使用自定义oids向PKCS#7签名添加经过身份验证/签名的属性?

Oli*_*ier 1 openssl cryptography pkcs#7

有没有办法使用openssl为PKCS#7签名消息传递额外的经过身份验证的属性?我坚持使用命令行.

我目前正在使用:

openssl smime -sign -outform DER -md sha1 -binary -signer my.crt -inkey my.key
Run Code Online (Sandbox Code Playgroud)

我没有在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
Run Code Online (Sandbox Code Playgroud)

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

Jcs*_*Jcs 5

遗憾的是,无法从OpenSSL命令行向已签名的消息添加自定义属性(既不使用smime也不使用cms命令).如果要添加一些自定义属性,则必须使用OpenSSL API.

主要步骤是:

  • 打电话CMS_sign来创建一个CMS_ContentInfo
  • 用.创建一个SignerInfo CMS_add1_signer
  • 将属性添加到此签名者 CMS_signed_add1_attr_by_OBJ
  • 签字 CMS_final()

更多细节:http://www.openssl.org/docs/crypto/CMS_sign.html