源码分析报错的原因,对症下药
JDK7使用自签证书使用LDAPS完全没问题,后来升级JDK14后就无法连接,查看日志打印 No subject alternative names present,查看源码分析:
定位到:sun.security.util.HostnameChecker
JDK14 需要验证扩展属性中的IP,我的证书域名时IP地址,如果是域名则会验证DNS
/**
* Check if the certificate allows use of the given IP address.
*
* From RFC2818:
* In some cases, the URI is specified as an IP address rather than a
* hostname. In this case, the iPAddress subjectAltName must be present
* in the certificate and must exactly match the IP in the URI.
*/
private static void matchIP(String expectedIP, X509Certificate cert)
throws CertificateException {
Collection<List<?>> subjAltNames = cert.getSubjectAlternativeNames();
//之前是V1的证书没有扩展属性,这里返回的是null
if (subjAltNames == null) {
throw new CertificateException