Quellcode durchsuchen

fix: x509: certificate signed by unknown authority

Jerry vor 7 Jahren
Ursprung
Commit
ba35cd30e2
2 geänderte Dateien mit 21 neuen und 7 gelöschten Zeilen
  1. 20 6
      wechat_client.go
  2. 1 1
      wechat_client_test.go

+ 20 - 6
wechat_client.go

@@ -35,7 +35,10 @@ func (this *weChatClient) Micropay(body BodyMap) (wxRsp *WeChatMicropayResponse,
 	var bytes []byte
 	if this.isProd {
 		//正式环境
-		bytes, err = this.doWeChat(body, wxURL_Micropay)
+		tlsConfig := new(tls.Config)
+		tlsConfig.InsecureSkipVerify = true
+
+		bytes, err = this.doWeChat(body, wxURL_Micropay, tlsConfig)
 		if err != nil {
 			return nil, err
 		}
@@ -60,7 +63,10 @@ func (this *weChatClient) UnifiedOrder(body BodyMap) (wxRsp *WeChatUnifiedOrderR
 	var bytes []byte
 	if this.isProd {
 		//正式环境
-		bytes, err = this.doWeChat(body, wxURL_UnifiedOrder)
+		tlsConfig := new(tls.Config)
+		tlsConfig.InsecureSkipVerify = true
+
+		bytes, err = this.doWeChat(body, wxURL_UnifiedOrder, tlsConfig)
 		if err != nil {
 			return nil, err
 		}
@@ -86,7 +92,9 @@ func (this *weChatClient) QueryOrder(body BodyMap) (wxRsp *WeChatQueryOrderRespo
 	var bytes []byte
 	if this.isProd {
 		//正式环境
-		bytes, err = this.doWeChat(body, wxURL_OrderQuery)
+		tlsConfig := new(tls.Config)
+		tlsConfig.InsecureSkipVerify = true
+		bytes, err = this.doWeChat(body, wxURL_OrderQuery, tlsConfig)
 		if err != nil {
 			return nil, err
 		}
@@ -111,7 +119,9 @@ func (this *weChatClient) CloseOrder(body BodyMap) (wxRsp *WeChatCloseOrderRespo
 	var bytes []byte
 	if this.isProd {
 		//正式环境
-		bytes, err = this.doWeChat(body, wxURL_CloseOrder)
+		tlsConfig := new(tls.Config)
+		tlsConfig.InsecureSkipVerify = true
+		bytes, err = this.doWeChat(body, wxURL_CloseOrder, tlsConfig)
 		if err != nil {
 			return nil, err
 		}
@@ -216,7 +226,9 @@ func (this *weChatClient) QueryRefund(body BodyMap) (wxRsp *WeChatQueryRefundRes
 	var bytes []byte
 	if this.isProd {
 		//正式环境
-		bytes, err = this.doWeChat(body, wxURL_RefundQuery)
+		tlsConfig := new(tls.Config)
+		tlsConfig.InsecureSkipVerify = true
+		bytes, err = this.doWeChat(body, wxURL_RefundQuery, tlsConfig)
 		if err != nil {
 			return nil, err
 		}
@@ -241,7 +253,9 @@ func (this *weChatClient) DownloadBill(body BodyMap) (wxRsp string, err error) {
 	var bytes []byte
 	if this.isProd {
 		//正式环境
-		bytes, err = this.doWeChat(body, wxURL_DownloadBill)
+		tlsConfig := new(tls.Config)
+		tlsConfig.InsecureSkipVerify = true
+		bytes, err = this.doWeChat(body, wxURL_DownloadBill, tlsConfig)
 	} else {
 		bytes, err = this.doWeChat(body, wxURL_SanBox_DownloadBill)
 	}

+ 1 - 1
wechat_client_test.go

@@ -28,7 +28,7 @@ func TestWeChatClient_UnifiedOrder(t *testing.T) {
 	log.Println("Number:", number)
 	body.Set("out_trade_no", number)
 	body.Set("total_fee", 1)
-	body.Set("spbill_create_ip", "180.171.101.212")
+	body.Set("spbill_create_ip", "124.77.173.62")
 	body.Set("notify_url", "http://www.igoogle.ink")
 	body.Set("trade_type", TradeType_JsApi)
 	//body.Set("device_info", "WEB")