如何使用openssl签署证书请求?

时间:2015-05-17 19:42:54

标签: openssl certificate signing pki

为了进行测试,我正在尝试执行以下3个步骤:

  • 为“我自己的CA公司”生成CA证书
  • 为另一个实体“我的客户”生成证书申请
  • 使用CA证书签署请求

我在最后一步失败了(见下文)。我认为我的问题是我对我正在做的步骤有错误的理解,但我无法弄清楚它是什么。

<a class="project" href="<%= url_for({:controller => :project, :action => :show, :id => project.id}) %>">

错误:

# generate self signed CA certificate
openssl req -x509 -days 2557 -newkey rsa:1024 -out ca-cert.pem -keyout ca-sec-key.pem

# for another entity, generate another private key and a signing request
openssl req -newkey rsa:1024 -out sub-request.pem -keyout sub-sec-key.pem

# the following fails:
# sign the request using the CA certificate and key
openssl ca -cert ca-cert.pem -keyfile ca-sec-key.pem -in sub-request.pem -out sub-cert.pem

我不明白为什么openssl抱怨这些根本不同。我认为它们应该是不同的。

1 个答案:

答案 0 :(得分:4)

很可能您的OpenSSL配置基于默认配置文件(openssl.cnf),该文件限制organizationName DN组件的值。在CA部分中,找到policy=<section_name>条目并将organizationName=match更改为organizationName=supplied,如下所示:

[ policy_match ] 
organizationName    = supplied