我试图在成功获得Apple Pay授权后解密对象的paymentData
属性PKPaymentToken
。
我试图按照此处的说明进行操作,但仍停留在解密步骤的第2步中,该步骤显示:
使用publicKeyHash密钥的值确定Apple使用了哪个商人公共密钥,然后检索相应的商人公共密钥证书和私钥。
我怎么做?
请指教。
谢谢!
给定从Apple开发人员中心下载的Apple Pay证书文件,以下是在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)
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句