shezhi
This commit is contained in:
@@ -6,7 +6,6 @@ import (
|
||||
"crypto/md5"
|
||||
"crypto/sha256"
|
||||
"crypto/tls"
|
||||
"crypto/x509"
|
||||
"encoding/xml"
|
||||
"fmt"
|
||||
"net/http"
|
||||
@@ -397,7 +396,7 @@ func New(appID, appKey, mchID string, config ...*platformapi.APIConfig) *API {
|
||||
}
|
||||
}
|
||||
|
||||
func NewWithCertificate(appID, appKey, mchID string, certPEMBlock, keyPEMBlock, rootCa interface{}, config ...*platformapi.APIConfig) (a *API) {
|
||||
func NewWithCertificate(appID, appKey, mchID string, certPEMBlock, keyPEMBlock interface{}, config ...*platformapi.APIConfig) (a *API) {
|
||||
var certs tls.Certificate
|
||||
var err error
|
||||
if binCertPEMBlock, ok := certPEMBlock.([]byte); ok {
|
||||
@@ -406,12 +405,12 @@ func NewWithCertificate(appID, appKey, mchID string, certPEMBlock, keyPEMBlock,
|
||||
certs, err = tls.LoadX509KeyPair(certPEMBlock.(string), keyPEMBlock.(string))
|
||||
}
|
||||
if err == nil {
|
||||
pool := x509.NewCertPool()
|
||||
pool.AppendCertsFromPEM(rootCa.([]byte))
|
||||
// pool := x509.NewCertPool()
|
||||
// pool.AppendCertsFromPEM(rootCa.([]byte))
|
||||
a = New(appID, appKey, mchID, config...)
|
||||
a.client.Transport = &http.Transport{
|
||||
TLSClientConfig: &tls.Config{
|
||||
RootCAs: pool,
|
||||
// RootCAs: pool,
|
||||
Certificates: []tls.Certificate{certs},
|
||||
},
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ func init() {
|
||||
baseapi.Init(sugarLogger)
|
||||
certPEMBlock, _ := ioutil.ReadFile("1390686702_20190115_cert/apiclient_cert.pem")
|
||||
keyPEMBlock, _ := ioutil.ReadFile("1390686702_20190115_cert/apiclient_key.pem")
|
||||
api = NewWithCertificate("wx70d0943e61e0d15c", "XKJPOIHJ233adf01KJIXlIeQDSDKFJAD", "1603491062", certPEMBlock, keyPEMBlock, nil)
|
||||
api = NewWithCertificate("wx70d0943e61e0d15c", "XKJPOIHJ233adf01KJIXlIeQDSDKFJAD", "1603491062", certPEMBlock, keyPEMBlock)
|
||||
// api = New("wx4b5930c13f8b1170", "XKJPOIHJ233adf01KJIXlIeQDSDKFJAD", "1390686702")
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user