Authored by mali

Merge branch 'test6.9.13' of http://git.yoho.cn/ufo/yohoufo-fore into test6.9.13

@@ -55,21 +55,8 @@ public class HttpClient { @@ -55,21 +55,8 @@ public class HttpClient {
55 private CloseableHttpClient httpClient; 55 private CloseableHttpClient httpClient;
56 56
57 @PostConstruct 57 @PostConstruct
58 - public void init() {  
59 - new Thread(() -> {  
60 - while (Objects.isNull(httpClient)) {  
61 - try { 58 + public void init() throws Exception {
62 httpClient = this.buildHttpClient(); 59 httpClient = this.buildHttpClient();
63 - } catch (Exception e) {  
64 - log.warn("build http client fail, {}", e.getMessage());  
65 - }  
66 - try {  
67 - Thread.sleep(3 * 1000);  
68 - } catch (InterruptedException e) {  
69 -  
70 - }  
71 - }  
72 - }, "http-client-builder-" + this.getClass().getSimpleName()).start();  
73 } 60 }
74 61
75 public CloseableHttpClient buildHttpClient() throws Exception { 62 public CloseableHttpClient buildHttpClient() throws Exception {
@@ -15,7 +15,6 @@ import org.apache.http.impl.conn.PoolingHttpClientConnectionManager; @@ -15,7 +15,6 @@ import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
15 import org.apache.http.ssl.SSLContextBuilder; 15 import org.apache.http.ssl.SSLContextBuilder;
16 import org.springframework.beans.factory.annotation.Autowired; 16 import org.springframework.beans.factory.annotation.Autowired;
17 17
18 -import javax.annotation.PostConstruct;  
19 import javax.net.ssl.HostnameVerifier; 18 import javax.net.ssl.HostnameVerifier;
20 import javax.net.ssl.SSLContext; 19 import javax.net.ssl.SSLContext;
21 20
@@ -32,6 +31,8 @@ public abstract class HttpSslClientAbstract extends HttpClient { @@ -32,6 +31,8 @@ public abstract class HttpSslClientAbstract extends HttpClient {
32 31
33 protected abstract String getMchId(); 32 protected abstract String getMchId();
34 33
  34 + protected abstract String getMchCertPath();
  35 +
35 36
36 @Override 37 @Override
37 public CloseableHttpClient buildHttpClient() throws Exception { 38 public CloseableHttpClient buildHttpClient() throws Exception {
@@ -57,7 +58,7 @@ public abstract class HttpSslClientAbstract extends HttpClient { @@ -57,7 +58,7 @@ public abstract class HttpSslClientAbstract extends HttpClient {
57 SSLConnectionSocketFactory sslSocketFactory = new SSLConnectionSocketFactory( 58 SSLConnectionSocketFactory sslSocketFactory = new SSLConnectionSocketFactory(
58 sslContext, hostnameVerifier); 59 sslContext, hostnameVerifier);
59 Registry<ConnectionSocketFactory> socketFactoryRegistry = RegistryBuilder 60 Registry<ConnectionSocketFactory> socketFactoryRegistry = RegistryBuilder
60 - .<ConnectionSocketFactory> create() 61 + .<ConnectionSocketFactory>create()
61 .register("http", 62 .register("http",
62 PlainConnectionSocketFactory.getSocketFactory()) 63 PlainConnectionSocketFactory.getSocketFactory())
63 .register("https", sslSocketFactory).build(); 64 .register("https", sslSocketFactory).build();
@@ -86,7 +87,7 @@ public abstract class HttpSslClientAbstract extends HttpClient { @@ -86,7 +87,7 @@ public abstract class HttpSslClientAbstract extends HttpClient {
86 } 87 }
87 88
88 private void loadKeyMaterial(SSLContextBuilder sslContextBuilder) throws Exception { 89 private void loadKeyMaterial(SSLContextBuilder sslContextBuilder) throws Exception {
89 - wechatHelper.loadKeyMaterial(getMchId(), sslContextBuilder); 90 + wechatHelper.loadKeyMaterial(getMchId(), getMchCertPath(), sslContextBuilder);
90 } 91 }
91 92
92 } 93 }
@@ -12,4 +12,10 @@ public class WxMiniappHttpSslClient extends HttpSslClientAbstract { @@ -12,4 +12,10 @@ public class WxMiniappHttpSslClient extends HttpSslClientAbstract {
12 protected String getMchId() { 12 protected String getMchId() {
13 return WeixinPayConfig.Miniapp.MALL_ID; 13 return WeixinPayConfig.Miniapp.MALL_ID;
14 } 14 }
  15 +
  16 + @Override
  17 + protected String getMchCertPath() {
  18 + return WeixinPayConfig.Miniapp.APP_PARTNER_CERT;
  19 + }
  20 +
15 } 21 }
@@ -11,4 +11,9 @@ public class WxUFORealAppHttpSslClient extends HttpSslClientAbstract { @@ -11,4 +11,9 @@ public class WxUFORealAppHttpSslClient extends HttpSslClientAbstract {
11 return WeixinPayConfig.PARTNER_ID; 11 return WeixinPayConfig.PARTNER_ID;
12 } 12 }
13 13
  14 + @Override
  15 + protected String getMchCertPath() {
  16 + return WeixinPayConfig.WECHAT_PAY_UFOREAL_APP_PARTNER_CERT;
  17 + }
  18 +
14 } 19 }