我们通过Gem运行此命令。
openssl pkcs8 -inform DER -in file_init.key -passin pass:secret -out file_key.pem在shell上一切正常,我们想用ruby把这一行转换成openssl,我们试过了:
key_file = OpenSSL::PKey::RSA.new File.read('file_init'), 'secret'
puts key_file.to_pem_pkcs8但是我们得到了:
`initialize': Neither PUB key nor PRIV key: nested asn1 error (OpenSSL::PKey::RSAError)有什么建议吗?
发布于 2018-11-23 09:13:35
Ruby的openssl实现不能处理pkcs8加密的der密钥文件。这里有一个解决方法(通过对der进行base64编码+添加正确的标头,将der转换为PEM ):Load PKCS#8 binary key into Ruby
https://stackoverflow.com/questions/53438888
复制相似问题