Non ho provato a convalidare i file firmati con la CA di prova, ma ho convalidato le firme firmate con certificato autofirmato o firmate dalla mia CA di sviluppo.
Fondamentalmente è necessario caricare le CA personalizzate da un file di elenco attendibile locale (PFX, JKS)
I haven’t tried to validate files signed with test CA but I have validated signatures signed either with self-signed certificate or signed by my development CA.
You basically need to load the custom CAs from a local trusted list file (PFX, JKS)
— [some sample code that might help] —
final var localTrustStoreSource = new CommonTrustedCertificateSource();
// trust-store.pfx contains the public key of the CAs; if you sign with a self-signed then put the public part in the .pfx
// the file might have more than one certificate; use KeyStoreExplorer to build one. You can also use a JKS if you wish.
final var keyStore = new KeyStoreCertificateSource(“trust-store.pfx”, “PKCS12”, “super-secret”);
localTrustStoreSource.importAsTrusted(keyStore);
final var documentToValidate = new InMemoryDocument(documentSource.getByteStream(), documentName);
final CertificateVerifier cv = new CommonCertificateVerifier();
// Trust all certificates from the local trust store
cv.addTrustedCertSources(localTrustStoreSource);
// Trust all certificates loaded from trusted lists (remote)
// Load additional certificates from the trusted lists for EU countries available here:
// DSS Demonstration WebApp
// https://eidas.agid.gov.it/TL/TSL-IT.xml
// cv.addTrustedCertSources(trustedListStoreSource);
cv.setAIASource(new DefaultAIASource());
cv.setOcspSource(new OnlineOCSPSource());
cv.setCrlSource(new OnlineCRLSource());
final var documentValidator = SignedDocumentValidator.fromDocument(documentToValidate);
documentValidator.setValidationTime(Date.from(validationTime));
documentValidator.setValidationLevel(ValidationLevel.BASIC_SIGNATURES);
documentValidator.setCertificateVerifier(cv);
documentValidator.setIncludeSemantics(true);
final Reports reports = documentValidator.validateDocument();