【问题标题】:How do I create a .p12 file in Ruby?如何在 Ruby 中创建 .p12 文件?
【发布时间】:2009-04-30 16:48:51
【问题描述】:

我查看了Ruby OpenSSL documentation,但我不太清楚我需要将哪些部分放在一起来制作一个 .p12 文件。

还有this tutorial,但 cmets 对其正确性存在矛盾心理。

【问题讨论】:

    标签: ruby encryption cryptography openssl


    【解决方案1】:

    来自 ossl_pkcs12.c:

    /*
    * call-seq:
    *    PKCS12.create(pass, name, key, cert [, ca, [, key_pbe [, cert_pbe [, key_iter [, mac_iter [, keytype]]]]]])
    *
    * === Parameters
    * * +pass+ - string
    * * +name+ - A string describing the key.
    * * +key+ - Any PKey.
    * * +cert+ - A X509::Certificate.
    * * * The public_key portion of the certificate must contain a valid public key.
    * * * The not_before and not_after fields must be filled in.
    * * +ca+ - An optional array of X509::Certificate's.
    * * +key_pbe+ - string
    * * +cert_pbe+ - string
    * * +key_iter+ - integer
    * * +mac_iter+ - integer
    * * +keytype+ - An integer representing an MSIE specific extension.
    *
    * Any optional arguments may be supplied as nil to preserve the OpenSSL defaults.
    *
    * See the OpenSSL documentation for PKCS12_create().
    

    */

    所以(未经测试并且可能不正确 - 我对 Ruby 不是很熟悉):

    p12 = OpenSSL::PKCS12.create("password", "key", pkey, cert)
    p12_bytes = p12.to_der
    

    【讨论】:

      猜你喜欢
      • 2011-01-03
      • 2014-02-04
      • 1970-01-01
      • 2011-12-16
      • 1970-01-01
      • 2016-09-30
      • 2012-01-10
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多