mirror of
https://github.com/square/okhttp.git
synced 2026-01-18 20:40:58 +03:00
Merge pull request #693 from square/adrian.okcurl-verify
okcurl --insecure means allow any hostname
This commit is contained in:
@@ -37,7 +37,9 @@ import java.security.cert.X509Certificate;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
import javax.net.ssl.HostnameVerifier;
|
||||
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;
|
||||
@@ -168,6 +170,7 @@ public class Main extends HelpOption implements Runnable {
|
||||
}
|
||||
if (allowInsecure) {
|
||||
client.setSslSocketFactory(createInsecureSslSocketFactory());
|
||||
client.setHostnameVerifier(createInsecureHostnameVerifier());
|
||||
}
|
||||
// If we don't set this reference, there's no way to clean shutdown persistent connections.
|
||||
client.setConnectionPool(ConnectionPool.getDefault());
|
||||
@@ -251,4 +254,12 @@ public class Main extends HelpOption implements Runnable {
|
||||
throw new AssertionError(e);
|
||||
}
|
||||
}
|
||||
|
||||
private static HostnameVerifier createInsecureHostnameVerifier() {
|
||||
return new HostnameVerifier() {
|
||||
@Override public boolean verify(String s, SSLSession sslSession) {
|
||||
return true;
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user