Suggest a feature
×

Welcome to TagMyCode

Please login or create account to add a snippet.
0
0
 
0
Language: Java
Posted by: Carlos Wu
Added: Mar 16, 2018 6:46 AM
Modified: Mar 16, 2018 6:58 AM
Views: 17
Tags: no tags
  1. @Bean
  2. @Qualifier("crispByDemographicsHttpClient")
  3. CloseableHttpClient crispByDemographicsHttpClient() {
  4.         KeyStore keyStore = KeyStore.getInstance("JKS")
  5.         keyStore.load(new FileInputStream(crisp_path), EncryptionUtil.basicDecrypt(crisp_keystore_pass).toCharArray())
  6.  
  7.         SSLConnectionSocketFactory trustSelfSignedSocketFactory = new SSLConnectionSocketFactory(
  8.                         new SSLContextBuilder().loadKeyMaterial(
  9.                                         keyStore,
  10.                                         EncryptionUtil.basicDecrypt(crisp_key_pass).toCharArray()
  11.                         ).build(),
  12.                         new NoopHostnameVerifier())
  13.  
  14.         Registry<ConnectionSocketFactory> socketFactoryRegistry = RegistryBuilder
  15.                         .<ConnectionSocketFactory> create()
  16.                         .register("http", new PlainConnectionSocketFactory())
  17.                         .register("https", trustSelfSignedSocketFactory)
  18.                         .build()
  19.  
  20.         PoolingHttpClientConnectionManager cm = new PoolingHttpClientConnectionManager(socketFactoryRegistry)
  21.  
  22.         return HttpClients.custom().setConnectionManager(cm).build()
  23. }
  24.