Open modal with JavaScript to select certificate and send to server

3

When we enter the eCAC - Virtual Service Center page and click on Digital Certificate on the right side of the screen opens a modal to select a certain certificate that we configure in the system (this if there are certificate (s) in the configured system). Here is the modal image with the modal description deleted:

I would like to know how I can implement a resource similar to this in a given system application using JavaScript to load the customer's NF-e certificate and use it to send the invoices to the Government and perform other operations with them . I still have not figured out where to start and few of the materials found.

    
asked by anonymous 06.11.2015 / 19:48

1 answer

2

Well, after a long time, I managed to find a solution, today Certisign has an API that validates digital certificates.

If I'm not mistaken a GET with javascript is blocked by CORS from their application,

<form action=" https://autenticador.certisign.com.br/CertisignLogin/certificado/login?id={idDaChave}&nome={nomeDaChave}&retorno={urlDeRetorno}"
  method="get">
   <input type="submit" value="enviar" />
</form>

Using a form, when you send it, it automatically prompts you to choose the certificate, and it will open the modal.

In this return URL, it will send you a token, encrypted, if it is authenticated, and you will have access to the data, for example:

CertificadoBean:
{
  emissor: Certisign Autoridade Certificadora TESTE,
  nome: "PROPRIETARIO DO CERTIFICADO DE TESTE",
  cpf: "001.002.003-44",
  cnpj: "",
  OAB: "",
  validade: "2015-05-27 20:59:59",
  emissao: "2014-05-27 21:00:00",
  email: "[email protected]",
  certificadoBase64: "MIIFmDCCBICgAwI...... BAQUFADCCARAx"
}

If you have further questions, link

Here on my team, we had some questions, so we called them on the phone that is on the site. They treated us very well and answered all our questions.

    
14.07.2016 / 20:49