@@ -18,6 +18,10 @@ import (
1818 "github.com/wechatpay-apiv3/wechatpay-go/core/auth/validators"
1919)
2020
21+ const rsaSignatureType = "WECHATPAY2-SHA256-RSA2048"
22+ const defaultSignatureType = rsaSignatureType
23+ const aeadAesGcmAlgorithm = "AEAD_AES_256_GCM"
24+
2125// Handler 通知处理器,使用前先设置验签和解密的算法套件
2226type Handler struct {
2327 cipherSuites map [string ]CipherSuite
@@ -49,9 +53,9 @@ func (h *Handler) AddCipherSuite(cipherSuite CipherSuite) *Handler {
4953// AddRSAWithAESGCM 添加一个 RSA + AES-GCM 的算法套件
5054func (h * Handler ) AddRSAWithAESGCM (verifier auth.Verifier , aesgcm cipher.AEAD ) * Handler {
5155 v := CipherSuite {
52- signatureType : "WECHATPAY2-RSA2048-SHA256" ,
56+ signatureType : rsaSignatureType ,
5357 validator : * validators .NewWechatPayNotifyValidator (verifier ),
54- aeadAlgorithm : "AEAD_AES_256_GCM" ,
58+ aeadAlgorithm : aeadAesGcmAlgorithm ,
5559 aead : aesgcm ,
5660 }
5761 return h .AddCipherSuite (v )
@@ -65,7 +69,7 @@ func (h *Handler) ParseNotifyRequest(
6569) (* Request , error ) {
6670 signType := request .Header .Get ("Wechatpay-Signature-Type" )
6771 if signType == "" {
68- signType = "WECHATPAY2-RSA2048-SHA256"
72+ signType = defaultSignatureType
6973 }
7074
7175 suite , ok := h .cipherSuites [signType ]
0 commit comments