Java 使用PKIStatus值验证RFC 3161时间戳响应
我有一个Java 使用PKIStatus值验证RFC 3161时间戳响应,java,cryptography,timestamp,digital-signature,bouncycastle,Java,Cryptography,Timestamp,Digital Signature,Bouncycastle,我有一个SOAP请求,需要重新设计,因为SoapUI无法正确处理二进制响应。 我决定让它基于Java。我发现函数是如何在代码片段上产生的,这非常有用,但不确定。我有 消化价值 签名价值 X509证书 在SOAPrequest中定义,但不确定如何转换这些信息以将请求发送到my tsendpint。 我也试过了,但不确定为什么我们需要登录凭据。我留下了空的那些领域,但它结束了所有的时间与 TSAClientBouncyCastle@1f0e140b 信息 我使用构造函数从Main调用TSACli
SOAP
请求,需要重新设计,因为SoapUI
无法正确处理二进制响应。
我决定让它基于Java。我发现函数是如何在代码片段上产生的,这非常有用,但不确定。我有
- 消化价值
- 签名价值
- X509证书
SOAP
request中定义,但不确定如何转换这些信息以将请求发送到my tsendpint。
我也试过了,但不确定为什么我们需要登录凭据。我留下了空的那些领域,但它结束了所有的时间与
TSAClientBouncyCastle@1f0e140b
信息
我使用构造函数从Main
调用TSAClientBouncyCastle
类
这是主要部分,它应该解码数据
// Get TSA response as a byte array
InputStream inp = tsaConnection.getInputStream();
ByteArrayOutputStream baos = new ByteArrayOutputStream();
byte[] buffer = new byte[1024];
int bytesRead = 0;
while ((bytesRead = inp.read(buffer, 0, buffer.length)) >= 0) {
baos.write(buffer, 0, bytesRead);
}
byte[] respBytes = baos.toByteArray();
String encoding = tsaConnection.getContentEncoding();
if (encoding != null && encoding.equalsIgnoreCase("base64")) {
respBytes = Base64.decode(new String(respBytes));
}
时间戳管理局(TSA)生成数据在特定时间之前存在的证明。它使用RFC3161中定义的协议和格式
时间戳响应如下(请参阅):
您可以使用解析内容类型application/timestamp reply
的响应,以获取PKIStatusInfo
TimeStampResponse response = new TimeStampResponse(tsaInputStream);
int status = response.getStatus();
可能的值是
PKIStatus ::= INTEGER {
granted (0),
-- when the PKIStatus contains the value zero a TimeStampToken, as
requested, is present.
grantedWithMods (1),
-- when the PKIStatus contains the value one a TimeStampToken,
with modifications, is present.
rejection (2),
waiting (3),
revocationWarning (4),
-- this message contains a warning that a revocation is
-- imminent
revocationNotification (5)
-- notification that a revocation has occurred }
我不明白你的问题的要素之间的关系。1) Soap请求不需要RFC3161时间戳。2) 您想验证时间戳(问题标题)3),但您正在使用TSA客户端请求新的时间戳4),错误来自何处?你在给什么数据加时间戳?展示你的code@pedrofb:对不起,是的,不太清楚。我有一个已定义的请求,SoapUI中的答案不是人类可读的。原始响应还包含问号和矩形,所以我想我无法使用SoapUI获得一些基于ascii的信息。我必须了解身份的价值。这就是我所说的验证。我需要一个TSA客户机,我可以从tsendpoint的响应中获得ASCII信息。时间戳管理局(TSA)生成一个证据,证明在特定时间之前存在一个数据。它使用RFC3161中定义的协议和格式。如果这是您的意图,则无法使用TSA验证另一条消息。如果您看到奇怪的字符,那是因为您的消息是二进制的,而不是文本。TSA可能返回内容类型为
application/timestamp reply
的错误。我仍然不理解您的用例。我没办法you@pedrofb:是的,我知道它是二进制的,这就是为什么我试图在SoapUI中转换它。我的用例是根据协议中的定义,从时间戳响应中检查此值:status pki statusinfo
。所以verification代表检查这个值。这就是我试图以某种方式获得ASCII响应的原因。您无法将timeramp回复转换为ASCII。在您链接的代码中,有一个使用bouncycastle解析它的示例<代码>时间戳响应=新的时间戳响应(respBytes);response.getStatus()这就是您要找的吗?谢谢!我在问题中链接的解决方案也使用此库,但我没有用户凭据,只有X509Data。
PKIStatus ::= INTEGER {
granted (0),
-- when the PKIStatus contains the value zero a TimeStampToken, as
requested, is present.
grantedWithMods (1),
-- when the PKIStatus contains the value one a TimeStampToken,
with modifications, is present.
rejection (2),
waiting (3),
revocationWarning (4),
-- this message contains a warning that a revocation is
-- imminent
revocationNotification (5)
-- notification that a revocation has occurred }