Android Https Connection

I got this error on Android SDK 1.1 on HTTPS connections.

java.io.IOException: Hostname <www.verisign.com> was not verified

To Fix it, just include this code bellow:

URL aURL = new URL(url);

HttpsURLConnection conn = (HttpsURLConnection) aURL.openConnection();
conn.setHostnameVerifier( new HostnameVerifier() {
public boolean verify( String hostname, SSLSession session ) {
return true;
}
});

conn.connect();

Enjoy!!

Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s