www in docker support
This commit is contained in:
parent
539a848e95
commit
c227fce036
2145 changed files with 399596 additions and 58 deletions
|
|
@ -0,0 +1,49 @@
|
|||
package it.acxent.skebby.api;
|
||||
|
||||
import java.security.GeneralSecurityException;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.security.SecureRandom;
|
||||
import java.security.cert.X509Certificate;
|
||||
import javax.net.ssl.SSLContext;
|
||||
import javax.net.ssl.SSLSession;
|
||||
import javax.net.ssl.SSLSocketFactory;
|
||||
import javax.net.ssl.TrustManager;
|
||||
import javax.net.ssl.X509TrustManager;
|
||||
import okhttp3.OkHttpClient;
|
||||
|
||||
public class UnsafeOkHttpSSL {
|
||||
private static TrustManager[] getAllTrustingTrustManager() {
|
||||
return new TrustManager[] { new X509TrustManager() {
|
||||
public void checkClientTrusted(X509Certificate[] chain, String authType) {}
|
||||
|
||||
public void checkServerTrusted(X509Certificate[] chain, String authType) {}
|
||||
|
||||
public X509Certificate[] getAcceptedIssuers() {
|
||||
return new X509Certificate[0];
|
||||
}
|
||||
} };
|
||||
}
|
||||
|
||||
private static SSLSocketFactory getUnsafeSslSocketFactory() {
|
||||
try {
|
||||
SSLContext sslContext = SSLContext.getInstance("TLS");
|
||||
sslContext.init(null, getAllTrustingTrustManager(), new SecureRandom());
|
||||
return sslContext.getSocketFactory();
|
||||
} catch (NoSuchAlgorithmException|java.security.KeyManagementException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public static OkHttpClient getUnsafeOkHttpClient() {
|
||||
try {
|
||||
OkHttpClient.Builder builder = new OkHttpClient.Builder();
|
||||
TrustManager[] trustAllCerts = getAllTrustingTrustManager();
|
||||
X509TrustManager trustManager = (X509TrustManager)trustAllCerts[0];
|
||||
builder.sslSocketFactory(getUnsafeSslSocketFactory(), trustManager);
|
||||
builder.hostnameVerifier((hostname, session) -> true);
|
||||
return builder.build();
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue