【问题标题】:How to encode challenge password into certificate request如何将质询密码编码到证书请求中
【发布时间】:2015-05-20 03:18:50
【问题描述】:

我正在使用linux版本的openssl req生成一个带有挑战密码的csr,一切正常,除了它不能打印这个属性:

# openssl req -new -key private.key -out server.csr 
# openssl req -in server.csr -noout -text
  Certificate Request: ...
         Attributes:
             challengePassword        :unable to print attribute ...

我在fedora中使用OpenSSL 1.0.1j和ubuntu中使用OpenSSL 1.0.1进行测试,都无法将challengePassword写入csr文件。

但是如果我使用windows版本,它可以工作:

# openssl req -in test.csr -noout -text
  Certificate Request:
  ...
        Attributes:
            challengePassword        :00F7FC7937B5366F2231AC891472998C

... 我正在使用来自SCEP tool 的 64 位 openssl:

然后我搜索了openssl文档,找到了这句话:

属性

这指定了包含任何请求属性的部分:它的 格式与 distinct_name 相同。通常这些可能包含 这 challengePassword 或非结构化名称类型。 它们目前被 OpenSSL 的请求签名实用程序忽略,但某些 CA 可能需要 他们

是的,一些 CA 可能需要它们。我正在使用 NDES windows 2008 r2,它需要挑战密码,看起来它不能由 openssl req 应用程序生成,我可以使用 openssl C API 或 python/perl 吗?还是我需要修复 openssl 代码?

我还在 sscep 问题列表上问过这个问题,他们告诉我需要将挑战密码编码为 BMPString。但我不知道如何编码。有人可以给我指导吗?

【问题讨论】:

  • 我的话题有点误导。应该是“如何将质询密码编码到证书请求中”。

标签: python c linux openssl


【解决方案1】:

让我自己回答我的问题。

要在 CSR 中启用挑战密码属性,我们需要编写 ASN 可打印字符串,但 openssl req 实用程序默认写入 MBSTRING_ASC 字符串,因此它总是返回“:unable to print attribute ...”

这是 C 代码示例:

将 MBSTRING_ASC 字符串转换为 ASN1_PRINTABLESTRING:

ASN1_STRING *tmp_os = M_ASN1_PRINTABLESTRING_new();
tmp_os->type = V_ASN1_PRINTABLESTRING;
int password_length = strlen(challenge_password);
ASN1_STRING_set(tmp_os, (const unsigned char *)challenge_password, password_length);

为请求添加属性:

X509_REQ_add1_attr_by_NID(req, NID_pkcs9_challengePassword, tmp_os->type, tmp_os->data, password_length);

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-08-24
    • 1970-01-01
    • 2017-05-17
    • 1970-01-01
    • 1970-01-01
    • 2019-08-05
    • 1970-01-01
    相关资源
    最近更新 更多