2012-08-31 60 views
0

簽名SignC我想有大約SignerCTest一些信息,因爲實際上我有一些問題:關於在XADES4J

在我的主類:

public class XadesTest{ 

    public static void main(String[] args) throws Exception { 

      SignerCTest signerCTest = new SignerCTest(); 
      System.out.println("signerCTest : " + signerCTest.toString()); 
      signerCTest.testSignC();  
    } 

在我SignerCTest.class:

 public class SignerCTest extends SignerTestBase 
{ 
    //@Test 
    public void testSignC() throws Exception 
    { 
     System.out.println("signC"); 

     Document doc = getTestDocument(); 
     Element elemToSign = doc.getDocumentElement(); 

     ValidationDataProvider vdp = new ValidationDataFromCertValidationProvider(VerifierTestBase.validationProviderNist); 
     SignerC signer = (SignerC)new XadesCSigningProfile(keyingProviderNist, vdp).newSigner(); 
     new Enveloped(signer).sign(elemToSign); 

     outputDocument(doc, "document.signed.c.xml"); 


    } 
} 

,我有這些錯誤:

signerCTest : [email protected] 
signC 
Exception in thread "main" xades4j.providers.ValidationDataException: Cannot validate certificate: unable to find valid certification path to requested target 
    at xades4j.providers.impl.ValidationDataFromCertValidationProvider.getValidationData(ValidationDataFromCertValidationProvider.java:54) 
    at xades4j.production.SignerC.getFormatSpecificSignatureProperties(SignerC.java:70) 
    at xades4j.production.SignerBES.sign(SignerBES.java:200) 
    at xades4j.production.Enveloped.sign(Enveloped.java:69) 
    at xadestest.SignerCTest.testSignC(SignerCTest.java:45) 
    at xadestest.XadesTest.main(XadesTest.java:84) 
Caused by: xades4j.providers.CannotBuildCertificationPathException: unable to find valid certification path to requested target 
    at xades4j.providers.impl.PKIXCertificateValidationProvider.validate(PKIXCertificateValidationProvider.java:142) 
    at xades4j.providers.impl.ValidationDataFromCertValidationProvider.getValidationData(ValidationDataFromCertValidationProvider.java:51) 
    ... 5 more 
Java Result: 1 
BUILD SUCCESSFUL (total time: 17 seconds) 

但cetificate非常這裏:

D:\NetBeansProjects_MYSIGN\XadesTest\src\test\cert\my\LG.pfx 

D:\NetBeansProjects_MYSIGN\XadesTest\src\test\cert\csrc.nist\test4.p12 

所以......我不明白。有誰能夠幫助我 ?

謝謝, 威廉。

回答

2

您使用的測試僅依賴於來自NIST的證書。

測試使用的CertificateValidationProviderVerifierTestBase.validationProviderNist)已啓用證書撤銷檢查。另請注意,它是使用反映csrc.nist文件夾內容的CertStore創建的。這意味着csrc.nist文件夾必須包含CRL和其他中間證書,以便提供者可以構建證書鏈並檢查撤銷狀態。

+0

它的工作原理!謝謝 – Ale