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


Java SSLConnectionSocketFactory.BROWSER_COMPATIBLE_HOSTNAME_VERIFIER属性代码示例

本文整理汇总了Java中org.apache.http.conn.ssl.SSLConnectionSocketFactory.BROWSER_COMPATIBLE_HOSTNAME_VERIFIER属性的典型用法代码示例。如果您正苦于以下问题:Java SSLConnectionSocketFactory.BROWSER_COMPATIBLE_HOSTNAME_VERIFIER属性的具体用法?Java SSLConnectionSocketFactory.BROWSER_COMPATIBLE_HOSTNAME_VERIFIER怎么用?Java SSLConnectionSocketFactory.BROWSER_COMPATIBLE_HOSTNAME_VERIFIER使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在org.apache.http.conn.ssl.SSLConnectionSocketFactory的用法示例。


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

示例1: ceateSSLClient

public static CloseableHttpClient ceateSSLClient(File keyFile, String protocol, String password){
	CloseableHttpClient httpclient = null;
	try{
		KeyStore keyStore  = KeyStore.getInstance("PKCS12");
        FileInputStream instream = new FileInputStream(keyFile);
        try {
            keyStore.load(instream, password.toCharArray());
        } finally {
            instream.close();
        }
        // Trust own CA and all self-signed certs
        SSLContext sslcontext = SSLContexts.custom().loadKeyMaterial(keyStore, password.toCharArray()).build();
        // Allow TLSv1 protocol only
        String[] protocols = new String[] {protocol};
        SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory(sslcontext,protocols,null,SSLConnectionSocketFactory.BROWSER_COMPATIBLE_HOSTNAME_VERIFIER);
        httpclient = HttpClients.custom().setSSLSocketFactory(sslsf).build();
	}catch(Exception e){
		e.printStackTrace();
	}
	return httpclient;
}
 
开发者ID:anylineorg,项目名称:anyline,代码行数:21,代码来源:HttpClientUtil.java

示例2: getSSLConnectionSocketFactory

/**
     * 
    		*@name 获取ssl链接
    		*@Description  
    		*@CreateDate 2015年12月31日下午2:34:40
     */
    public static SSLConnectionSocketFactory getSSLConnectionSocketFactory(String keyStoreType,String certFilePath,String certPassword) throws Exception{
    	KeyStore keyStore  = KeyStore.getInstance(keyStoreType);
//        FileInputStream instream = new FileInputStream(new File(certFilePath));
    	InputStream instream = null;
        try {
        	instream = new ClassPathResource(certFilePath).getInputStream();
            keyStore.load(instream, certPassword.toCharArray());
        } 
        finally {
            instream.close();
        }

        SSLContext sslContext = SSLContexts.custom()
                		  				   .loadKeyMaterial(keyStore, certPassword.toCharArray())
                		  				   .build();
        
        return new SSLConnectionSocketFactory(sslContext,new String[] { "TLSv1" },null,
                	SSLConnectionSocketFactory.BROWSER_COMPATIBLE_HOSTNAME_VERIFIER);
    }
 
开发者ID:yinshipeng,项目名称:sosoapi-base,代码行数:25,代码来源:HttpClientUtils.java

示例3: getHostNameVerifier

@ReviewBeforeRelease("Need to have a way to communicate with HTTP impl supports disabling of strict" +
                     "hostname verification. If it doesn't we either need to fail in S3 or switch to path style" +
                     "addressing.")
private HostnameVerifier getHostNameVerifier(AttributeMap standardOptions) {
    // TODO Need to find a better way to handle these deprecations.
    return standardOptions.get(SdkHttpConfigurationOption.USE_STRICT_HOSTNAME_VERIFICATION)
            ? SSLConnectionSocketFactory.STRICT_HOSTNAME_VERIFIER
            : SSLConnectionSocketFactory.BROWSER_COMPATIBLE_HOSTNAME_VERIFIER;
}
 
开发者ID:aws,项目名称:aws-sdk-java-v2,代码行数:9,代码来源:ApacheConnectionManagerFactory.java

示例4:

private HostnameVerifier getHostNameVerifier
        (HttpClientSettings options) {
    // TODO Need to find a better way to handle these deprecations.
    return options.useBrowserCompatibleHostNameVerifier()
            ? SSLConnectionSocketFactory.BROWSER_COMPATIBLE_HOSTNAME_VERIFIER
            : SSLConnectionSocketFactory.STRICT_HOSTNAME_VERIFIER;
}
 
开发者ID:IBM,项目名称:ibm-cos-sdk-java,代码行数:7,代码来源:ApacheConnectionManagerFactory.java

示例5: init

private void init() throws IOException, KeyStoreException, UnrecoverableKeyException, NoSuchAlgorithmException, KeyManagementException {

        KeyStore keyStore = KeyStore.getInstance("PKCS12");
        FileInputStream instream = new FileInputStream(new File(config.getCertLocalPath()));//加载本地的证书进行https加密传输
        try {
            keyStore.load(instream,config.getCertPassword().toCharArray());//设置证书密码
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            instream.close();
        }

        // Trust own CA and all self-signed certs
        SSLContext sslcontext = SSLContexts.custom()
                .loadKeyMaterial(keyStore, config.getCertPassword().toCharArray())
                .build();
        // Allow TLSv1 protocol only
        SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory(
                sslcontext,
                new String[]{"TLSv1"},
                null,
                SSLConnectionSocketFactory.BROWSER_COMPATIBLE_HOSTNAME_VERIFIER);

        httpClient = HttpClients.custom()
                .setSSLSocketFactory(sslsf)
                .build();

        //根据默认超时限制初始化requestConfig
        requestConfig = RequestConfig.custom().setSocketTimeout(socketTimeout).setConnectTimeout(connectTimeout).build();

        hasInit = true;
    }
 
开发者ID:1991wangliang,项目名称:pay,代码行数:32,代码来源:HttpsRequest.java

示例6: main

public final static void main(String[] args) throws Exception {
    KeyStore keyStore  = KeyStore.getInstance("PKCS12");
    FileInputStream instream = new FileInputStream(new File("D:/10016225.p12"));
    try {
        keyStore.load(instream, "10016225".toCharArray());
    } finally {
        instream.close();
    }

    // Trust own CA and all self-signed certs
    SSLContext sslcontext = SSLContexts.custom()
            .loadKeyMaterial(keyStore, "10016225".toCharArray())
            .build();
    // Allow TLSv1 protocol only
    SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory(
            sslcontext,
            new String[] { "TLSv1" },
            null,
            SSLConnectionSocketFactory.BROWSER_COMPATIBLE_HOSTNAME_VERIFIER);
    CloseableHttpClient httpclient = HttpClients.custom()
            .setSSLSocketFactory(sslsf)
            .build();
    try {

        HttpGet httpget = new HttpGet("https://api.mch.weixin.qq.com/secapi/pay/refund");

        System.out.println("executing request" + httpget.getRequestLine());

        CloseableHttpResponse response = httpclient.execute(httpget);
        try {
            HttpEntity entity = response.getEntity();

            System.out.println("----------------------------------------");
            System.out.println(response.getStatusLine());
            if (entity != null) {
                System.out.println("Response content length: " + entity.getContentLength());
                BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(entity.getContent()));
                String text;
                while ((text = bufferedReader.readLine()) != null) {
                    System.out.println(text);
                }
               
            }
            EntityUtils.consume(entity);
        } finally {
            response.close();
        }
    } finally {
        httpclient.close();
    }
}
 
开发者ID:guhanjie,项目名称:weixin-boot,代码行数:51,代码来源:TestHttpsClientCustomSSL.java


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