Giter Club home page Giter Club logo

使用了定时更新平台证书功能,并且使用Verifier在调用接口时获取平台证书。但是怎么获取平台证书序列号以满足接口对header里的Wechatpay-Serial的需求呢 about wechatpay-apache-httpclient HOT 9 CLOSED

Daxiangshen avatar Daxiangshen commented on June 20, 2024
使用了定时更新平台证书功能,并且使用Verifier在调用接口时获取平台证书。但是怎么获取平台证书序列号以满足接口对header里的Wechatpay-Serial的需求呢

from wechatpay-apache-httpclient.

Comments (9)

xy-peng avatar xy-peng commented on June 20, 2024
// 建议从Verifier中获得微信支付平台证书,或使用预先下载到本地的平台证书文件中
X509Certificate certificate = verifier.getValidCertificate();
try {
  String ciphertext = RsaCryptoUtil.encryptOAEP(text, certificate);
} catch (IllegalBlockSizeException e) {
  e.printStackTrace();
}

这样拿到证书,然后从 X509Certificate 获取。

from wechatpay-apache-httpclient.

Daxiangshen avatar Daxiangshen commented on June 20, 2024

可是为什么我用certificate.getSerialNumber()获取到的序列号和正确的序列号不一样

from wechatpay-apache-httpclient.

Daxiangshen avatar Daxiangshen commented on June 20, 2024

也就是说我将certificate.getSerialNumber()获取到的序列号传入header之后。微信API提示我序列号错误。我用工具获取到的序列号和这个序列号不一样,但是可以通过微信的API接口

from wechatpay-apache-httpclient.

Daxiangshen avatar Daxiangshen commented on June 20, 2024
// 建议从Verifier中获得微信支付平台证书,或使用预先下载到本地的平台证书文件中
X509Certificate certificate = verifier.getValidCertificate();
try {
  String ciphertext = RsaCryptoUtil.encryptOAEP(text, certificate);
} catch (IllegalBlockSizeException e) {
  e.printStackTrace();
}

这样拿到证书,然后从 X509Certificate 获取。

可是为什么我用certificate.getSerialNumber()获取到的序列号和正确的序列号不一样
也就是说我将certificate.getSerialNumber()获取到的序列号传入header之后。微信API提示我序列号错误。我用工具获取到的序列号和这个序列号不一样,但是可以通过微信的API接口

from wechatpay-apache-httpclient.

xy-peng avatar xy-peng commented on June 20, 2024

certificate.getSerialNumber().toString(HEX).toUpperCase(),是这样获取的吗?

from wechatpay-apache-httpclient.

Daxiangshen avatar Daxiangshen commented on June 20, 2024

certificate.getSerialNumber().toString(HEX).toUpperCase(),是这样获取的吗?

HEX类是哪个包下面呢?

from wechatpay-apache-httpclient.

Daxiangshen avatar Daxiangshen commented on June 20, 2024

certificate.getSerialNumber().toString(HEX).toUpperCase(),是这样获取的吗?

我是直接获取的certificate.getSerialNumber() 后面没有.toString(HEX).toUpperCase() 这个HEX指的是?

from wechatpay-apache-httpclient.

xy-peng avatar xy-peng commented on June 20, 2024

就是16,表示16进制。证书序列号是16进制的字符串,getSerialNumber()得到的是 BigInteger 呀,需要转换一下。

from wechatpay-apache-httpclient.

Daxiangshen avatar Daxiangshen commented on June 20, 2024

已解决。多谢

from wechatpay-apache-httpclient.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.