解决LDAPS连接时报错 No subject alternative names present

源码分析报错的原因,对症下药

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
     
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值