我正在试着用xades4j给西班牙政府签一张发票。它们为签名的xml提供了一个在线检查器,而整个检查只有一个步骤失败了:
Step: Checks if the signature policy is correct Result: Unknown policy self:policy/general
其他步骤,如完整性和证书状态都是可以的。
我的猜测是self:policy/general是xades4j库中的某种占位符,我应该以某种方式覆盖它?
现在,我将此代码用于策略
SignaturePolicyInfoProvider policyInfoProvider = new SignaturePolicyInfoProvider()
{
String FACTURAE_URL = "http://www.facturae.es/politica_de_firma_formato_facturae/politica_de_firma_formato_facturae_v3_1.pdf";
public SignaturePolicyBase getSignaturePolicy()
{
InputStream is = null;
try {
URL url = new URL(FACTURAE_URL);
URLConnection conn = url.openConnection();
is = conn.getInputStream();
} catch (IOException e) {
e.printStackTrace();
}
SignaturePolicyBase base = new SignaturePolicyIdentifierProperty(new ObjectIdentifier(FACTURAE_URL),is);
return base;
}
};要求在此在线文档(西班牙语) https://www.facturae.gob.es/politica_de_firma_formato_facturae/politica_de_firma_formato_facturae_v3_1.pdf中
我的xml输出似乎符合以下要求:
<xades:SignaturePolicyIdentifier>
<xades:SignaturePolicyId>
<xades:SigPolicyId>
<xades:Identifier>http://www.facturae.es/politica_de_firma_formato_facturae/politica_de_firma_formato_facturae_v3_1.pdf</xades:Identifier>
</xades:SigPolicyId>
<xades:SigPolicyHash>
<ds:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/>
<ds:DigestValue>2jmj7l5rSw0yVb/vlWAYkK/YBwk=</ds:DigestValue>
</xades:SigPolicyHash>
</xades:SignaturePolicyId>
</xades:SignaturePolicyIdentifier>发布于 2020-01-24 23:10:27
我的猜测是:策略/常规是xades4j库中的某种占位符,我应该以某种方式覆盖它吗?
根本没有这回事。这可能是验证应用程序的详细信息。
我注意到问题文本中的URL是HTTPS,而代码中的URL是HTTP。后者似乎重定向到HTTPs,但看起来URLConnection doesn't follow redirects when protocols are different。
尝试在代码中使用最终的HTTPS URL。
https://stackoverflow.com/questions/59877060
复制相似问题