Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error : java.security.cert.CertificateException: Illegal given domain name: abc_xyz.stg.myweb.com

Tags:

java

ssl

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?

like image 318
Nitin Parashar Avatar asked Dec 18 '17 09:12

Nitin Parashar


2 Answers

In case anyone see this issue again. This issue is caused by an old jdk that thinks an underscore is invalid as the sub domain name, which in a later version has been removed from the jdk. So in short upgrade jdk version will solve this issue.

like image 173
jacob Avatar answered Sep 30 '22 06:09

jacob


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;
        }
    });
like image 33
Fabien MIFSUD Avatar answered Sep 30 '22 04:09

Fabien MIFSUD