"testuser.p12" is represented by the PKCS # 12 file according to the postfix message. Reading PKCS # 12 as an X.509 certificate format causes an ASN.1 decoding error.
Instead, you should do OpenSSL::PKCS12.new(File.read("testuser.p12")) . If the file is password protected (this is normal), enter the passphrase as the second parameter for PKCS12.new, as OpenSSL::PKCS12.new(File.read("testuser.p12"), "pass")
You can extract certificate certificates and CA certificates using the PKCS12#certificate and PKCS12#ca_certs .
p12 = OpenSSL::PKCS12.new(File.read("testuser.p12"), "pass") p p12.certificate p p12.ca_certs
source share