This is a text-only version of the following page on https://raymii.org: --- Title : OpenSSL get entire certificate chain from a domain or loop over entire chain in file Author : Remy van Elst Date : 16-07-2024 18:30 URL : https://raymii.org/s/snippets/OpenSSL_get_entire_certificate_chain_from_a_domain_or_use_all_certs_in_a_file.html Format : Markdown/HTML --- The `openssl x509` command can be used to get information from a certificate. If you supply a filename, the command will only use the topmost certificate in the file, not all certificates in the file, like in the case of a certificate chain. The `openssl s_client -connect` command can connect to a server and show all certificates served by that server. The command I'm providing in this snippet splits up all certificates found in a file or as the result of `openssl s_client` and allows `openssl x509` to loop over each one individually.

Recently I removed all Google Ads from this site due to their invasive tracking, as well as Google Analytics. Please, if you found this content useful, consider a small donation using any of the options below:

I'm developing an open source monitoring app called Leaf Node Monitoring, for windows, linux & android. Go check it out!

Consider sponsoring me on Github. It means the world to me if you show your appreciation and you'll help pay the server costs.

You can also sponsor me by getting a Digital Ocean VPS. With this referral link you'll get $200 credit for 60 days. Spend $25 after your credit expires and I'll get $25!

The command I use to print the entire certificate chain from a domain is the following: OLDIFS=$IFS; IFS=':' certificates=$(openssl s_client -connect raymii.org:443 -showcerts -tlsextdebug 2>&1 . Just to be clear, the information on this website is for meant for educational purposes and you use it at your own risk. I do not take responsibility if you screw something up. Use common sense, do not 'rm -rf /' as root for example. If you have any questions then do not hesitate to contact me. See https://raymii.org/s/static/About.html for details.