Hello,
I'd like to access content that is provided by https but my code always fails
with an SSLException. I tried it with a very simple example:
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.DefaultHttpClient;
public class HttpsTest {
public static void main(final String[] args) throws Exception {
final HttpClient client = new DefaultHttpClient();
final HttpGet req = new HttpGet("https://www.apache.org");
client.execute(req);
}
}
This code fails with:
Exception in thread "main" javax.net.ssl.SSLException: hostname in certificate
didn't match: <140.211.11.131> != <*.apache.org>
at
org.apache.http.conn.ssl.AbstractVerifier.verify(AbstractVerifier.java:220)
at
org.apache.http.conn.ssl.BrowserCompatHostnameVerifier.verify(BrowserCompatHostnameVerifier.java:54)
at
org.apache.http.conn.ssl.AbstractVerifier.verify(AbstractVerifier.java:149)
at
org.apache.http.conn.ssl.AbstractVerifier.verify(AbstractVerifier.java:130)
at
org.apache.http.conn.ssl.SSLSocketFactory.createSocket(SSLSocketFactory.java:399)
at
org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:143)
at
org.apache.http.impl.conn.AbstractPoolEntry.open(AbstractPoolEntry.java:149)
at
org.apache.http.impl.conn.AbstractPooledConnAdapter.open(AbstractPooledConnAdapter.java:108)
at
org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:415)
at
org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:641)
at
org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:576)
at
org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:554)
at HttpsTest.fails(HttpsTest.java:25)
at HttpsTest.main(HttpsTest.java:12)
It doesn't has anything to do with wildcard certificates. Whenever I get this
exception I have a combination of <ip-address> != <common-name-of-certificate>
as exception message. What am I
doing wrong? Unfortunately I couldn't find a simple SSL example in the docs,
only stuff for customizing SSL configuration.
Bye
Oliver
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]