使用openssl (https://www.openssl.org/docs/man1.1.0/man1/openssl-ts.html),我可以创建ts查询、回复、从回复中提取令牌并验证RFC3161格式的令牌(如果我有以下所指定的DER格式的签名证书):https://www.ietf.org/rfc/rfc3161.txt
为了得到一个记号,我可以:
openssl ts -query -digest 899ba3d9f777e2a74bdd34302bc06cb3f7a46ac1f565ee128f79fd5dab99d68b -sha256 \
| curl -s -H "Content-Type: application/timestamp-query" -H "Accept: application/timestamp-reply" --data-binary @- https://freetsa.org/tsr > response.tsr
openssl ts -reply -in response.tsr -token_out -out token.tk我还可以使用openssl ts -reply -in response.tsr -text以人类可读的形式打印响应。
要验证令牌,我需要提供参数
-CAfile trusted_certs.pem
The name of the file containing a set of trusted self-signed CA certificates in PEM format.
The file should contain one or more certificates in PEM format.问题1:
为什么这只需要信任锚(=自签名)证书,而不需要到TSA证书的整个链(或者-verify只使用令牌中包含证书链的令牌)?
问题2:
-cert
The TSA is expected to include its signing certificate in the response.如果我在第一个openssl调用中指定了-cert参数,那么token.tk将更长,并且还包含用于签名的证书。如何从token.tk提取该证书?
问题3:
我感到惊讶的是,当我请求响应包括证书时,token.tk会变得更长(我假设只有response.tsr才会变长,而不是令牌本身),因为规范指定了TimeStampToken,如下所示:
A TimeStampToken is as follows. It is defined as a ContentInfo
([CMS]) and SHALL encapsulate a signed data content type.
TimeStampToken ::= ContentInfo
-- contentType is id-signedData ([CMS])
-- content is SignedData ([CMS])
The fields of type EncapsulatedContentInfo of the SignedData
construct have the following meanings:
eContentType is an object identifier that uniquely specifies the
content type. For a time-stamp token it is defined as:
id-ct-TSTInfo OBJECT IDENTIFIER ::= { iso(1) member-body(2)
us(840) rsadsi(113549) pkcs(1) pkcs-9(9) smime(16) ct(1) 4}
eContent is the content itself, carried as an octet string.
The eContent SHALL be the DER-encoded value of TSTInfo.
TSTInfo ::= SEQUENCE {
version INTEGER { v1(1) },
policy TSAPolicyId,
messageImprint MessageImprint,
-- MUST have the same value as the similar field in
-- TimeStampReq
serialNumber INTEGER,
-- Time-Stamping users MUST be ready to accommodate integers
-- up to 160 bits.
genTime GeneralizedTime,
accuracy Accuracy OPTIONAL,
ordering BOOLEAN DEFAULT FALSE,
nonce INTEGER OPTIONAL,
-- MUST be present if the similar field was present
-- in TimeStampReq. In that case it MUST have the same value.
tsa [0] GeneralName OPTIONAL,
extensions [1] IMPLICIT Extensions OPTIONAL }那么,签名证书存储在哪里呢?是分机吗?或者它是ContentType标识符的一部分?
问题4:
如果我确实指定了-cert参数,那么如何从token.tk中提取一个文件token_stripped.tk,从而使token_stripped.tk与在没有-cert参数的情况下创建请求的情况相同?
问题5:
如何从PKIStatus (如链接规范中指定的那样)提取response.tsr (最优地,而不首先将其转换为人类可读的形式)?
发布于 2021-02-22 16:00:08
回答我自己的问题:
问题1:
为什么这只需要信任锚(=自签名)证书,而不需要到TSA证书的整个链(或者-verify只使用令牌中包含证书链的令牌)?
它确实需要它,但是如果令牌已经包含嵌入的整个信任链,那么它就不需要了。否则,必须使用-untrusted参数提供
问题2:
-cert预期TSA将在响应中包含其签名证书。
如果我在第一个openssl调用中指定了-cert参数,那么token.tk将更长,并且还包含用于签名的证书。如何从token.tk提取该证书?
以下调用提取嵌入的证书:
penssl pkcs7 -inform DER -in tokenfile.tst -print_certs -outform PEM -out certificatechain.pem问题3:
我感到惊讶的是,当我请求响应包括证书时,token.tk变得更长了(我假设只有response.tsr才会变长,而不是令牌本身)
TstInfo实际上保持相同的长度,但时间戳令牌不是TstInfo,而是包装CMS ContentInfo,证书(符合规范)作为符号属性嵌入到ContentInfo对象中。
问题4:
如果我确实指定了-cert参数,那么如何从token.tk中提取一个文件token_stripped.tk,从而使token_stripped.tk与在没有-cert参数的情况下创建请求的情况相同?
由于证书嵌入在有符号属性中,而不是无符号属性中,因此不可能从包含证书链的属性中生成有效的剥离令牌。
问题5:
如何从PKIStatus (如链接规范中指定的那样)提取response.tsr (最优地,而不首先将其转换为人类可读的形式)?
除了使用openssl cli解析人类可读的表单之外,我没有找到其他方法。
https://stackoverflow.com/questions/66044640
复制相似问题