wx
This commit is contained in:
@@ -6,6 +6,7 @@ import (
|
||||
"crypto/md5"
|
||||
"crypto/sha256"
|
||||
"crypto/tls"
|
||||
"crypto/x509"
|
||||
"encoding/xml"
|
||||
"fmt"
|
||||
"net/http"
|
||||
@@ -396,7 +397,7 @@ func New(appID, appKey, mchID string, config ...*platformapi.APIConfig) *API {
|
||||
}
|
||||
}
|
||||
|
||||
func NewWithCertificate(appID, appKey, mchID string, certPEMBlock, keyPEMBlock interface{}, config ...*platformapi.APIConfig) (a *API) {
|
||||
func NewWithCertificate(appID, appKey, mchID string, certPEMBlock, keyPEMBlock, rootCa interface{}, config ...*platformapi.APIConfig) (a *API) {
|
||||
var certs tls.Certificate
|
||||
var err error
|
||||
if binCertPEMBlock, ok := certPEMBlock.([]byte); ok {
|
||||
@@ -405,9 +406,12 @@ func NewWithCertificate(appID, appKey, mchID string, certPEMBlock, keyPEMBlock i
|
||||
certs, err = tls.LoadX509KeyPair(certPEMBlock.(string), keyPEMBlock.(string))
|
||||
}
|
||||
if err == nil {
|
||||
pool := x509.NewCertPool()
|
||||
pool.AppendCertsFromPEM(rootCa.([]byte))
|
||||
a = New(appID, appKey, mchID, config...)
|
||||
a.client.Transport = &http.Transport{
|
||||
TLSClientConfig: &tls.Config{
|
||||
RootCAs: pool,
|
||||
Certificates: []tls.Certificate{certs},
|
||||
},
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user