【问题标题】:OpenSSL Keystore Generation for Trinidad特立尼达的 OpenSSL 密钥库生成
【发布时间】:2012-07-03 20:33:21
【问题描述】:

我正在尝试使用 openSSL 为我的应用程序设置 https 连接。我正在运行一个 Neo4j 1.2.2 数据库,一个 Trinidad 1.3.5 Web 服务器,使用 Rails 3.1 和 ruby​​ 1.9。

我有一个 Thawte 试用证书 ca_cert.crt,它们的中间证书和根证书分别为 ca_intermediate.crt 和 ca_root.crt,以及我自己的私钥 ca_private.pem。我需要运行什么 openssl 命令来创建可以在我的应用程序的 trinidad.yaml 配置文件中指定的密钥库?

到目前为止,我尝试过的“看起来最接近右侧”的方法是:

pkcs12 –export –in ca_cert.crt inkey ca_private.pem –out keystore.p12 –name tomcat

它给了我错误:

unable to load certificates
6380:error:0D0680A8:asn1 encoding routines:ASN1_CHECK_TLEN:wrong tag:.\crypto\as
n1\tasn_dec.c:1319:
6380:error:0D07803A:asn1 encoding routines:ASN1_ITEM_EX_D2I:nested asn1 error:.\
crypto\asn1\tasn_dec.c:381:Type=X509_CINF
6380:error:0D08303A:asn1 encoding routines:ASN1_TEMPLATE_NOEXP_D2I:nested asn1 e
rror:.\crypto\asn1\tasn_dec.c:751:Field=cert_info, Type=X509
6380:error:0907400D:PEM routines:PEM_X509_INFO_read_bio:ASN1 lib:.\crypto\pem\pe
m_info.c:258:
error in pkcs12

在我看来,openssl 不喜欢我保存文件的格式,尽管我尝试了几乎所有我能想到的 .pem、.crt、.cer 和 .key 扩展名的组合都无济于事.我完全是 SSL 新手,所以我希望我只是在做一些愚蠢的事情,而且很容易解决......

这是我一直试图遵循的示例:https://github.com/trinidad/trinidad/wiki/ssl-end-to-end-example

【问题讨论】:

    标签: ruby-on-rails-3.1 https openssl keystore trinidad


    【解决方案1】:

    this answer 看来,Thawte 证书格式为 PKCS#7,而openssl pkcs12 -export 命令expects PEM。 PKCS#7 中的证书可以使用先前链接答案的命令修改版本进行转换。

    $ openssl pkcs7 -in ca_cert.crt -print_certs | openssl x509 -outform PEM > ca_cert.pem
    

    然后执行您提供的命令,创建 PKCS#12 密钥库。

    $ openssl pkcs12 –export –in ca_cert.pem -inkey ca_private.pem –out keystore.p12 –name tomcat
    

    【讨论】:

    • 非常感谢!这正是问题所在。我必须将我的 ca_cert.pem 文件保存为 ca_cert.p7b,然后使用“openssl pkcs7 -print_certs -in ca_cert.p7b -out ca_cert.pem”进行转换。转换后,我尝试的命令效果非常好!
    猜你喜欢
    • 1970-01-01
    • 2011-02-10
    • 2019-08-09
    • 2021-01-20
    • 2012-11-15
    • 2020-07-23
    • 2013-12-02
    • 2014-05-10
    • 2012-12-07
    相关资源
    最近更新 更多