mirror of https://github.com/shred/acme4j
Accept all host names when accessing Pebble
parent
cda0f4284b
commit
1e50669999
|
@ -26,8 +26,10 @@ import java.security.cert.CertificateException;
|
||||||
|
|
||||||
import javax.annotation.ParametersAreNonnullByDefault;
|
import javax.annotation.ParametersAreNonnullByDefault;
|
||||||
import javax.annotation.concurrent.ThreadSafe;
|
import javax.annotation.concurrent.ThreadSafe;
|
||||||
|
import javax.net.ssl.HostnameVerifier;
|
||||||
import javax.net.ssl.HttpsURLConnection;
|
import javax.net.ssl.HttpsURLConnection;
|
||||||
import javax.net.ssl.SSLContext;
|
import javax.net.ssl.SSLContext;
|
||||||
|
import javax.net.ssl.SSLSession;
|
||||||
import javax.net.ssl.SSLSocketFactory;
|
import javax.net.ssl.SSLSocketFactory;
|
||||||
import javax.net.ssl.TrustManagerFactory;
|
import javax.net.ssl.TrustManagerFactory;
|
||||||
|
|
||||||
|
@ -41,13 +43,22 @@ import org.shredzone.acme4j.connector.HttpConnector;
|
||||||
@ThreadSafe
|
@ThreadSafe
|
||||||
public class PebbleHttpConnector extends HttpConnector {
|
public class PebbleHttpConnector extends HttpConnector {
|
||||||
|
|
||||||
|
private static HostnameVerifier ALLOW_ALL_HOSTNAME_VERIFIER = new HostnameVerifier() {
|
||||||
|
@Override
|
||||||
|
public boolean verify(String hostname, SSLSession session) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
private static SSLSocketFactory sslSocketFactory;
|
private static SSLSocketFactory sslSocketFactory;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public HttpURLConnection openConnection(URL url, Proxy proxy) throws IOException {
|
public HttpURLConnection openConnection(URL url, Proxy proxy) throws IOException {
|
||||||
HttpURLConnection conn = super.openConnection(url, proxy);
|
HttpURLConnection conn = super.openConnection(url, proxy);
|
||||||
if (conn instanceof HttpsURLConnection) {
|
if (conn instanceof HttpsURLConnection) {
|
||||||
((HttpsURLConnection) conn).setSSLSocketFactory(createSocketFactory());
|
HttpsURLConnection conns = (HttpsURLConnection) conn;
|
||||||
|
conns.setSSLSocketFactory(createSocketFactory());
|
||||||
|
conns.setHostnameVerifier(ALLOW_ALL_HOSTNAME_VERIFIER);
|
||||||
}
|
}
|
||||||
return conn;
|
return conn;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue