ruby-on-rails – Ruby – 如何从ruby上的.pfx文件中提取public,rsa私钥和CA密钥

ruby-on-rails – Ruby – 如何从ruby上的.pfx文件中提取public,rsa私钥和CA密钥,第1张

概述我有.pfx格式的证书,我需要使用 ruby提取Public,Private和CA证书. 使用shell我可以这样做: # Extract Public Key (ask for password)openssl pkcs12 -in file.pfx -out file_public.pem -clcerts -nokeys# Extract Certificate Authority K 我有.pfx格式的证书,我需要使用 ruby提取Public,Private和CA证书.

使用shell我可以这样做:

# Extract Public Key (ask for password)openssl pkcs12 -in file.pfx -out file_public.pem -clcerts -nokeys# Extract Certificate Authority Key (ask for password)openssl pkcs12 -in file.pfx -out file_ca.pem -cacerts -nokeys# Extract Private Key (ask for password)openssl pkcs12 -in file.pfx -out file_private.pem -nocerts -nodes# Extract RSA Private Keyopenssl rsa -in file_private.pfx -out file_private_rsa.key# Create Combo file with Public and RSA Private Keyscat file_private_rsa.key file_public.pem > file_combo.pem

On this post DMKE显示了如何将键转换为.PFX,但是如何反过来呢?

解决方法
pkcs = OpenSSL::PKCS12.new(file.read("xyz.p12"),"password_for_xyz.p12")key = OpenSSL::PKey::RSA.new(pkcs.key.to_pem)cert = OpenSSL::X509::Certificate.new(pkcs.certificate.to_pem)
总结

以上是内存溢出为你收集整理的ruby-on-rails – Ruby – 如何从ruby上的.pfx文件中提取public,rsa私钥和CA密钥全部内容,希望文章能够帮你解决ruby-on-rails – Ruby – 如何从ruby上的.pfx文件中提取public,rsa私钥和CA密钥所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/langs/1284777.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-06-09
下一篇 2022-06-09

发表评论

登录后才能评论

评论列表(0条)

保存