我正在尝试使用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>
我的猜测是self:policy / general是xades4j库中的某种占位符,我应该以某种方式覆盖它?
没有这种东西。这可能是验证应用程序的细节。
我注意到问题文本中的URL是HTTPS,而代码中的URL是HTTP。似乎稍后会重定向到HTTP,但是似乎URLConnection
doesn't follow redirects when protocols are different。
尝试在代码中使用最终的HTTPS URL。