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

Dan*_* S. 1 openssl signing certificate pki

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

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

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

# 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
Run Code Online (Sandbox Code Playgroud)

错误:

The organizationName field needed to be the same in the
CA certificate (My Own CA Company) and the request (My Customer)
Run Code Online (Sandbox Code Playgroud)

我不明白为什么 openssl 抱怨这些完全不同。我认为他们应该有所不同。

Han*_* Z. 6

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

[ policy_match ] 
organizationName    = supplied 
Run Code Online (Sandbox Code Playgroud)