I'm trying to use the Demoiselle Signer to verify the signature of a document made with the Serpro Digital Document Recorder ( link ).
The code is very simple:
byte[] documento = getBytesFrom("assinatura/tema-228.pdf");
byte[] assinatura = getBytesFrom("assinatura/tema-228.p7s");
PKCS7Signer signer = PKCS7Factory.getInstance().factoryDefault();
boolean ok = signer.check(documento, assinatura);
System.out.println(ok);
The files used in the test:
Pom:
<dependency>
<groupId>br.gov.frameworkdemoiselle.component</groupId>
<artifactId>demoiselle-certificate-signer</artifactId>
<version>2.0.0</version>
</dependency>
And what happened ...
java.lang.NullPointerException
at br.gov.frameworkdemoiselle.certificate.signer.pkcs7.impl.CAdESSigner.check(CAdESSigner.java:178)
at br.gov.serpro.sislv.assinatura.DemoiselleSignerTest.shouldVerificarAssinatura(DemoiselleSignerTest.java:29)
I tried to use the previous version of the signer:
<dependency>
<groupId>br.gov.frameworkdemoiselle.component</groupId>
<artifactId>demoiselle-certificate-signer</artifactId>
<version>1.0.9</version>
</dependency>
There he made another mistake:
br.gov.frameworkdemoiselle.certificate.signer.SignerException: O Atributo signingCertificate não pode ser nulo.
at br.gov.frameworkdemoiselle.certificate.signer.pkcs7.bc.policies.ADRBCMS_2_1.validate(ADRBCMS_2_1.java:219)
at br.gov.frameworkdemoiselle.certificate.signer.pkcs7.bc.CAdESSigner.check(CAdESSigner.java:238)
at br.gov.serpro.sislv.assinatura.DemoiselleSignerTest.shouldVerificarAssinatura(DemoiselleSignerTest.java:29)
The use of Signer was based on the following documentation: link
Doubt: How can I check a document signed by the Serpro Signer? Can you use the Demoiseller Signer for this?
One bad thing is that on the Signer page it does not account for the algorithms used = /
Is this subscriber basically Demoiselle Applet
with Demoiselle Signer
? Or is it something else to see?
Thank you! Leonardo Leite
PS: Demoiselle code where null pointer
occurs in version 2.0.0:
AttributeTable unsignedAttributes = signer.getUnsignedAttributes();
if (unsignedAttributes.size() == 0) { // null pointer aqui!
logger.info("O pacote PKCS7 não contem atributos nao assinados.");
}