Sichern Sie Ihren Linux -Server: So überprüfen Sie TLS/SSL -Zertifikat -Ablaufdaten. In diesem Artikel, we will learn how to check the expiration date of an SSL/TLS certificate from the command line using the OpenSSL client. The OpenSSL client provides detailed information about the validity dates, Ablaufdaten, and issuing authority of the certificate.
To check the expiration date of an SSL/TLS certificate, Öffnen Sie die Terminalanwendung und führen Sie den folgenden Befehl aus:
openssl s_client -servername {SERVER_NAME} -connect {SERVER_NAME}:{PORT} | openssl x509 -noout -dates
Zum Beispiel, um das herauszufinden Ablaufdatum des Zertifikats für enterinit.com, run the following command:
DOM="enterinit.com"
PORT="443"
openssl s_client -servername $DOM -connect $DOM:$PORT | openssl x509 -noout -dates
Die Ausgabe enthält Informationen zum Start- und Ablaufdaten des Zertifikats.
Sie können die hinzufügen echo
Befehl, um nicht drücken zu müssen CTRL+C
, Wie unten gezeigt:
DOM="{SITE_URL}"
PORT="443"
echo | openssl s_client -servername $DOM -connect $DOM:$PORT | openssl x509 -noout -dates
Der openssl
Befehlszeilenoptionen, die in den oben genannten Befehlen verwendet werden, sind wie folgt:
s_client
: Implementiert einen generischen SSL/TLS -Client, der mit SSL/TLS mit einem Remote -Host eine Verbindung herstellt.-servername $DOM
: Setzt den TLS SNI (Servernamenanzeige) Erweiterung in der Clienthello -Nachricht zum angegebenen Wert.-connect $DOM:$PORT
: Gibt den Host an ($Dom) und optionaler Port ($HAFEN) zu verbinden mit.x509
: Runs certificate display and signing utility.-noout
: Prevents output of the encoded version of the certificate.-dates: Prints out the start and expiry dates of a TLS or SSL certificate.
To find out the expiration date of a PEM encoded certificate file, run the following command:
openssl x509 -enddate -noout -in {/path/to/my/my.pem}
Zum Beispiel, to find out the expiration date of the certificate for enterinit.com, run the following command:
openssl x509 -enddate -noout -in /etc/nginx/ssl/enterinit.com
Die Ausgabe enthält das Ablaufdatum des Zertifikats.
You can also check if the certificate will expire within a given timeframe. Zum Beispiel, to find out if the certificate will expire within the next seven days, run the following command:
openssl x509 -enddate -noout -in my.pem -checkend 604800
To check if the certificate will expire in the next four months, run the following command:
openssl x509 -enddate -noout -in my.pem -checkend 10520000
Zusammenfassend, OpenSSL is a powerful diagnostic tool that provides useful information about the SSL/TLS certificates. Es hilft Ihnen sicherzustellen, dass die Zertifikate gültig und aktuell sind, und bei Bedarf zeitnahe Maßnahmen zu ergreifen.