public final class DisableSslCertificateCheckUtil extends Object
Modifier and Type | Field and Description |
---|---|
private static boolean |
disabled
Flag to indicate that certificate checks are disabled.
|
private static Logger |
LOG
Logger.
|
static HostnameVerifier |
NULL_HOSTNAME_VERIFIER
Null host name verifier.
|
static X509TrustManager |
NULL_TRUST_MANAGER
Null trust manager.
|
private static HostnameVerifier |
originalHostnameVerifier
Original hostname verifier, set by {
disableChecks() . |
private static SSLSocketFactory |
originalSslSocketFactory
Original SSL Socket factory, set by {
disableChecks() . |
Modifier | Constructor and Description |
---|---|
private |
DisableSslCertificateCheckUtil()
Prevent instantiation of utility class.
|
Modifier and Type | Method and Description |
---|---|
static SSLContext |
buildUnsecureSslContext()
Constructs an unsecure SSL context.
|
static void |
disableChecks()
Disable trust checks for SSL connections.
|
static void |
reenableChecks()
This will re-enable the SSL checks after it was disabled by
disableChecks() . |
private static boolean disabled
private static final Logger LOG
public static final HostnameVerifier NULL_HOSTNAME_VERIFIER
public static final X509TrustManager NULL_TRUST_MANAGER
private static HostnameVerifier originalHostnameVerifier
disableChecks()
.private static SSLSocketFactory originalSslSocketFactory
disableChecks()
.private DisableSslCertificateCheckUtil()
public static SSLContext buildUnsecureSslContext() throws GeneralSecurityException
Constructs an unsecure SSL context. This SSL context is configured with a
NULL_TRUST_MANAGER
. There is no guarantee that the
SSLContext
is thread-safe so new ones have to get created in
order to be safe.
The TLSv1
is guaranteed to be present according to the
SSLContext
javadoc. The SSLContext.getInstance(String)
method is used rather than SSLContext.getDefault()
as the default
context would have already been initialized therefore it would not allow
us to execute
SSLContext.init(javax.net.ssl.KeyManager[], TrustManager[], java.security.SecureRandom)
.
GeneralSecurityException
public static void disableChecks() throws GeneralSecurityException
GeneralSecurityException
- thrown when there is a problem disabling the SSL. Shouldn't
happen unless there is something wrong with the Java
implementation.public static void reenableChecks()
disableChecks()
.Copyright © 2012–2015 Trajano. All rights reserved.