Certificate to pem to certificate not working: nested asn1 error

前端 未结 1 379
旧巷少年郎
旧巷少年郎 2021-01-22 20:05

I want to create a certificate from a string. Why does this not work:

OpenSSL::X509::Certificate.new(OpenSSL::X509::Certificate.new.to_pem)

It retur

1条回答
  •  野趣味
    野趣味 (楼主)
    2021-01-22 21:01

    So I got the answer myself. The certificate needs at least these information:

    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
    

    Then this is possible:

    OpenSSL::X509::Certificate.new(cert.to_pem) => returns

    0 讨论(0)
提交回复
热议问题