Error : java.security.cert.CertificateException: I

2019-07-13 09:22发布

Hi team i found below exception when calling an api

https://abc_xyz.stg.myweb.com/api/AuthorizedUser?username=admin&password=admin

java.security.cert.CertificateException: Illegal given domain name

when getting response from server using Jersey. Everything is fine when i get response from postman.

Why it is illegal domain name, whether browser not refuse to open this.

If my domain name not contains underscore then this exception is not rising. Is this problem of underscore in domain name?

标签: java ssl
2条回答
放荡不羁爱自由
2楼-- · 2019-07-13 09:53

In case anyone see this issue again. This issue is cased by old jdk think underscore is invalid as the sub domain name, and it is later removed from the jdk. So in short upgrade jdk version will slove this issue.

查看更多
仙女界的扛把子
3楼-- · 2019-07-13 10:15

In case someone see this issue again and don't want to change jdk version, it is possible to disable the SSL Host name verification (and it is not the good solution but sometimes it is not possible to avoid this..) :

    HttpsURLConnection.setDefaultHostnameVerifier(new HostnameVerifier() {
        public boolean verify(String hostname, SSLSession session) {
            return true;
        }
    });
查看更多
登录 后发表回答