java.security.cert.CertificateException:

2.3k views Asked by At

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,

1

There are 1 answers

0
C.P.O On

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.