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

配置多租户时如果有相同的微信证书会复用,导致配置的tenantId无法找到对应的证书,报错failed to obtain wechat pay x509Certificate #77

Closed
hellozhongying opened this issue Sep 22, 2022 · 0 comments
Assignees
Labels
bug Something isn't working

Comments

@hellozhongying
Copy link
Contributor

一个微信证书对应多个appid时,CERTIFICATE_MAP有缓存
`/**
* Get certificate x 509 wechat certificate info.
*
* @param tenantId the tenant id
* @return the x 509 wechat certificate info
*/
public X509WechatCertificateInfo getCertificate(String tenantId) {
for (String serial : CERTIFICATE_MAP.keySet()) {
X509WechatCertificateInfo wechatCertificateInfo = CERTIFICATE_MAP.get(serial);
X509Certificate x509Cert = wechatCertificateInfo.getX509Certificate();
if (wechatCertificateInfo.getTenantId().equals(tenantId)){
try {
x509Cert.checkValidity();

                return wechatCertificateInfo;
            } catch (Exception e) {
                log.warn("the wechat certificate is invalid , {}", e.getMessage());
                // Async?
                wechatMetaContainer.getTenantIds().forEach(this::refreshCertificate);
            }
        }
    }
    throw new PayException("failed to obtain wechat pay x509Certificate ");
}`
NotFound403 added a commit that referenced this issue Sep 22, 2022
@NotFound403 NotFound403 self-assigned this Oct 5, 2022
@NotFound403 NotFound403 added the bug Something isn't working label Oct 5, 2022
@NotFound403 NotFound403 mentioned this issue Jan 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants