Last active
November 17, 2025 19:28
-
-
Save skarllot/9663935 to your computer and use it in GitHub Desktop.
Download ICP-Brasil certificates and make a bundle
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| HTTPADDR=http://acraiz.icpbrasil.gov.br/credenciadas/CertificadosAC-ICP-Brasil/ACcompactado.zip | |
| DEST=/etc/ssl/certs/icp-brasil | |
| mkdir -p ${DEST} | |
| cd ${DEST} | |
| rm -f *.crt | |
| rm -f *.zip | |
| wget "$HTTPADDR" | |
| unzip *.zip | |
| for fn in $(file *.crt|grep data|sed 's/: *data//') | |
| do | |
| mv $fn $fn.der | |
| openssl x509 -inform der -in $fn.der -out $fn | |
| done | |
| #rm *.der | |
| for f in $(ls *.crt); do | |
| dos2unix $f > /dev/null | |
| openssl x509 -text -in $f >> bundle.crt | |
| done | |
| #Ref: http://blog.gendoc.com.br/2012/03/instalando-os-certificados-ac-do-icp-brasil-para-e-cpf-e-e-cnpj/ | |
| #Ref: http://www.iti.gov.br/icp-brasil/certificados/188-atualizacao/4530-ac-raiz |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <VirtualHost *:443> | |
| (...) | |
| SSLCACertificateFile /etc/ssl/certs/icp-brasil/bundle.crt | |
| (...) | |
| </VirtualHost> |
Pelo que analisei o problema do arquivo bundle ter ficado muito grande foi devido ao comando openssl x509 -text -in $f >> bundle.crt, este comando esta listando todos os dados do certificado.
Entendo que não é necessário o passo anterior a concatenação, onde tem um loop for para DER.
Embora os arquivos tenham a extensão .crt, o formato dos certificados são PEM.
O ideal é ter um script fazendo a concatenação de todos os certificados .crt.
Sugestão: for f in $(ls *.crt); do dos2unix $f -q && cat $f >> /tmp/bundleicpbrasil.crt ; done
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Ok, desmontando meu eCNPJ eu identifiquei 3 certificados que estão no zip deste shell.
O trecho abaixo faz o Nginx funcionar direitinho
nas confs do nginx, tenho
Entendi que ssl_verify_depth vai fazer o Nginx verificar os certificados intermediarios no chain.pem, mas honestamente, ainda não li a documentação oficial. https://stackoverflow.com/questions/8431528/nginx-ssl-certificate-authentication-signed-by-intermediate-ca-chain