Ruby&Rails---支付宝 OpenSSL - Neith
2019-03-08 本文已影响0人
HPD_黄霹雳
Rails 部署到服务器上,使用dotenv来管理环境变量。设置支付宝支付的相关秘钥信息时,可能会出现
OpenSSL - Neither PUB key nor PRIV key:: nested asn1 error
解决办法: 秘钥每隔64位都用 \n 分割
例子:
应用私钥
APP_PRIVATE_KEY = "-----BEGIN RSA PRIVATE KEY-----\nMIIEogIBAAKCAQEApjMVbk7j+kBNXCaudlq3SmXN3/1nHBaPmelgFLtbakqghuJ/\nGJ/mH/bFN3ZeVvDFtz3blcSHoDZmYGURQ4zeCjqbC8GAKMbJZbvjkZI8FHd/CgE2\nHbQLNtIpPQFNqfHWnhiqtTD9kBLSZUj7kcnmT2EZdlXbniCXQcUM8BI9DXOE8NiE\nRN8lRmW3VCGPNZk/USgv/iLsq4F8y7nCGlqZNntI6Nt/p9r2r3pCpnYZLH3XPl1b\npSYuZm1LhHDKedJrmPz3loZrGu4pGkstysQ6noDq1lrVo04R+kO47JflwlpK/3Es\nq7ZBN4PcrAtx8M83rIMjed862614i/syqFMZEwIDAQABAoIBABq2v00ZtR82Urjr\nJsOzVR7KOks0iexD3BUbI+xxKQJuuFq18UPd/7lHiu+dQRCsZrtLYA40prAjzlTU\nKfA3pkDyppU/JwBm41xM1QlC/hE0G+FZzH79v4eyRBqgKQGV8685u8af90G/JL5O\n+tC2KSS9MMCKkGBcULOrnqa/57xPgMMKHjh2ZS5/uv95ZeE2Tj+oxkrsLgybUTCd\nUcyBNhgMzZcV3NtK03b5VKs7oxsZjtQG3BiNVDx3Wt8u2oYOitpTb7+ZOzVvOjQz\nxRYKqAbLzIsYoLrvpwBtWJRoaKBsDz5dNlu8oQMksnoknQs7ho5QptGXZgZK7HuG\n3fbXEaECgYEA1vPa2zJfX6DgLNTR+NKNjcWPSi1rmQn3jCxvI1ermaLTvxA0pLwH\n3ujBFtdg18ryUVr3FpUOuB970kg8Ky/ylCFKymi3b3VeDCHhxPAqK1kRXMnafgwi\nFrGuFu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