我想从字符串创建证书。为什么这不起作用:
OpenSSL::X509::Certificate.new(OpenSSL::X509::Certificate.new.to_pem)
返回:OpenSSL::X509::CertificateError: nested asn1 error
答案 0 :(得分:3)
所以我自己得到了答案。证书至少需要这些信息:
cert = OpenSSL::X509::Certificate.new
cert.version = 2
cert.serial = 0
cert.not_before = Time.now
cert.not_after = Time.now + 3600
cert.public_key = key.public_key
cert.sign key, OpenSSL::Digest::SHA1.new
然后这是可能的:
OpenSSL::X509::Certificate.new(cert.to_pem)
=>返回