Package uk.ac.ebi.utils.opt.net
Class SSLUtils
java.lang.Object
uk.ac.ebi.utils.opt.net.SSLUtils
SSL Utilities.
At the moment contains methods to disable SSL certificate verification in HTTP connections.
WARNING: doing this is UNSAFE, you should fix the bad certificate on server side instead.
Courtesy of
this.
- Author:
- brandizi
- Date:
- 29 Nov 2016
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
Trusts all certificates. -
Field Summary
Modifier and TypeFieldDescriptionstatic final org.apache.hc.client5.http.auth.AuthScope
static final org.apache.hc.client5.http.io.HttpClientConnectionManager
static final SSLContext
static final org.apache.hc.client5.http.ssl.DefaultClientTlsStrategy
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic org.apache.hc.client5.http.classic.HttpClient
noCertClient
(String user, String pwd) Gets anHttpClient
that doesn't do any SSL certificate verification.static void
Set the default host name Verifier to an instance of a fake class that trust all hostnames.static void
Set the default X509 Trust Manager to an instance of a fake class that trust all certificates, even the self-signed ones.
-
Field Details
-
FAKE_SSL_CONTEXT
-
FAKE_TLS_STRATEGY
public static final org.apache.hc.client5.http.ssl.DefaultClientTlsStrategy FAKE_TLS_STRATEGY -
FAKE_HTTP_CLIENT_CONNECTION_MANAGER
public static final org.apache.hc.client5.http.io.HttpClientConnectionManager FAKE_HTTP_CLIENT_CONNECTION_MANAGER -
FAKE_AUTH_SCOPE
public static final org.apache.hc.client5.http.auth.AuthScope FAKE_AUTH_SCOPE
-
-
Constructor Details
-
SSLUtils
public SSLUtils()
-
-
Method Details
-
trustAllHostnames
public static void trustAllHostnames()Set the default host name Verifier to an instance of a fake class that trust all hostnames. -
trustAllHttpsCertificates
public static void trustAllHttpsCertificates()Set the default X509 Trust Manager to an instance of a fake class that trust all certificates, even the self-signed ones. -
noCertClient
Gets anHttpClient
that doesn't do any SSL certificate verification. If user is null, returns a client that doesn't deal with authentication, else sets up a client that does basicHTTP Auth
.
-