I am creating a java application where I need to bypass SSL authentication for some URL connection, not for all URL connection. Currently I am using the following code:
TrustManager[] trustAllCerts = new TrustManager[] {
new X509TrustManager() {
public java.security.cert.X509Certificate[] getAcceptedIssuers() {
return null;
}
public void checkClientTrusted (
java.security.cert.X509Certificate[] certs, String authType) {
}
public void checkServerTrusted (
java.security.cert.X509Certificate[] certs, String authType) {
}
}
};
try {
SSLContext sc = SSLContext.getInstance("SSL");
sc.init(null, trustAllCerts, new java.security.SecureRandom());
HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory());
} catch (Exception e) {
}
In this code all URL connection skipping SSL authentication, until the application get restarted.
Is there any way so that we can skip SSL authentication check only for some URL connection, not for all URL connection?