Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

支持公钥验签 #226

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

Conversation

xy-peng
Copy link
Contributor

@xy-peng xy-peng commented May 15, 2024

如何使用

var (
	wechatpayPublicKeyID       string = "00000000000000000000000000000000"          // 微信支付公钥ID
)

wechatpayPublicKey, err = utils.LoadPublicKeyWithPath("/path/to/wechatpay/pub_key.pem")
if err != nil {
	panic(fmt.Errorf("load wechatpay public key err:%s", err.Error()))
}
    
// 初始化 Client
opts := []core.ClientOption{
	option.WithWechatPayPublicKeyAuthCipher(
		mchID,
		mchCertificateSerialNumber, mchPrivateKey,
		wechatpayPublicKeyID, wechatpayPublicKey),
}
client, err := core.NewClient(ctx, opts...)

// 新商户,初始化 notify.Handler
handler := notify.NewNotifyHandler(
	mchAPIv3Key, 
	verifiers.NewSHA256WithRSAPubkeyVerifier(wechatpayPublicKeyID, *wechatPayPublicKey))

// 存量商户,初始化 notify.Handler
handler := notify.NewNotifyHandler(
	mchAPIv3Key,
	verifiers.NewSHA256WithRSACombinedVerifier(certificateVisitor, wechatpayPublicKeyID, *wechatPayPublicKey))

@xy-peng xy-peng requested review from wujunjiesd and a team May 15, 2024 03:24
Copy link

sonarcloud bot commented May 15, 2024

Quality Gate Passed Quality Gate passed

Issues
1 New issue
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud

@xy-peng xy-peng changed the title 支持公私钥验签 支持公钥验签 May 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant