我正在尝试使用 SSL 两种方式创建加特林测试,但我无法禁用主机名验证。我正在使用加特林 2.3。这是我的加特林配置:
ssl {
keyStore {
type = "JKS"
file = "keystore.jks"
password = "changeit"
#algorithm = ""
}
trustStore {
type = "JKS"
file = "truststore.jks"
password = "changeit"
#algorithm = ""
}
}
ahc {
acceptAnyCertificate = true
....
}
我还在我的应用程序的开头添加了此系统属性
System.setProperty("jdk.tls.allowUnsafeServerCertChange", "true")
System.setProperty("sun.security.ssl.allowUnsafeRenegotiation", "true")
我可以看到我的 keystore 和 trutstore 已正确使用,但我仍然遇到此问题:
java.security.cert.CertificateException: No subject alternative DNS name matching <my_dns> found.
at sun.security.util.HostnameChecker.matchDNS(HostnameChecker.java:204)
at sun.security.util.HostnameChecker.match(HostnameChecker.java:95)
at sun.security.ssl.X509TrustManagerImpl.checkIdentity(X509TrustManagerImpl.java:455)
at sun.security.ssl.X509TrustManagerImpl.checkIdentity(X509TrustManagerImpl.java:436)
at sun.security.ssl.X509TrustManagerImpl.checkTrusted(X509TrustManagerImpl.java:252)
at sun.security.ssl.X509TrustManagerImpl.checkServerTrusted(X509TrustManagerImpl.java:136)
at sun.security.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:1493)
... 28 common frames omitted
最佳答案
如果有人仍在寻找解决方案:此功能已在 Gatling v3.0 中实现。
相关配置参数为:
ahc {
enableSni = true # When set to true, enable Server Name indication (SNI)
enableHostnameVerification = false # When set to true, enable hostname verification: SSLEngine.setHttpsEndpointIdentificationAlgorithm("HTTPS")
}
关于java - 如何使用 Gatting 和 SSL 两种方式禁用 SSL 主机名验证,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50755456/