XADES4j - XML签名验证错误 - 未指定签名节点

时间:2015-02-06 21:08:40

标签: java xml verification xml-signature xades4j

我使用XAdES4j签署了一个XML文件,但在验证它时,我总是得到“未指定签名节点”。显然signatureParentnull!如何解决?

这是我的代码:

FileSystemDirectoryCertStore certStore = new FileSystemDirectoryCertStore(".");
KeyStore trustAnchors = createAndLoadJKSKeyStore(".\\myStore", "mystorepass");
CertificateValidationProvider certValidator = new PKIXCertificateValidationProvider(trustAnchors, false, certStore.getStore());

XadesVerificationProfile p = new XadesVerificationProfile(certValidator);
XadesVerifier v = p.newVerifier();

Document sourceDoc = Signapp.getDocument(".\\TEST.XML.FILE.xml");

Element signatureParent = (Element)sourceDoc.getElementsByTagNameNS(Constants.SignatureSpecNS, Constants._TAG_SIGNATURE).item(0);;
XAdESVerificationResult r = v.verify(signatureParent,null);

2 个答案:

答案 0 :(得分:0)

这是我的getDocument方法:

        File fXmlFile = new File(path);
        DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
        DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
        Document doc = dBuilder.parse(fXmlFile);
        doc.getDocumentElement().normalize();
        return doc;

答案 1 :(得分:0)