-
-
Notifications
You must be signed in to change notification settings - Fork 16.3k
Using an X509TrustManager with OPEN_SSL engine bypass hostname verification #6664
Description
Expected behavior
Using an X509TrustManager with OPEN_SSL engine should perform hostname verification.
Actual behavior
With JDK engine, when an X509TrustManager is passed in the SslContextBuilder, the returned X509TrustManager is wrapped by an X509ExtendedTrustManager that performs hostname verification, for instance here is a verification failure trace:
Caused by: java.security.cert.CertificateException: No name matching localhost_ found
at sun.security.util.HostnameChecker.matchDNS(HostnameChecker.java:221)
at sun.security.util.HostnameChecker.match(HostnameChecker.java:95)
at sun.security.ssl.X509TrustManagerImpl.checkIdentity(X509TrustManagerImpl.java:455)
at sun.security.ssl.AbstractTrustManagerWrapper.checkAdditionalTrust(SSLContextImpl.java:998)
at sun.security.ssl.AbstractTrustManagerWrapper.checkServerTrusted(SSLContextImpl.java:937)
at sun.security.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:1496)
When using the OPEN_SSL engine, the checkServerTrusted(X509Certificate[] x509Certificates, String s) of X509TrustManager is called for verification purpose but it cannot perform the hostname validation as it does not have access to the engine that contains the parameters.
Steps to reproduce
https://github.com/vietj/netty-openssl-custom-trustmanager-verification-error
- change JDK engine to OPEN_SSL in the
SslContextBuilder - run the test : the hostname verification should fail
Minimal yet complete reproducer code (or URL to code)
Netty version
4.1.8.Final is used in the reproducer but it fails too with 4.1.9.Final
JVM version (e.g. java -version)
java version "1.8.0_92"
OS version (e.g. uname -a)
Darwin julien 15.6.0 Darwin Kernel Version 15.6.0: Fri Feb 17 10:21:18 PST 2017; root:xnu-3248.60.11.4.1~1/RELEASE_X86_64 x86_64
o