当前位置: 首页>>代码示例>>Java>>正文


Java SSLSocketFactory.getSocketFactory方法代码示例

本文整理汇总了Java中cz.msebera.android.httpclient.conn.ssl.SSLSocketFactory.getSocketFactory方法的典型用法代码示例。如果您正苦于以下问题:Java SSLSocketFactory.getSocketFactory方法的具体用法?Java SSLSocketFactory.getSocketFactory怎么用?Java SSLSocketFactory.getSocketFactory使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在cz.msebera.android.httpclient.conn.ssl.SSLSocketFactory的用法示例。


在下文中一共展示了SSLSocketFactory.getSocketFactory方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getFixedSocketFactory

import cz.msebera.android.httpclient.conn.ssl.SSLSocketFactory; //导入方法依赖的package包/类
/**
 * Returns a SSlSocketFactory which trusts all certificates
 *
 * @return SSLSocketFactory
 */
public static SSLSocketFactory getFixedSocketFactory() {
    SSLSocketFactory socketFactory;
    try {
        socketFactory = new MySSLSocketFactory(getKeystore());
        socketFactory.setHostnameVerifier(SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
    } catch (Throwable t) {
        t.printStackTrace();
        socketFactory = SSLSocketFactory.getSocketFactory();
    }
    return socketFactory;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:17,代码来源:MySSLSocketFactory.java

示例2: getDefaultSchemeRegistry

import cz.msebera.android.httpclient.conn.ssl.SSLSocketFactory; //导入方法依赖的package包/类
/**
 * Returns default instance of SchemeRegistry
 *
 * @param fixNoHttpResponseException Whether to fix issue or not, by omitting SSL verification
 * @param httpPort                   HTTP port to be used, must be greater than 0
 * @param httpsPort                  HTTPS port to be used, must be greater than 0
 */
private static SchemeRegistry getDefaultSchemeRegistry(boolean fixNoHttpResponseException, int httpPort, int httpsPort) {
    if (fixNoHttpResponseException) {
        log.d(LOG_TAG, "Beware! Using the fix is insecure, as it doesn't verify SSL certificates.");
    }

    if (httpPort < 1) {
        httpPort = 80;
        log.d(LOG_TAG, "Invalid HTTP port number specified, defaulting to 80");
    }

    if (httpsPort < 1) {
        httpsPort = 443;
        log.d(LOG_TAG, "Invalid HTTPS port number specified, defaulting to 443");
    }

    // Fix to SSL flaw in API < ICS
    // See https://code.google.com/p/android/issues/detail?id=13117
    SSLSocketFactory sslSocketFactory;
    if (fixNoHttpResponseException) {
        sslSocketFactory = MySSLSocketFactory.getFixedSocketFactory();
    } else {
        sslSocketFactory = SSLSocketFactory.getSocketFactory();
    }

    SchemeRegistry schemeRegistry = new SchemeRegistry();
    schemeRegistry.register(new Scheme("http", PlainSocketFactory.getSocketFactory(), httpPort));
    schemeRegistry.register(new Scheme("https", sslSocketFactory, httpsPort));

    return schemeRegistry;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:38,代码来源:AsyncHttpClient.java


注:本文中的cz.msebera.android.httpclient.conn.ssl.SSLSocketFactory.getSocketFactory方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。