What is the correct order of the ICP-Brazil certificate chain so that the certificate of an e-CPF and e-CNPJ is requested via TLS Handshake?

Asked

Viewed 2,436 times

9

To authenticate a user using the digital certificate, and to obtain this certificate in the backend it is necessary to enable the "SSL/TSL Handshake" option on the web server with the option to export the certificate as an environment variable - allowing access, after authorized and selected, by the language behind the web application.

However, only certificates that are on the property "CA Bundle" are allowed and listed in the prompt. CA Bundle, defines the certification chain that is trusted for authentication on this site.

In the case of e-CPF and e-CNPJ, which are digital certificates signed by the certification chain of ICP-Brasil.

I used a script to download and generate the Bundle with all certificates made publicly available on the official website, for those interested the script is as follows https://gist.github.com/skarllot/9663935, but I did not succeed in implementing the file generated on my webserver because the order generated by this script is random.

As this script downloads all certificates, it is still allowing the inclusion of NF-e and OAB certificates, which is not the focus.

The expected result is something like this:

Exemplo do prompt

Trying all combinations would not be an option at the moment as there are more than 133 certificates from the main directory (available here for those who need to download: http://www.iti.gov.br/icp-brasil/repositorio/144-icp-brasil/repositorio/3886-repositorio-de-certificados-arquivo-unico-compactado).

  • 2

    Why doesn’t it meet the scope ? the people who closed this topic should find the Ambambam.

  • @I don’t understand it either, but I respect the decision. The researches that this question made me ask me have elucidated a lot about Handshake ssl and I realized that there is no reason to maintain monopoly on login via ssl as certsign does, since it is relatively simple to do so.

  • 1

    The staff is used to the OS but Sopt is not the same site, the rules here are a little different, as Gabe https://pt.meta.stackoverflow.com/questions/1/aqui-n%C3%83o-%C3%89-o-stackoverflow-with Maybe this question is closed due to lack of understanding of who voted to close.

  • 1

    Just as they denied this question: https://answall.com/q/195207/7130 Sometimes questions like "how to add javascript" gain more credibility than one of such a complex subject.

  • 1

    Man, these days I asked a question about FTP authentication using the TLS protocol, I didn’t give 2 minutes and a so-called bigdow sent to close the question. mischief huh !

1 answer

7


After some searches in several sites, I got the expected result.

To complete the flow of SSL Handshake, the server needs to tell which certificates are accepted, so the browser will display the selection prompt with only possibly valid certificates to complete this request, as shown in the diagram below:

inserir a descrição da imagem aqui

In this way, It is necessary to add only the certificates "Root" in this "Bundle" of Cas. This combined file must respect the RFC 4346 using the delimiters correctly so that the file is read correctly by the web server.

The order that is working with me is as follows:

  1. Brazilian Root Certification Authority v5 (NF-e/e-CPF/e-CNPJ v5)
  2. Brazilian root V2 (e-CPF/e-CNPJ v2)

In this way:

CA do HTTPS do site 
==========
(...)
= CA ICP Brasil =
(NF-e/e-CPF/e-CNPJ v5)Autoridade Certificadora Raiz Brasileira v5
==========
-----BEGIN CERTIFICATE-----
MIIGoTCCBImgAwIBAgIBATANBgkqhkiG9w0BAQ0FADCBlzELMAkGA1UEBhMCQlIx
EzARBgNVBAoMCklDUC1CcmFzaWwxPTA7BgNVBAsMNEluc3RpdHV0byBOYWNpb25h
bCBkZSBUZWNub2xvZ2lhIGRhIEluZm9ybWFjYW8gLSBJVEkxNDAyBgNVBAMMK0F1
dG9yaWRhZGUgQ2VydGlmaWNhZG9yYSBSYWl6IEJyYXNpbGVpcmEgdjUwHhcNMTYw
MzAyMTMwMTM4WhcNMjkwMzAyMjM1OTM4WjCBlzELMAkGA1UEBhMCQlIxEzARBgNV
BAoMCklDUC1CcmFzaWwxPTA7BgNVBAsMNEluc3RpdHV0byBOYWNpb25hbCBkZSBU
ZWNub2xvZ2lhIGRhIEluZm9ybWFjYW8gLSBJVEkxNDAyBgNVBAMMK0F1dG9yaWRh
ZGUgQ2VydGlmaWNhZG9yYSBSYWl6IEJyYXNpbGVpcmEgdjUwggIiMA0GCSqGSIb3
DQEBAQUAA4ICDwAwggIKAoICAQD3LXgabUWsF+gUXw/6YODeF2XkqEyfk3VehdsI
x+3/ERgdjCS/ouxYR0Epi2hdoMUVJDNf3XQfjAWXJyCoTneHYAl2McMdvoqtLB2i
leQlJiis0fTtYTJayee9BAIdIrCor1Lc0vozXCpDtq5nTwhjIocaZtcuFsdrkl+n
bfYxl5m7vjTkTMS6j8ffjmFzbNPDlJuV3Vy7AzapPVJrMl6UHPXCHMYMzl0KxR/4
7S5XGgmLYkYt8bNCHA3fg07y+Gt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cOgzuFU2YsgProtVu0fFNXGr6KK9fu44pOHajmMsTXK3X7r/P
wh19kFRow5F3RQMUZC6Re0YLfXh+ypnUSCzA+uL4JPtHIGyvkbWiulkustpOKUSV
wBPzvA2sQUOvqdbAR7C8jcHYFJMuK2HZFji7pxcWWab/NKsFcJ3sluDjmhizpQax
bYTfAVXu3q8yd0su/BHHhBpteyHvYyyz0Eb9LUysR2cMtWvfPU6vnoPgYvOGO1Cz
iyGEsgKULkCH4o2Vgl1gQuKWO4V68rFW8a/jvq28sbY+y/Ao0I5ohpnBcQOAawiF
bz6yJtObajYMuztDDP8oY656EuuJXBJhuKAJPI/7WDtgfV8ffOh/iQGQATVMtgDN
0gv8bn5NdUX8UMNX1sHhU3H1UpoW
-----END CERTIFICATE-----



(e-CPF/e-CNPJ v2) Raiz Brasileira V2
===========================================
-----BEGIN CERTIFICATE-----
MIIGoTCCBImgAwIBAgIBATANBgkqhkiG9w0BAQ0FADCBlzELMAkGA1UEBhMCQlIx
EzARBgNVBAoTCklDUC1CcmFzaWwxPTA7BgNVBAsTNEluc3RpdHV0byBOYWNpb25h
bCBkZSBUZWNub2xvZ2lhIGRhIEluZm9ybWFjYW8gLSBJVEkxNDAyBgNVBAMTK0F1
dG9yaWRhZGUgQ2VydGlmaWNhZG9yYSBSYWl6IEJyYXNpbGVpcmEgdjIwHhcNMTAw
NjIxMTkwNDU3WhcNMjMwNjIxMTkwNDU3WjCBlzELMAkGA1UEBhMCQlIxEzARBgNV
BAoTCklDUC1CcmFzaWwxPTA7BgNVBAsTNEluc3RpdHV0byBOYWNpb25hbCBkZSBU
ZWNub2xvZ2lhIGRhIEluZm9ybWFjYW8gLSBJVEkxNDAyBgNVBAMTK0F1dG9yaWRh
ZGUgQ2VydGlmaWNhZG9yYSBSYWl6IEJyYXNpbGVpcmEgdjIwggIiMA0GCSqGSIb3
DQEBAQUAA4ICDwAwggIKAoICAQC6RqQO3edA8rWgfFKVV0X8bYTzhgHJhQOtmKvS
8l4Fmcm7b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vLIJdgmAOWcAGDRtBgrmtRBZ
SLp1YPw/jh0YVXArnkuVrImrCncke2HEx5EmjkYTUTe2jCcK0w3wmisig4OzvYM1
rZs8vHiDKTVhNvgRcTMgVGNTRQHYE1qEO9dmEyS3xEbFIthzJO4cExeWyCXoGx7P
34VQbTzq91CeG5fep2vb1nPSz3xQwLCM5VMSeoY5rDVbZ8fq1PvRwl3qDpdzmK4p
v+Q68wQ2UCzt3h7bhegdhAnu86aDM1tvR3lPSLX8uCYTq6qz9GER+0Vn8x0+bv4q
SyZEGp+xouA82uDkBTp4rPuooU2/XSx3KZDNEx3vBijYtxTzW8jJnqd+MRKKeGLE
0QW8BgJjBCsNid3kXFsygETUQuwq8/JAhzHVPuIKMgwUjdVybQvm/Y3kqPMFjXUX
d5sKufqQkplliDJnQwWOLQsVuzXxYejZZ3ftFuXoAS1rND+Og7P36g9KHj41hJ2M
gDQ/qZXow63EzZ7KFBYsGZ7kNou5uaNCJQc+w+XVaE+gZhyms7ZzHJAaP0C5GlZC
cIf/by0PEf0e//eFMBUO4xcx7ieVzMnpmR6Xx21bB7UFaj3yRd+6gnkkcC6bgh9m
qaVtJ8z2KqLRX4Vv4EadqtKlTlUO
-----END CERTIFICATE-----

These two meet the newest certificates. It is possible to download them on the official website:

http://www.iti.gov.br/icp-brasil/certificados/188-atualizacao/4530-ac-raiz

  • this Bundle that you cite above, must be configured in which apache parameter?

  • @Celsomarigojr You must combine the certificates in your apache configuration in this question I gave more details of how this works: https://answall.com/a/194946/7130 Here’s an example with apache also: https://cweiske.de/tagebuch/ssl-client-certificates.htm

  • @Leonancarvalho as you do to send to the browser you need a certificate? I do not understand yet. it works for A3 e-cpf/e-cnpj?

  • 1

    @Hagahood answered this question here: https://answall.com/a/198803/7130 &#Xa.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.