本文整理汇总了Java中org.apache.http.conn.ssl.SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER属性的典型用法代码示例。如果您正苦于以下问题:Java SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER属性的具体用法?Java SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER怎么用?Java SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.apache.http.conn.ssl.SSLSocketFactory
的用法示例。
在下文中一共展示了SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER属性的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createThreadSafeClient
private static void createThreadSafeClient(boolean forceSecure) {
httpClient = new DefaultHttpClient();
ClientConnectionManager mgr = httpClient.getConnectionManager();
HttpParams params = httpClient.getParams();
SchemeRegistry schemeRegistry = mgr.getSchemeRegistry();
if (forceSecure) {
schemeRegistry.register(new Scheme("https",
getSecureConnectionSetting(), 443));
} else {
HostnameVerifier hostnameVerifier = SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER;
SSLSocketFactory socketFactory = SSLSocketFactory
.getSocketFactory();
socketFactory
.setHostnameVerifier((X509HostnameVerifier) hostnameVerifier);
schemeRegistry.register(new Scheme("https", socketFactory, 443));
}
httpClient = new DefaultHttpClient(new ThreadSafeClientConnManager(params,
schemeRegistry), params);
}
示例2: switchOffSSLVerification
private HttpClient switchOffSSLVerification(HttpClient httpClient) throws GeneralSecurityException {
TrustStrategy acceptingTrustStrategy = new TrustStrategy() {
@Override
public boolean isTrusted(X509Certificate[] certificate, String authType) {
return true;
}
};
SSLSocketFactory socketFactory = new SSLSocketFactory(acceptingTrustStrategy, SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
httpClient.getConnectionManager().getSchemeRegistry().register(new Scheme("https", SSL_PORT, socketFactory));
return httpClient;
}
示例3: test4
public void test4() throws NoSuchAlgorithmException, ClientProtocolException, IOException, KeyManagementException{
Executor.unregisterScheme("https");
SSLContext sslContext = SSLContext.getInstance("SSL");
sslContext.init(null, null, null);
// ## SHOULD FIRE OVER-PERMISSIVE HOSTNAME VERIFIER
SSLSocketFactory sslSocketFactory = new SSLSocketFactory(sslContext, SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
Executor.registerScheme(new Scheme("https", 443, sslSocketFactory));
String responseAsString = Request.Get("https://www.google.com")
.execute().returnContent().asString();
System.out.println(responseAsString);
}
示例4: AzureSSLSocketFactory
public AzureSSLSocketFactory(AzureX509 creds, boolean disableSSLValidation) throws InternalException, NoSuchAlgorithmException, KeyManagementException, KeyStoreException, UnrecoverableKeyException {
super("TLS", creds.getKeystore(), AzureX509.PASSWORD, null, null, disableSSLValidation ? trustStrategy : null, SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
}
示例5: HC4TrustAllSSLSocketFactory
/**
* Create an SSL factory which trusts all certificates and hosts.
* {@link SSLSocketFactory#SSLSocketFactory(TrustStrategy, org.apache.http.conn.ssl.X509HostnameVerifier)}
* @param factory javax.net.ssl.SSLSocketFactory
* @throws GeneralSecurityException if there's a problem setting up the security
*/
protected HC4TrustAllSSLSocketFactory(javax.net.ssl.SSLSocketFactory factory) throws GeneralSecurityException {
super(TRUSTALL, SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
this.factory = factory;
}