我有一个.pfx格式的证书,我需要使用ruby提取公共证书,私有证书和CA证书。
使用外壳,我可以这样:
# 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 Key
openssl rsa -in file_private.pfx -out file_private_rsa.key
# Create Combo file with Public and RSA Private Keys
cat file_private_rsa.key file_public.pem > file_combo.pem
Run Code Online (Sandbox Code Playgroud)
在这篇文章中, DMKE显示了如何将密钥转换为.PFX,但是如何反过来呢?