Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/http/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 使用XAdES4j,如何信任windows密钥库的锚?_Java_Encryption_Xades4j - Fatal编程技术网

Java 使用XAdES4j,如何信任windows密钥库的锚?

Java 使用XAdES4j,如何信任windows密钥库的锚?,java,encryption,xades4j,Java,Encryption,Xades4j,我正在开发(java)一个需要连接到windows密钥库的xml验证应用程序。 目前我被以下消息卡住了:CannotBuildCertificationPathExection:信任锚密钥库未初始化。 现在,我可以使用以下示例从商店获取密钥:http://stackoverflow.com/questions/5476974/java-access-to-intermediate-cas-from-windows-keystores 这很有效。给了我使用XAdES4J的希望 我使用的代码如下所示

我正在开发(java)一个需要连接到windows密钥库的xml验证应用程序。 目前我被以下消息卡住了:CannotBuildCertificationPathExection:信任锚密钥库未初始化。

现在,我可以使用以下示例从商店获取密钥:http://stackoverflow.com/questions/5476974/java-access-to-intermediate-cas-from-windows-keystores 这很有效。给了我使用XAdES4J的希望

我使用的代码如下所示:

trustAnchors = KeyStore.getInstance("Windows-MY");  
certValidator = new PKIXCertificateValidationProvider(trustAnchors, false); 
p = new XadesVerificationProfile(certValidator); 
v = p.newVerifier();

Element sigElem = (Element) signature.item(0); //Which contains the complete signature segment from the xml

XAdESVerificationResult r;  
SignatureSpecificVerificationOptions options = new SignatureSpecificVerificationOptions().useBaseUri("http://www.ietf.org/rfc/");

r = v.verify(sigElem, options);
该证书是x509。加密方法是XAdES-t

有人知道如何使用windows密钥库获得可信连接吗?
是否有关于SignatureSpecificationVerificationOptions的任何信息。我发现在我需要使用的实际设置的上下文中很难理解手册。

即使它是Wndows密钥库,您仍然需要加载它:

trustAnchors.load(null);
PKIXCertificateValidationProvider无法执行此操作,因为可能需要保护参数


此外,您可能希望使用“Windows ROOT”而不是“Windows MY”来访问受信任的证书颁发机构。

Hi Igon,您的回复帮助很大。