Skip to content

Instantly share code, notes, and snippets.

@mergulhao
Last active April 6, 2017 13:33
Show Gist options
  • Star 7 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save mergulhao/6269789 to your computer and use it in GitHub Desktop.
Save mergulhao/6269789 to your computer and use it in GitHub Desktop.
How to convert a PFX ssl certificate to PEM? If you are in Brazil and buy an A1 (e-CNPJ) certificate from CertSign it comes as a PFX. We need to convert it to PEM format so we can use the certificate to sign documents electronically and use it to access a lot of APIs, incluing NFe.
### pfx to pem, complete edition:
$ openssl pkcs12 -in filename.pfx -nocerts -out key.pem
$ openssl pkcs12 -in filename.pfx -clcerts -nokeys -out cert.pem
$ openssl pkcs12 -in filename.pfx -cacerts -out ca_cert.pem
@rafaelp
Copy link

rafaelp commented Aug 25, 2014

Antes de rodar o comando é necessário escolher uma senha, de preferência um string com 120 caracteres randômicos. Essa senha é usada na geração do key e do ca_cert.

Para colocar o conteúdo de cada arquivo como variável de ambiente no Heroku usar esse trick:
http://stackoverflow.com/questions/6942600/multi-line-config-variables-in-heroku
http://stackoverflow.com/questions/2789319/file-content-into-unix-variable-with-newlines

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment