How to check TLS/SSL certificate expiration date from Linux CLI?
Last Updated :
05 Feb, 2023
Transport Layer Security is referred to as TLS. The system known as Transport Layer Security creates an encrypted session between two computers using the Internet. It authenticates the server's identity and inhibits data interception by hackers. When using the HTTPS protocol, users can securely transfer sensitive data thanks to TLS (and SSL's forerunner). In other words, HTTPS is TLS overlaid with HTTP. Applications like banking, information authentication, email exchange, and any other process requiring a greater level of privacy and security are perfect candidates for this technology. TLS makes it more difficult for hackers to get sensitive information by encrypting otherwise readable data. This helps to give an additional layer of security.
Digital certificates are files that are used to verify who has a public key, often known as identity certificates or public key certificates. A Certificate Authority issues TLS certificates, a sort of digital certificate (CA). The certificate is signed by the CA, attesting to the fact that they have confirmed it belongs to the people who hold the domain name that is the subject of the certificate.
TLS certificates typically include the following details:
- Domain Name
- Organization
- The name of the issuing CA
- Subdomains
- Issue Date
- Expiry Date
- The public key
- The digital signature by the CA
Below are the steps to view the expiration date of TLS/SSL from Linux CLI.
Find out the expiration date for www.geeksforgeeks.org
Step 1: Open The CLI (Command-Line Interface) by pressing below keyboard keys.
CTRL + ALT + T
Or you can open a terminal by right-clicking anywhere and the menu will be popped, click on the Open Terminal option.
Step 2: Define the variable for the site URL or the site name that you want to view the expiration date of TLS/SSL. (for eg. google.com). Use the below code to define a variable in CLI. (Replace google.com with the URL of the site that you want to see.)
export URL_OF_WEBSITE="www.geeksforgeeks.org"
Enter the above command and press enter.
Step 3: Again define one variable for the Port address as shown below.
export SSL_PORT_ADDRESS="443"
Step 4: Now use the below command to view the Expiration date, Paste the below command in CLI and press enter.
echo | openssl s_client -connect ${URL_OF_WEBSITE}:${SSL_PORT_ADDRESS} -servername ${URL_OF_WEBSITE} 2> /dev/null | openssl x509 -noout -dates
Step 5: There two dates will be appeared notBefore and notAfter, In that notAfter is the expiration date. See below screenshot of CLI you can see the expiration date.
Method: Finding the SSL certificate expiration date from a PEM-encoded certificate file
Step 1: Repeat the first three same steps as in the above example.
Step 2: Enter the below command to download the PEM Encoded Certificate file.
echo -n | openssl s_client -connect ${URL_OF_WEBSITE}:${SSL_PORT_ADDRESS} -servername ${URL_OF_WEBSITE} \ | openssl x509 > ./SSL.cert
After entering the above command SSL.cert file will be downloaded.
Step 3: Enter Below Command to view Expiry Data.
openssl x509 -enddate -noout -in ./SSL.cert
Step 4: The expiration Date will be displayed.
Similar Reads
Non-linear Components In electrical circuits, Non-linear Components are electronic devices that need an external power source to operate actively. Non-Linear Components are those that are changed with respect to the voltage and current. Elements that do not follow ohm's law are called Non-linear Components. Non-linear Co
11 min read
Spring Boot Tutorial Spring Boot is a Java framework that makes it easier to create and run Java applications. It simplifies the configuration and setup process, allowing developers to focus more on writing code for their applications. This Spring Boot Tutorial is a comprehensive guide that covers both basic and advance
10 min read
Class Diagram | Unified Modeling Language (UML) A UML class diagram is a visual tool that represents the structure of a system by showing its classes, attributes, methods, and the relationships between them. It helps everyone involved in a projectâlike developers and designersâunderstand how the system is organized and how its components interact
12 min read
Backpropagation in Neural Network Back Propagation is also known as "Backward Propagation of Errors" is a method used to train neural network . Its goal is to reduce the difference between the modelâs predicted output and the actual output by adjusting the weights and biases in the network.It works iteratively to adjust weights and
9 min read
3-Phase Inverter An inverter is a fundamental electrical device designed primarily for the conversion of direct current into alternating current . This versatile device , also known as a variable frequency drive , plays a vital role in a wide range of applications , including variable frequency drives and high power
13 min read
Decorators in Python In Python, decorators are a powerful and flexible way to modify or extend the behavior of functions or methods, without changing their actual code. A decorator is essentially a function that takes another function as an argument and returns a new function with enhanced functionality. Decorators are
10 min read
Linux Commands Cheat Sheet Linux, often associated with being a complex operating system primarily used by developers, may not necessarily fit that description entirely. While it can initially appear challenging for beginners, once you immerse yourself in the Linux world, you may find it difficult to return to your previous W
13 min read
Polymorphism in Java Polymorphism in Java is one of the core concepts in object-oriented programming (OOP) that allows objects to behave differently based on their specific class type. The word polymorphism means having many forms, and it comes from the Greek words poly (many) and morph (forms), this means one entity ca
7 min read
CTE in SQL In SQL, a Common Table Expression (CTE) is an essential tool for simplifying complex queries and making them more readable. By defining temporary result sets that can be referenced multiple times, a CTE in SQL allows developers to break down complicated logic into manageable parts. CTEs help with hi
6 min read
What is Vacuum Circuit Breaker? A vacuum circuit breaker is a type of breaker that utilizes a vacuum as the medium to extinguish electrical arcs. Within this circuit breaker, there is a vacuum interrupter that houses the stationary and mobile contacts in a permanently sealed enclosure. When the contacts are separated in a high vac
13 min read