Skip to content

Certificado Modelo A3

Leonardo Pucci edited this page Dec 12, 2015 · 13 revisions

Os certificados A3 NÃO FUNCIONAM com o PHP!!!!

O uso de certificado em formato A3 está em estudo para verificarmos a possibilidade futura de seu uso, porém isso irá requer programas externos para a comunicação com o token (usb drive ou smart card).

Existem ferramentas para isso, mas ainda não estão integradas ao PHP e portanto esse certificado ainda não está acessível ao sistema. Isso inclui também sistemas profissionais como o HSM (Hardware Secure Module).

Um projeto está em andamento mas ainda não foi testado, que deve permitir o acesso pelo PHP dos certificados A3 : LibCryptoSec

Aparentemente existe um workaround, que usa o openssl executado via execv(php) para conseguir utilizar o certificado A3.

Aqui abaixo um exemplo assinando pdf:

 exec('openssl smime -md sha256 -binary -outform SMIME -sign -certfile /home/user/full_chain.pem -signer        /home/user/personal.pem -inkey slot_x-id_xxxxxxxxxxxxxxx -keyform engine -in ' . $tempdoc . ' -out ' . $tempsign . ' -  engine pkcs11 -passin pass:123456');
  • certfile: The path to the chain certificates (in PEM format). All certificates should be in a single file, one after the other. If your certificate authority has given you the certificates in another format (e.g. DER), see this link on how to convert them using OpenSSL.

  • signer: The path to your personal certificate (its public key). You can usually export this from your token using the manufacturer's middleware.

  • inkey: The slot and id of your certificate. In order to get these, from command line run "pkcs11-tool --module /usr/lib/libeTPkcs11.so --list-objects" where you have to replace the --module parameter value with the correct path for your middleware library.

  • passin: The PIN of your token (after pass:)

http://linkwi.se/gr-el/blog/blog-inner/qualified-electronic-signatures-pdf-php/