【问题标题】:Digest value mismatch摘要值不匹配
【发布时间】:2015-12-14 22:18:23
【问题描述】:

我正在使用 xades4j 为 XML 文件创建一个 XAdES-T 封装签名。当我验证签名的 XML 时,我收到一条错误消息,提示“计算的摘要值与 ds:Reference 中的摘要值不匹配”,其中引用指向 Type="http://uri.etsi.org/ 的元素01903#SignedProperties”。根 XML 元素本身的摘要值是可以的。

有人遇到过这样的问题吗?

我唯一能检测到的是签名时间不是 Zulu 格式,而是看起来像这样:2015-12-14T22:12:12.302+01:00。有没有办法改变它在签名中的格式?

<ds:Reference Type="http://uri.etsi.org/01903#SignedProperties" URI="#xmldsig-795a7c1b-9b15-4d5f-b363-4cb106ca238b-signedprops">
<ds:DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256"/>
<ds:DigestValue>iJu8ShMAGXPF1tmQveXzHkrmpFgfUR1ByH6en+2eIhU=</ds:DigestValue>
...
<xades:SignedProperties Id="xmldsig-795a7c1b-9b15-4d5f-b363-4cb106ca238b-signedprops"><xades:SignedSignatureProperties><xades:SigningTime>2015-12-14T22:12:12.302+01:00</xades:SigningTime>
...

【问题讨论】:

    标签: timezone digest xades4j


    【解决方案1】:

    问题已解决:

    • 您可以通过以下方式更改签名时间的时区:

          XadesSigner signer = new XadesTSigningProfile(keyingDataProvider)
                                  .withSignaturePropertiesProvider(new SignaturePropertiesProvider()
          {
              public void provideProperties(SignaturePropertiesCollector signedPropsCol)
              {
                  signedPropsCol.setSigningTime(new SigningTimeProperty(new GregorianCalendar(TimeZone.getTimeZone("Zulu"))));
              }
          })...
      
    • 摘要不匹配是由于在读取 XML 文件时未设置命名空间感知造成的:

      DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
      dbFactory.setNamespaceAware(true);
      

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-04-20
      • 1970-01-01
      • 1970-01-01
      • 2022-11-23
      • 1970-01-01
      • 2011-10-12
      • 1970-01-01
      • 2011-02-05
      相关资源
      最近更新 更多