org.jlot.client.config.rest.SSLContextInitalizer Maven / Gradle / Ivy
package org.jlot.client.config.rest;
import java.security.cert.CertificateException;
import java.security.cert.X509Certificate;
import javax.net.ssl.SSLContext;
import javax.net.ssl.TrustManager;
import javax.net.ssl.X509TrustManager;
import org.springframework.stereotype.Component;
@Component
public class SSLContextInitalizer
{
public SSLContextInitalizer ()
{
initalize();
}
public void initalize ( )
{
try
{
SSLContext ctx = SSLContext.getInstance("TLS");
X509TrustManager tm = new X509TrustManager()
{
@Override
public void checkClientTrusted ( X509Certificate[] xcs, String string ) throws CertificateException
{}
@Override
public void checkServerTrusted ( X509Certificate[] xcs, String string ) throws CertificateException
{}
@Override
public X509Certificate[] getAcceptedIssuers ( )
{
return null;
}
};
ctx.init(null, new TrustManager[] { tm }, null);
SSLContext.setDefault(ctx);
}
catch (Exception ex)
{
ex.printStackTrace();
}
}
}