All UNIX / Linux applications linked against the OpenSSL libraries can verify certificates signed by a recognized certificate authority (CA). How do I verify SSL certificates using OpenSSL command line toolkit itself under UNIX like operating systems without using third party websites?
You can pass the verify option to openssl command to verify certificates as follows:
$ openssl verify pem-file
$ openssl verify mycert.pem
$ openssl verify cyberciti.biz.pem
Sample outputs:
cyberciti.biz.pem: OK
You will see OK message if everything checks out. If a certificate has expired, it will complain about it. Please note that OpenSSL won't verify a self-signed certificate. You can also retrieve the www.example.com certificate as follows and verify the same:
$ mkdir -p ~/.cert/www.example.com/
$ cd ~/.cert/www.example.com/
$ openssl s_client -showcerts -connect www.example.com:443
Copy from the "-----BEGIN CERTIFICATE-----" to the "-----END CERTIFICATE-----" , and save it in your ~/.cert/www.example.com/ directory as www.example.com.pem file. By default OpenSSL is configured to use various certificate authorities your system trusts and stored in /usr/lib/ssl/ directory. You can verify this using the following command:
$ openssl version -d
Sample outputs:
OPENSSLDIR: "/usr/lib/ssl"
Another option is to get certificate from the CA repository:
$ wget https://certs.godaddy.com/repository/gd_bundle.crt -O ~/.cert/www.example.com/gd.pem
Finally, create a symbolic link to files named by the hash values using c_rehash, enter:
$ c_rehash ~/.cert/www.example.com/
To confirm you have the correct and working certificates, enter:
$ openssl s_client -CApath ~/.cert/mail.example.com/ -connect www.example.com:443
References (suggested readings):
- OpenSSL man page : The verify command verifies certificate chains.
- HowTo: Verify SSL certificate from a shell prompt
You should follow me on twitter here or grab rss feed to keep track of new changes.
Featured Articles:
- 30 Handy Bash Shell Aliases For Linux / Unix / Mac OS X
- Top 30 Nmap Command Examples For Sys/Network Admins
- 25 PHP Security Best Practices For Sys Admins
- 20 Linux System Monitoring Tools Every SysAdmin Should Know
- 20 Linux Server Hardening Security Tips
- Linux: 20 Iptables Examples For New SysAdmins
- Top 20 OpenSSH Server Best Security Practices
- Top 20 Nginx WebServer Best Security Practices
- 20 Examples: Make Sure Unix / Linux Configuration Files Are Free From Syntax Errors
- 15 Greatest Open Source Terminal Applications Of 2012

- My 10 UNIX Command Line Mistakes
- Top 10 Open Source Web-Based Project Management Software
- Top 5 Email Client For Linux, Mac OS X, and Windows Users
- The Novice Guide To Buying A Linux Laptop













{ 0 comments… add one now }