我试图在成功的Apple授权下解密PKPaymentToken对象的PKPaymentToken属性。
我正在尝试遵循这里指令,但我被困在解密步骤的第二步,其中说:
使用publicKeyHash密钥的值确定苹果使用哪个商家公钥,然后检索相应的商户公钥证书和私钥。
我该怎么做?
请给我建议。
谢谢!
发布于 2015-04-20 14:18:09
考虑到从下载的Apple证书文件,下面是如何在Ruby中计算publicKeyHash。
require "base64"
require "digest"
require "openssl"
# set cert_file = path to the downloaded Apple Pay .cer file
cert = OpenSSL::X509::Certificate.new(File.read(cert_file))
# strip off the "-----BEGIN PUBLIC KEY-----" line at the start of the string
pem = cert.public_key.to_pem.split("\n").drop(1)
# strip off the "-----END PUBLIC KEY-----" line at the end of the string
pem = pem.take(pem.length - 1)
decoded = Base64.decode64(pem.join)
public_key_hash = Digest::SHA256.base64digest(decoded)发布于 2014-12-20 18:36:31
publicKeyHash字段的值是.公钥的散列。根据文档,它是商人证书的X.509编码公钥字节的SHA-256散列。您可以使用此标识符来确定哪个商家标识符用于签名支付数据(您可能只有一个商家标识符,在这种情况下,您将知道使用的是哪个商家标识符)。
https://stackoverflow.com/questions/27473085
复制相似问题