Verifica firma XadES Bes in java

Buongiorno, ho la necessità di effettuare la verifica della signature XadES Bes dal nostro applicativo scritto in java. Mi chiedevo se esistesse uno standard in merito. Ho notato che c’è una lib chilkat che però mi sembra non più aggiornato dal 2020 e xades4j che invece non mi sembra essere maturo.

Voi cosa usate?

Buongiorno,
io sviluppo in .Net e faccio uso di Chilkat, che considero un ottimo prodotto!
Saluti
Emanuele

I’m using the DSS Library (Digital Signature Service) to sign XAdES and CAdES. It has support for many formats and also trusted lists. Check the project repository on github: esig/dss: Digital Signature Service : creation, extension and validation of advanced electronic signatures (github.com)


Sto usando la DSS Library (Digital Signature Service) per firmare XAdES e CAdES. Supporta molti formati e anche elenchi attendibili. Controlla il repository del progetto su github: esig/dss: Digital Signature Service : creazione, estensione e validazione di firme elettroniche avanzate (github.com)

Ciao! grazie per la risposta. Effettivamente avevo trovato anche io questa lib.
Il problema è che il certificato con cui sono firmati i loro XML di test (DatiDaSdITest per capirci) è rilasciato dalla CA di test di cui non abbiamo il certificato e quindi non posso verificarlo. Gli ho scritto ma mi hanno detto che la CA è quella di prod, ma non mi torna. Tu sei riuscito a fare questa verifica anche sui file di test? puoi per caso condividermi come hai fatto?

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();