【问题标题】:Verify RFC 3161 timestamp response with PKIStatus value使用 PKIStatus 值验证 RFC 3161 时间戳响应
【发布时间】:2018-01-01 12:54:50
【问题描述】:

我有一个SOAP 请求,需要重新设计,因为SoapUI 无法正确处理二进制响应。 我决定让它基于Java。我发现this 非常有用,但不确定函数是如何出现在代码 sn-ps 上的。我有

  • 摘要值
  • 签名值
  • X509证书

SOAP 请求中定义,但不确定如何转换这些信息以将请求发送到我的 tsendpint。 我也试过TSAClientBouncyCastle,但不确定我们为什么需要登录凭据。我将这些字段留空,但它一直以

结束

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));
    }

【问题讨论】:

  • 我不明白你的问题的元素之间的关系。 1) Soap 请求不需要 RFC3161 时间戳。 2)您想要验证时间戳(问题标题) 3)但是您正在使用 TSAClient 请求新的时间戳 4)错误来自哪里?你在时间戳什么数据?显示您的代码
  • @pedrofb :对不起,是的,不是很清楚。我有一个已定义的请求,SoapUI 中的答案不是人类可读的。原始响应还包含问号和矩形,所以我认为我无法使用 SoapUI 获得一些基于 ascii 的信息。我必须获得 PKIStatus 的价值。这就是我所说的验证。我需要一个 TSAClient,我可以从 tsendpoint 的响应中获取 ASCII 信息。
  • 时间戳权威 (TSA) 生成数据在特定时间之前存在的证明。它使用 RFC3161 中定义的协议和格式。如果这是您的意图,则无法使用 TSA 验证另一条消息。如果您看到奇怪的字符,那是因为您的消息是二进制的,而不是文本。可能 TSA 正在返回内容类型为 application/timestamp-reply 的错误。我还是不明白你的用例。我帮不了你
  • @pedrofb :是的,我知道它是二进制的,这就是我尝试在 SoapUI 中转换它的原因。我的用例是从时间戳响应中检查此值:status PKIStatusInfo,如协议中所定义。所以验证代表检查这个值。这就是为什么我尝试以某种方式以 ASCII 形式获得响应。
  • 您不能将 timeramp-reply 转换为 ASCII。在您链接的代码中,您有一个使用 bouncycastle 解析它的示例。 TimeStampResponse response = new TimeStampResponse(respBytes); response.getStatus()这是你要找的吗?

标签: java cryptography timestamp digital-signature bouncycastle


【解决方案1】:

时间戳权威 (TSA) 会生成数据在特定时间之前存在的证明。它使用 RFC3161 中定义的协议和格式。

时间戳响应如下(参见RFC3161-section 2.4.2):

TimeStampResp ::= SEQUENCE  {
  status                  PKIStatusInfo,
  timeStampToken          TimeStampToken     OPTIONAL  }

可以用BouncyCastle解析content-typeapplication/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  }

【讨论】:

  • 谢谢!我在问题中链接的解决方案也使用了这个库,但我没有用户凭据,只有 X509Data。
猜你喜欢
  • 2013-10-31
  • 2014-02-18
  • 2019-01-09
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-12-01
  • 2016-05-29
  • 2022-11-24
相关资源
最近更新 更多