I'm making HTTP request to a https website using Unirest for Java, but I have problem with SSL certificate. Exception message - javax.net.ssl.SSLException: hostname in certificate didn't match:
Page: www.ceskereality.cz
If I open it in browser (I'm using Google Chrome on Windows 10), it works...
I tried this, but it isn't working
SSLContext sslcontext = SSLContexts.custom()
.loadTrustMaterial(null, new TrustSelfSignedStrategy())
.build();
SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory(sslcontext,SSLConnectionSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
CloseableHttpClient httpclient = HttpClients.custom()
.setSSLSocketFactory(sslsf)
.build();
Unirest.setHttpClient(httpclient);