Proteger su servidor Linux: Cómo verificar las fechas de vencimiento del certificado TLS/SSL. En este artículo, 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, fechas de vencimiento, and issuing authority of the certificate.
To check the expiration date of an SSL/TLS certificate, Abra la aplicación Terminal y ejecute el siguiente comando.:
openssl s_client -servername {SERVER_NAME} -connect {SERVER_NAME}:{PORT} | openssl x509 -noout -dates
Por ejemplo, para descubrir el fecha de vencimiento del certificado para enterinit.com, run the following command:
DOM="enterinit.com"
PORT="443"
openssl s_client -servername $DOM -connect $DOM:$PORT | openssl x509 -noout -dates
El resultado incluirá información sobre las fechas de inicio y vencimiento del certificado..
Puedes agregar el echo
comando para evitar tener que presionar CTRL+C
, como se muestra a continuación:
DOM="{SITE_URL}"
PORT="443"
echo | openssl s_client -servername $DOM -connect $DOM:$PORT | openssl x509 -noout -dates
El openssl
Las opciones de línea de comandos utilizadas en los comandos anteriores son las siguientes:
s_client
: Implementa un cliente SSL/TLS genérico que se conecta a un host remoto mediante SSL/TLS..-servername $DOM
: Establece el TLS SNI (Indicación del nombre del servidor) extensión en el mensaje ClientHello al valor dado.-connect $DOM:$PORT
: Especifica el anfitrión ($DOMINGO) y puerto opcional ($PUERTO) para conectarse a.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}
Por ejemplo, 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
El resultado incluirá la fecha de vencimiento del certificado..
You can also check if the certificate will expire within a given timeframe. Por ejemplo, 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
En resumen, OpenSSL is a powerful diagnostic tool that provides useful information about the SSL/TLS certificates. Le ayuda a garantizar que los certificados sean válidos y estén actualizados., y tomar medidas oportunas cuando sea necesario.