简体   繁体   中英

java.security.cert.CertificateException:

While creating Web Service Client in IBM RSA I'm getting below exception.. "Exception: javax.net.ssl.SSLHandshakeException: java.security.cert.CertificateException: No subject alternative DNS name matching "

Please advise how to resolve this issue.

Thanks,

You need to install the SSL certificate from server into client machine. Note if the SSL certificate is selft-signed, you need to disable SSL check like this:

    static {
            javax.net.ssl.HttpsURLConnection.setDefaultHostnameVerifier(new javax.net.ssl.HostnameVerifier() {

                public boolean verify(String hostname, javax.net.ssl.SSLSession sslSession) {

                    //for localhost or same LAN
                    if (hostname.equals("localhost") || hostname.startsWith("192.168")) {
                        return true;
                    }
                    return false;
                }
            });
        }

Note: in the SSL certificate, the CN property, must match the server name or the domain name. (CN = my-domain.com) is for a server published on my-domain.com.

If you are using some certificate designed for other server name or domain, you need to declare the match in operating system hosts file.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM