Reputation: 153
require 'openssl'
if ARGV.length == 2
pkcs12 = OpenSSL::PKCS12.new(File.read(ARGV[0]), ARGV[1])
p pkcs12.certificate
else
puts "Usage: load_cert.rb <path_to_cert> <cert_password>"
end
Running this produces error on windows but not in linux.
Error:
OpenSSL::PKCS12::PKCS12Error: PKCS12_parse: mac verify failure
from (irb):21:ininitialize
from (irb):21:innew
from (irb):21
from C:/Ruby192/bin/irb:12:in<main>
Upvotes: 7
Views: 6903
Reputation: 153
File.read("UserCert.p12", "rb")
Problem was ruby by default read file as text and need to force to read file as binary, it solves the problem
Upvotes: 8