我尝试使用SSL双向创建加特林测试,但我无法禁用主机名验证。我正在使用Gatling 2.3。这是我的Gatling配置:
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")
我可以看到我的密钥库和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
答案 0 :(得分:1)
从Gatling SSL documentation您可以尝试禁用SNI(-Djsse.enableSNIExtension=false
)。但是,如果你真的需要SNI(SSL虚拟主机),你不想这样做,你需要编写自己的HostNameVerifier代码,虽然我不知道如何在Gatling中包含它。
答案 1 :(得分:1)
如果有人仍在寻找解决方案:此功能已在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")
}