Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
liyiorg committed Aug 5, 2015
1 parent 6cd49db commit 8d15785
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 16 deletions.
2 changes: 2 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ Changes in version 2.4.4 (2015-08-05)
-------------------------------------
*issue #17 对帐单bug修复
*MediaAPI 添加 mediaUploadimg,上传图文消息内的图片获取URL
*修改退款申请bug
*修改 初始化 MCH HttpClient KeyStore 调用方式

Changes in version 2.4.3 (2015-08-03)
-------------------------------------
Expand Down
11 changes: 2 additions & 9 deletions src/main/java/weixin/popular/client/HttpClientFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -62,19 +62,12 @@ public static HttpClient createHttpClient(int maxTotal,int maxPerRoute) {
* @param maxPerRoute
* @return
*/
public static HttpClient createKeyMaterialHttpClient(KeyStore keystore,String keyPassword,String[] supportedProtocols,int maxTotal,int maxPerRoute) {
public static HttpClient createKeyMaterialHttpClient(KeyStore keystore,String keyPassword,String[] supportedProtocols) {
try {

SSLContext sslContext = SSLContexts.custom().useSSL().loadKeyMaterial(keystore, keyPassword.toCharArray()).build();
SSLConnectionSocketFactory sf = new SSLConnectionSocketFactory(sslContext,supportedProtocols,
null,SSLConnectionSocketFactory.BROWSER_COMPATIBLE_HOSTNAME_VERIFIER);
PoolingHttpClientConnectionManager poolingHttpClientConnectionManager = new PoolingHttpClientConnectionManager();
poolingHttpClientConnectionManager.setMaxTotal(maxTotal);
poolingHttpClientConnectionManager.setDefaultMaxPerRoute(maxPerRoute);
return HttpClientBuilder.create()
.setConnectionManager(poolingHttpClientConnectionManager)
.setSSLSocketFactory(sf)
.build();
return HttpClientBuilder.create().setSSLSocketFactory(sf).build();
} catch (KeyManagementException e) {
e.printStackTrace();
} catch (NoSuchAlgorithmException e) {
Expand Down
11 changes: 4 additions & 7 deletions src/main/java/weixin/popular/client/LocalHttpClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,16 @@ public static void init(int maxTotal,int maxPerRoute){

/**
* 初始化 MCH HttpClient KeyStore
* @param keyStoreName keyStore 名称
* @param keyStoreFilePath 私钥文件路径
* @param mch_id
* @param maxTotal
* @param maxPerRoute
* @param keyStoreFilePath
*/
public static void initMchKeyStore(String keyStoreName,String keyStoreFilePath,String mch_id,int maxTotal,int maxPerRoute){
public static void initMchKeyStore(String mch_id,String keyStoreFilePath){
try {
KeyStore keyStore = KeyStore.getInstance(keyStoreName);
KeyStore keyStore = KeyStore.getInstance("PKCS12");
FileInputStream instream = new FileInputStream(new File(keyStoreFilePath));
keyStore.load(instream,mch_id.toCharArray());
instream.close();
HttpClient httpClient = HttpClientFactory.createKeyMaterialHttpClient(keyStore, mch_id, new String[]{"TLSv1"}, maxTotal, maxPerRoute);
HttpClient httpClient = HttpClientFactory.createKeyMaterialHttpClient(keyStore, mch_id, new String[]{"TLSv1"});
httpClient_mchKeyStore.put(mch_id, httpClient);
} catch (KeyStoreException e) {
e.printStackTrace();
Expand Down

0 comments on commit 8d15785

Please sign in to comment.