User Tools

Site Tools


hpkp_public_key_pinning_con_let_s_encrypt

HPKP con Let's Encrypt

Cuando se utilizan certificados Let's Encrypt, si no se está conservando siempre la llave privada para renovar los certificados cada tres meses, se pueden tener problemas al usar HPKP. Si el “Key pinning” fue configurado unicamente con el hash del certificado en uso, al renovarse con otra llave privada la lave publica del certificado será diferente y el pinning fallará, bloqueando a todo visitante durante el tiempo configurado en la directiva. Hay que andarse con cuidado al trabajar con este tipo de medidas de seguridad ya que se puede dejar a los visitantes sin acceso al dominio por días meses o incluso años.

Si no se quiere conservar la llave privada al renovar los certificados (hay documentación de sobra), a falta de un soporte oficial por parte de Let's Encrypt, una solución sería hacer el pinning contra uno de los certificados intermedios y/o raíz. De esta manera también es posible detectar modificaciones en la cadena de certificación. Si se compromete la CA, hay que tener claro que posiblemente se estaría expuesto a ataques MiTM con certificados fraudulentos de Let's Encrypt. Pero se seguiría estando seguro frente a ataques que utilicen certificados de de otras CA vulneradas y se mantengan confiables para los navegadores.

Cadena de confianza de Let's Encrypt: https://letsencrypt.org/certificates/
No está de más visitar de vez en cuando la web y buscar posibles novedades, como certificados retirados.

Certificados recomendados para HPKP.

  • C5+lpZ7tcVwmwQIMcRtPbsQtWLABXhQzejna0wHFr8M=
  • YLh1dUR9y6Kja30RrAn7JKnbQG/uEtLMkBgFF2Fuihg=
  • sRHdihwgkaib1P1gxX8HFszlD+7/gTfNvuAybgLPNis=
  • Vjs8r4z+80wjNcr1YKepWQboSIRi63WsWXhIMN+eWys=

Ejemplo de uso de HPKP en Nginx con Let's Encrypt (1 mes = 2592000 segundos).

add_header Public-Key-Pins 'pin-sha256="C5+lpZ7tcVwmwQIMcRtPbsQtWLABXhQzejna0wHFr8M=";pin-sha256="YLh1dUR9y6Kja30RrAn7JKnbQG/uEtLMkBgFF2Fuihg=";pin-sha256="sRHdihwgkaib1P1gxX8HFszlD+7/gTfNvuAybgLPNis=";pin-sha256="Vjs8r4z+80wjNcr1YKepWQboSIRi63WsWXhIMN+eWys="; max-age=2592000; report-uri="XXX"';

Obtener con curl hashes para keypinning de certificados “let's encrypt”.

curl -qs https://letsencrypt.org/certs/lets-encrypt-x4-cross-signed.pem | openssl x509 -pubkey | openssl pkey -pubin -outform der | openssl dgst -sha256 -binary | base64
curl -qs https://letsencrypt.org/certs/lets-encrypt-x3-cross-signed.pem | openssl x509 -pubkey | openssl pkey -pubin -outform der | openssl dgst -sha256 -binary | base64
curl -qs https://letsencrypt.org/certs/isrgrootx1.pem | openssl x509 -pubkey | openssl pkey -pubin -outform der | openssl dgst -sha256 -binary | base64
# Root CA: https://www.identrust.com/certificates/trustid/root-download-x3.html

Analizar online políticas HPKP: https://report-uri.io/home/pkp_analyse/

Borrar configuraciones HPKP guardadas en Firefox.

An error occurred during a connection to domain. The server uses key pinning (HPKP) but no trusted certificate chain could be constructed that matches the pinset. Key pinning violations cannot be overridden. (Error code: mozilla_pkix_error_key_pinning_failure)

    * The page you are trying to view cannot be shown because the authenticity of the received data could not be verified.
    * Please contact the website owners to inform them of this problem.
  • Borrar el fichero (Linux): ~/.mozilla/firefox/XXXX.default/SiteSecurityServiceState.txt.
  • Borrar el fichero (MAC): /Users/[username]/Library/Application Support/Firefox/Profiles/[random].default
hpkp_public_key_pinning_con_let_s_encrypt.txt · Last modified: 2020/12/25 22:57 by 127.0.0.1