Resolucion de Problemas Al Renovar Certificado SSL

Como renovar un certificado SSL manualmente

(Cuando la renovacion automatica ha fallado.)
Ultimamente por cambios en la forma de verificar los certificados SSL estan fallando los sistemas de renovacion automaticos.
En mi caso me ha pasado en todos los servidores Con Debian8 jessie.



Si compruebo el certificado por ejemplo con curl.

En este caso veo que el certificado esta expirado.

em50l@jejo.es:~$ curl -v https://jejo.es
* (304) (OUT), TLS handshake, Client hello (1):
* (304) (IN), TLS handshake, Server hello (2):
* TLSv1.2 (IN), TLS handshake, Certificate (11):
* TLSv1.2 (OUT), TLS alert, Server hello (2):
* SSL certificate problem: certificate has expired
* stopped the pause stream!
* Closing connection 0

Parece que el certificado ssl no se ha renovado correctamente.
Lo que provoca que las paginas https den un aviso en el nagegador y dejaran de verse.
Nota: Esto solo pasaria con las direcciones https no con las http.



Al lanzar la renovacion manualmente obtengo el siguiente error:

em50l@jejo.es:~$ certbot renew
Cert run renewal 
Plugins selected: Authenticator standalone, Installer None
Renewing an existing certificate
Performing the following challenges:
http-01 challenge for jejo.pw
Cleaning up challenges
Attempting to renew cert (jejo.pw) from /etc/letsencrypt/renewal/jejo.pw.conf produced an unexpected error: Problem binding to port 80: Could not bind to IPv4 or IPv6.. Skipping.
All renewal attempts failed. The following certs could not be renewed:
  /etc/letsencrypt/live/jejo.pw/fullchain.pem (failure)

Si no sabes si falla o no y tu certificado todavia no esta caducado puedes probar con certbot renew --dry-run --manual



En mi caso el problema viene ya que por seguridad tengo una redireccion de http a https.
Asi todo el trafico de la web se fuerza por https. Tambien pasa en muchas distros Debian8 ya que

em50l@jejo.es:~$ curl -v http://jejo.pw

< HTTP/1.1 301 Moved Permanently
< Date: Sun, 28 Jul 2019 15:32:13 GMT
< Server: Apache
< Location: https://jejo.pw/


Workarround:

  1. Paro apache
  2. Renuevo certificado en modo standalone
  3. Rearranco apache.
/etc/init.d/apache2 stop
certbot renew --dry-run -v --standalone

#si todo bien
certbot renew -v --standalone
/etc/init.d/apache2 start


Comprobacion Manual de que el certificado es correcto.

em50l@jejo.es:~$ curl -v https://jejo.pw
* (304) (OUT), TLS handshake, Client hello (1):
* (304) (IN), TLS handshake, Server hello (2):
* TLSv1.2 (IN), TLS handshake, Certificate (11):
* TLSv1.2 (IN), TLS handshake, Server key exchange (12):
* TLSv1.2 (IN), TLS handshake, Server finished (14):
* TLSv1.2 (OUT), TLS handshake, Client key exchange (16):
* TLSv1.2 (OUT), TLS change cipher, Client hello (1):
* TLSv1.2 (OUT), TLS handshake, Finished (20):
* TLSv1.2 (IN), TLS handshake, Finished (20):
* SSL connection using TLSv1.2 / ECDHE-RSA-AES128-GCM-SHA256
* ALPN, server accepted to use http/1.1
* Server certificate:
*  subject: CN=jejo.pw
*  start date: Jul 28 14:19:59 2019 GMT
*  expire date: Oct 26 14:19:59 2019 GMT
*  subjectAltName: host "jejo.pw" matched cert's "jejo.pw"
*  issuer: C=US; O=Let's Encrypt; CN=Let's Encrypt Authority X3
*  SSL certificate verify ok.
...

Tambien puedo analizar el certificado con un servicio online.
https://www.ssllabs.com/ssltest/analyze.html



Y Listo ya tengo el certificado SSL Operativo de nuevo.

resultado Test certificado ssl




Apendice 1 Añadir certificados

/etc/init.d/apache2 stop
certbot certonly -v --standalone -d dominio1.com -d dominio2.com
/etc/init.d/apache2 start

Apendice 3 Depuracion tcpdump.

Si algo falla es bueno tener informacion tcpdump.
Paquetes/solicitudes que no entran, Respuestas que no salen etc….
Nos puede ayudar a detectar problemas con la red y con la comunicacion TCP/IP.

tcpdump -vvlnn inbound and dst port 80 or outbound and src port 80
Si tcpdump es incapaz de detectar el protocolo http tendremos que añadir -X para ver los datos.
tcpdump -vvlnnX inbound and dst port 80 or outbound and src port 80
Nota: el filtro es importante. (inbound and dst port 13020 or outbound and src port 13020) ya que si nuestro servidor saldria mucho “ruido” que tendriamos que separar.

Aqui dejo una captura de trafico en la que se ven las peticiones y las respuestas HTTP:




Referencias:


Otra forma intentar renovar el certificado via registros DNS:


Para analizar el certificado ssl generado:


Para comprobar la transparencia de los certificados.