When we have a client/server application. There is certificate(SSL installed) in server side. So In that case we have a problem , how to extract data.In this case we can by pass the SSL just writing few lines of code.
Write the below code before hitting "https://url/" based URL.
try
{
final SSLContext ctx = SSLContext.getInstance("TLS");
final X509TrustManager tm = new X509TrustManager()
{
public void checkClientTrusted(final X509Certificate[] xcs, final String string) throws CertificateException
{
// do nothing
}
public void checkServerTrusted(final X509Certificate[] xcs, final String string) throws CertificateException
{
// do nothing
}
public X509Certificate[] getAcceptedIssuers()
{
return null;
}
};
ctx.init(null, new TrustManager[]{ tm }, null);
SSLContext.setDefault(ctx);
}
catch (final Exception ex)
{
ex.printStackTrace();
}
Enjoy https !!
0 Comment(s)