首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Xades4j:策略'self: policy /general‘出错

Xades4j:策略'self: policy /general‘出错
EN

Stack Overflow用户
提问于 2020-01-23 19:02:02
回答 1查看 57关注 0票数 0

我正在试着用xades4j给西班牙政府签一张发票。它们为签名的xml提供了一个在线检查器,而整个检查只有一个步骤失败了:

Step: Checks if the signature policy is correct Result: Unknown policy self:policy/general

其他步骤,如完整性和证书状态都是可以的。

我的猜测是self:policy/general是xades4j库中的某种占位符,我应该以某种方式覆盖它?

现在,我将此代码用于策略

代码语言:javascript
复制
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输出似乎符合以下要求:

代码语言:javascript
复制
            <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>
EN

回答 1

Stack Overflow用户

发布于 2020-01-24 23:10:27

我的猜测是:策略/常规是xades4j库中的某种占位符,我应该以某种方式覆盖它吗?

根本没有这回事。这可能是验证应用程序的详细信息。

我注意到问题文本中的URL是HTTPS,而代码中的URL是HTTP。后者似乎重定向到HTTPs,但看起来URLConnection doesn't follow redirects when protocols are different

尝试在代码中使用最终的HTTPS URL。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/59877060

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档