【问题标题】:Add authenticated/signed attributes with custom oids to PKCS#7 signing?将带有自定义 oid 的已验证/签名属性添加到 PKCS#7 签名?
【发布时间】:2012-10-29 18:09:42
【问题描述】:

有没有办法使用 openssl 为 PKCS#7 签名消息传递额外的认证属性?我被命令行困住了。

我目前正在使用:

openssl smime -sign -outform DER -md sha1 -binary -signer my.crt -inkey my.key

我在 openssl cli 帮助中没有找到任何相关选项。


更多信息:

我目前正在尝试在 NodeJS 中构建 SCEP (http://tools.ietf.org/pdf/draft-nourse-scep-23.pdf) 服务器。

SCEP 规范要求构建 PKCS#7 签名 pkiMessages

The SignerInfo MUST contain a set of authenticatedAttributes (see PKCS#7 [RFC2315] Section 9.2 as well as Section 3.1.1 in this document). All messages MUST contain
* an SCEP transactionID attribute
* an SCEP messageType attribute
* an SCEP senderNonce attribute
* any attributes required by PKCS#7 [RFC2315] Section 9.2 If the message is a response, it MUST also include

目前我唯一的选择是通过child_process.spawn 包装openssl 功能。

【问题讨论】:

    标签: cryptography openssl pkcs#7


    【解决方案1】:

    不幸的是,无法从 OpenSSL 命令行(无论是使用 smime 还是使用 cms 命令)向签名消息添加自定义属性。如果要添加一些自定义属性,则必须使用 OpenSSL API。

    主要步骤是:

    • 调用CMS_sign创建CMS_ContentInfo
    • 使用CMS_add1_signer 创建一个SignerInfo
    • 使用CMS_signed_add1_attr_by_OBJ向此签名者添加属性
    • CMS_final()签名

    更多详情:http://www.openssl.org/docs/crypto/CMS_sign.html

    【讨论】:

    • 感谢您的回答,我想是时候深入研究自定义 NodeJS C++ 扩展了。希望我能活下来;-)。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-05-06
    • 1970-01-01
    • 2018-05-03
    相关资源
    最近更新 更多