本文整理匯總了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;
}