This post describes how to generate a few backup public key hashes to add to your HTTP Public Key Pinning (HPKP) config that might save you from bricking your domain if Let’s Encrypt ever gets untrusted like StartCom did.
If you have a healthy distrust of the X.509 PKI trust model, then you’ve probably heard of HPKP (and probably also HSTS & CAA). Website certificate pinning was a trend first started by google, who hard-coded a pin of their certificates in their Chrome browser. Eventually, google helped build a more standardized pinning method under RFC 7469. And today, it’s supported by Chrome, Firefox, and Opera.
Pinning is a great TOFU improvement to https, but–if misconfigured–you could “brick” your domain–making it so that your client’s browsers will refuse to let them access your site for months or years (interestingly, this has also caused some security experts to think of how HPKP could be abused in ransom-ware). Therefore, it’s a good idea to follow a few HPKP Best Practices.
Calculate Public Key Pins
This section will show the commands used to calculate the Public Key Pins that you’ll need to add to your web server’s config. In these examples, I’m using certificates that I recently created for a website that I’m securing: openbuildinginstitute.org
This guide assumes you’ve already generated your certificates with Let’s Encrypt, and that they’ve been stored to ‘/etc/letsencrypt/live/<your_domain>/’.
Leaf Certificate
First, get the pin of your leaf certificate issued by Let’s Encrypt.
[root@centos7 ~]# openssl x509 -in /etc/letsencrypt/live/openbuildinginstitute.org/cert.pem -pubkey | openssl pkey -pubin -outform der | openssl dgst -sha256 -binary | base64 UbSbHFsFhuCrSv9GNsqnGv4CbaVh5UV5/zzgjLgHh9c=
Note that this hash may change every 90 days when your certificate is renewed.
Let’s Encrypt Intermediate Certificate
Next, get the pin of the intermediate Let’s Encrypt certificate that signed your certificate.
[root@centos7 ~]# openssl x509 -in /etc/letsencrypt/live/openbuildinginstitute.org/chain.pem -pubkey | openssl pkey -pubin -outform der | openssl dgst -sha256 -binary | base64 YLh1dUR9y6Kja30RrAn7JKnbQG/uEtLMkBgFF2Fuihg=
Note that this hash may change when Let’s Encrypt rotates their Intermediate certificates. At the time of writing, they’ve already rotated to their third intermediate certificate.
Let’s Encrypt Root Certificate
Next, get the pin of the Root Let’s Encrypt certificate (The Internet Security Research Group (ISRG) is a California public benefit corporation that benefits Let’s Encrypt).
[root@centos7 ~]# mkdir /var/tmp/letsencrypt [root@centos7 ~]# cd /var/tmp/letsencrypt/ [root@centos7 letsencrypt]# wget --quiet https://letsencrypt.org/certs/isrgrootx1.pem [root@centos7 letsencrypt]# cat isrgrootx1.pem -----BEGIN CERTIFICATE----- MIIFazCCA1OgAwIBAgIRAIIQz7DSQONZRGPgu2OCiwAwDQYJKoZIhvcNAQELBQAw TzELMAkGA1UEBhMCVVMxKTAnBgNVBAoTIEludGVybmV0IFNlY3VyaXR5IFJlc2Vh cmNoIEdyb3VwMRUwEwYDVQQDEwxJU1JHIFJvb3QgWDEwHhcNMTUwNjA0MTEwNDM4 WhcNMzUwNjA0MTEwNDM4WjBPMQswCQYDVQQGEwJVUzEpMCcGA1UEChMgSW50ZXJu ZXQgU2VjdXJpdHkgUmVzZWFyY2ggR3JvdXAxFTATBgNVBAMTDElTUkcgUm9vdCBY MTCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBAK3oJHP0FDfzm54rVygc h77ct984kIxuPOZXoHj3dcKi/vVqbvYATyjb3miGbESTtrFj/RQSa78f0uoxmyF+ 0TM8ukj13Xnfs7j/EvEhmkvBioZxaUpmZmyPfjxwv60pIgbz5MDmgK7iS4+3mX6U A5/TR5d8mUgjU+g4rk8Kb4Mu0UlXjIB0ttov0DiNewNwIRt18jA8+o+u3dpjq+sW T8KOEUt+zwvo/7V3LvSye0rgTBIlDHCNAymg4VMk7BPZ7hm/ELNKjD+Jo2FR3qyH B5T0Y3HsLuJvW5iB4YlcNHlsdu87kGJ55tukmi8mxdAQ4Q7e2RCOFvu396j3x+UC B5iPNgiV5+I3lg02dZ77DnKxHZu8A/lJBdiB3QW0KtZB6awBdpUKD9jf1b0SHzUv KBds0pjBqAlkd25HN7rOrFleaJ1/ctaJxQZBKT5ZPt0m9STJEadao0xAH0ahmbWn OlFuhjuefXKnEgV4We0+UXgVCwOPjdAvBbI+e0ocS3MFEvzG6uBQE3xDk3SzynTn jh8BCNAw1FtxNrQHusEwMFxIt4I7mKZ9YIqioymCzLq9gwQbooMDQaHWBfEbwrbw qHyGO0aoSCqI3Haadr8faqU9GY/rOPNk3sgrDQoo//fb4hVC1CLQJ13hef4Y53CI rU7m2Ys6xt0nUW7/vGT1M0NPAgMBAAGjQjBAMA4GA1UdDwEB/wQEAwIBBjAPBgNV HRMBAf8EBTADAQH/MB0GA1UdDgQWBBR5tFnme7bl5AFzgAiIyBpY9umbbjANBgkq hkiG9w0BAQsFAAOCAgEAVR9YqbyyqFDQDLHYGmkgJykIrGF1XIpu+ILlaS/V9lZL ubhzEFnTIZd+50xx+7LSYK05qAvqFyFWhfFQDlnrzuBZ6brJFe+GnY+EgPbk6ZGQ 3BebYhtF8GaV0nxvwuo77x/Py9auJ/GpsMiu/X1+mvoiBOv/2X/qkSsisRcOj/KK NFtY2PwByVS5uCbMiogziUwthDyC3+6WVwW6LLv3xLfHTjuCvjHIInNzktHCgKQ5 ORAzI4JMPJ+GslWYHb4phowim57iaztXOoJwTdwJx4nLCgdNbOhdjsnvzqvHu7Ur TkXWStAmzOVyyghqpZXjFaH3pO3JLF+l+/+sKAIuvtd7u+Nxe5AW0wdeRlN8NwdC jNPElpzVmbUq4JUagEiuTDkHzsxHpFKVK7q4+63SM1N95R1NbdWhscdCb+ZAJzVc oyi3B43njTOQ5yOf+1CceWxG1bQVs5ZufpsMljq4Ui0/1lvh+wjChP4kqKOJ2qxq 4RgqsahDYVvTH9w7jXbyLeiNdd8XM2w9U/t7y0Ff/9yi0GE44Za4rF2LN9d11TPA mRGunUHBcnWEvgJBQl9nJEiU0Zsnvgc/ubhPgXRR4Xq37Z0j4r7g1SgEEzwxA57d emyPxgcYxn/eR44/KJ4EBs+lVDR3veyJm+kXQ99b21/+jh5Xos1AnX5iItreGCc= -----END CERTIFICATE----- [root@centos7 letsencrypt]# openssl x509 -in isrgrootx1.pem -pubkey | openssl pkey -pubin -outform der | openssl dgst -sha256 -binary | base64 C5+lpZ7tcVwmwQIMcRtPbsQtWLABXhQzejna0wHFr8M=
IdenTrust Root Certificate
Next, get the pin of the IdenTrust Root certificate, which was used to cross-sign the Let’s Encrypt Root Certificate above.
Unfortunately, there’s no easy way to script this. You have to go to IdenTrust’s website and copy & paste the contents of their <textarea> into a text editor. Then you have to add ‘—–BEGIN CERTIFICATE—–‘ to the top of the file and ‘—–END CERTIFICATE—–‘ to the end of the file.
[root@centos7 ~]# mkdir /var/tmp/letsencrypt [root@centos7 ~]# cd /var/tmp/letsencrypt/ # type the contents of the <textarea> from this site https://www.identrust.com/certificates/trustid/root-download-x3.html # then add '-----BEGIN CERTIFICATE-----' to the top of the file and # then add '-----END CERTIFICATE-----' to the end of the file [root@centos7 letsencrypt]# vim identrust.dst.root.x3.pem [root@centos7 letsencrypt]# cat /var/tmp/identrust.dst.root.x3.pem -----BEGIN CERTIFICATE----- MIIDSjCCAjKgAwIBAgIQRK+wgNajJ7qJMDmGLvhAazANBgkqhkiG9w0BAQUFADA/ MSQwIgYDVQQKExtEaWdpdGFsIFNpZ25hdHVyZSBUcnVzdCBDby4xFzAVBgNVBAMT DkRTVCBSb290IENBIFgzMB4XDTAwMDkzMDIxMTIxOVoXDTIxMDkzMDE0MDExNVow PzEkMCIGA1UEChMbRGlnaXRhbCBTaWduYXR1cmUgVHJ1c3QgQ28uMRcwFQYDVQQD Ew5EU1QgUm9vdCBDQSBYMzCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEB AN+v6ZdQCINXtMxiZfaQguzH0yxrMMpb7NnDfcdAwRgUi+DoM3ZJKuM/IUmTrE4O rz5Iy2Xu/NMhD2XSKtkyj4zl93ewEnu1lcCJo6m67XMuegwGMoOifooUMM0RoOEq OLl5CjH9UL2AZd+3UWODyOKIYepLYYHsUmu5ouJLGiifSKOeDNoJjj4XLh7dIN9b xiqKqy69cK3FCxolkHRyxXtqqzTWMIn/5WgTe1QLyNau7Fqckh49ZLOMxt+/yUFw 7BZy1SbsOFU5Q9D8/RhcQPGX69Wam40dutolucbY38EVAjqr2m7xPi71XAicPNaD aeQQmxkqtilX4+U9m5/wAl0CAwEAAaNCMEAwDwYDVR0TAQH/BAUwAwEB/zAOBgNV HQ8BAf8EBAMCAQYwHQYDVR0OBBYEFMSnsaR7LHH62+FLkHX/xBVghYkQMA0GCSqG SIb3DQEBBQUAA4IBAQCjGiybFwBcqR7uKGY3Or+Dxz9LwwmglSBd49lZRNI+DT69 ikugdB/OEIKcdBodfpga3csTS7MgROSR6cz8faXbauX+5v3gTt23ADq1cEmv8uXr AvHRAosZy5Q6XkjEGB5YGV8eAlrwDPGxrancWYaLbumR9YbK+rlmM6pZW87ipxZz R8srzJmwN0jP41ZL9c8PDHIyh8bwRLtTcm1D9SZImlJnt1ir/md2cXjbDaJWFBM5 JDGFoqgCWjBH4d1QB7wCCZAA62RjYJsWvIjJEubSfZGL+T0yjWW06XyxV3bqxbYo Ob8VZRzI9neWagqNdwvYkQsEjgfbKbYK7p2CNTUQ -----END CERTIFICATE----- [root@centos7 letsencrypt]# openssl x509 -in identrust.dst.root.x3.pem -pubkey | openssl pkey -pubin -outform der | openssl dgst -sha256 -binary | base64 Vjs8r4z+80wjNcr1YKepWQboSIRi63WsWXhIMN+eWys=
Backup Key CSRs
It’s a good idea to pregenerate keys & Certificate Signing Requests (CSRs). In fact, this is required–though no tool can actually validate this.
[root@centos7 ~]# mkdir /etc/pki/tls/hpkpBackupKeys [root@centos7 ~]# chown root:root /etc/pki/tls/hpkpBackupKeys [root@centos7 ~]# chmod 0700 /etc/pki/tls/hpkpBackupKeys/ [root@centos7 ~]# cd /etc/pki/tls/hpkpBackupKeys/ [root@centos7 hpkpBackupKeys]# openssl genrsa -out first.key 4096 Generating RSA private key, 4096 bit long modulus .................................................................++ ..............................................................................................................................................................................................................................++ e is 65537 (0x10001) [root@centos7 hpkpBackupKeys]# openssl req -new -key first.key -sha256 -out first.csr You are about to be asked to enter information that will be incorporated into your certificate request. What you are about to enter is what is called a Distinguished Name or a DN. There are quite a few fields but you can leave some blank For some fields there will be a default value, If you enter '.', the field will be left blank. ----- Country Name (2 letter code) [XX]:US State or Province Name (full name) []: Locality Name (eg, city) [Default City]: Organization Name (eg, company) [Default Company Ltd]: Organizational Unit Name (eg, section) []: Common Name (eg, your name or your server's hostname) []: Email Address []: Please enter the following 'extra' attributes to be sent with your certificate request A challenge password []: An optional company name []: [root@centos7 hpkpBackupKeys]# openssl genrsa -out second.key 4096 Generating RSA private key, 4096 bit long modulus ...............................................................................................................++ ...............................................................................................................................................++ e is 65537 (0x10001) [root@centos7 hpkpBackupKeys]# openssl req -new -key second.key -sha256 -out second.csr You are about to be asked to enter information that will be incorporated into your certificate request. What you are about to enter is what is called a Distinguished Name or a DN. There are quite a few fields but you can leave some blank For some fields there will be a default value, If you enter '.', the field will be left blank. ----- Country Name (2 letter code) [XX]:US State or Province Name (full name) []:Missouri Locality Name (eg, city) [Default City]:Maysville Organization Name (eg, company) [Default Company Ltd]:Open Source Ecology Organizational Unit Name (eg, section) []: Common Name (eg, your name or your server's hostname) []:opensourceecology.org Email Address []:letsencrypt@opensourceecology.org Please enter the following 'extra' attributes to be sent with your certificate request A challenge password []: An optional company name []: [root@centos7 hpkpBackupKeys]# chown -R root:root /etc/pki/tls/hpkpBackupKeys [root@centos7 hpkpBackupKeys]# chmod 0400 /etc/pki/tls/hpkpBackupKeys/* [root@centos7 hpkpBackupKeys]# openssl req -pubkey < first.csr | openssl pkey -pubin -outform der | openssl dgst -sha256 -binary | base64 MDhNnV1cmaPdDDONbiVionUHH2QIf2aHJwq/lshMWfA= [root@centos7 hpkpBackupKeys]# openssl req -pubkey < second.csr | openssl pkey -pubin -outform der | openssl dgst -sha256 -binary | base64 OIZP7FgTBf7hUpWHIA7OaPVO2WrsGzTl9vdOHLPZmJU=
In the above example, I locked-down the permissions of these backup key files to root:root 0400. However, it would be a good idea to store them in an encrypted backup in a safe & securely delete them from the server entirely.
Two Backup CAs
Finally, it’s a good idea to pin the root certificate for two distinct CAs in the event that Let’s Encrypt is unusable in the future. In this example, I’m using
- CloudFlare (because they offer free SSL certificates) and
- ssl.com (because they offer free 90-day certificates)
Note that CloudFlare’s certificates themselves are cross-signed by digicert, addtrust, globalsign, and gtecybertrust (now digicert), so we include those as well.
#################################################################### # pin cloudflare root CA certs if Let's Encrypt disappears one day # #################################################################### # https://support.cloudflare.com/hc/en-us/articles/115001186052-What-intermediates-and-roots-are-Cloudflare-issued-certs-signed-against- [root@centos7 ~]# mkdir /var/tmp/cloudflare [root@centos7 ~]# cd /var/tmp/cloudflare # CloudFlare Universal SSL Certs are signed by Comodo or GlobalSign # https://www.crt.sh/?d=1 # https://www.crt.sh/?d=88 [root@centos7 cloudflare]# wget --quiet -O addtrust.pem https://www.crt.sh/?d=1 [root@centos7 cloudflare]# cat addtrust.pem -----BEGIN CERTIFICATE----- MIIENjCCAx6gAwIBAgIBATANBgkqhkiG9w0BAQUFADBvMQswCQYDVQQGEwJTRTEU MBIGA1UEChMLQWRkVHJ1c3QgQUIxJjAkBgNVBAsTHUFkZFRydXN0IEV4dGVybmFs IFRUUCBOZXR3b3JrMSIwIAYDVQQDExlBZGRUcnVzdCBFeHRlcm5hbCBDQSBSb290 MB4XDTAwMDUzMDEwNDgzOFoXDTIwMDUzMDEwNDgzOFowbzELMAkGA1UEBhMCU0Ux FDASBgNVBAoTC0FkZFRydXN0IEFCMSYwJAYDVQQLEx1BZGRUcnVzdCBFeHRlcm5h bCBUVFAgTmV0d29yazEiMCAGA1UEAxMZQWRkVHJ1c3QgRXh0ZXJuYWwgQ0EgUm9v dDCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBALf3GjPm8gAELTngTlvt H7xsD821+iO2zt6bETOXpClMfZOfvUq8k+0DGuOPz+VtUFrWlymUWoCwSXrbLpX9 uMq/NzgtHj6RQa1wVsfwTz/oMp50ysiQVOnGXw94nZpAPA6sYapeFI+eh6FqUNzX mk6vBbOmcZSccbNQYArHE504B4YCqOmoaSYYkKtMsE8jqzpPhNjfzp/haW+710LX a0Tkx63ubUFfclpxCDezeWWkWaCUN/cALw3CknLa0Dhy2xSoRcRdKn23tNbE7qzN E0S3ySvdQwAl+mG5aWpYIxG3pzOPVnVZ9c0p10a3CitlttNCbxWyuHv77+ldU9U0 WicCAwEAAaOB3DCB2TAdBgNVHQ4EFgQUrb2YejS0Jvf6xCZU7wO94CTLVBowCwYD VR0PBAQDAgEGMA8GA1UdEwEB/wQFMAMBAf8wgZkGA1UdIwSBkTCBjoAUrb2YejS0 Jvf6xCZU7wO94CTLVBqhc6RxMG8xCzAJBgNVBAYTAlNFMRQwEgYDVQQKEwtBZGRU cnVzdCBBQjEmMCQGA1UECxMdQWRkVHJ1c3QgRXh0ZXJuYWwgVFRQIE5ldHdvcmsx IjAgBgNVBAMTGUFkZFRydXN0IEV4dGVybmFsIENBIFJvb3SCAQEwDQYJKoZIhvcN AQEFBQADggEBALCb4IUlwtYj4g+WBpKdQZic2YR5gdkeWxQHIzZlj7DYd7usQWxH YINRsPkyPef89iYTx4AWpb9a/IfPeHmJIZriTAcKhjW88t5RxNKWt9x+Tu5w/Rw5 6wwCURQtjr0W4MHfRnXnJK3s9EK0hZNwEGe6nQY1ShjTK3rMUUKhemPR5ruhxSvC Nr4TDea9Y355e6cJDUCrat2PisP29owaQgVR1EX1n6diIWgVIEM8med8vSTYqZEX c4g/VhsxOBi0cQ+azcgOno4uG+GMmIPLHzHxREzGBHNJdmAPx/i9F4BrLunMTA5a mnkPIAou1Z5jJh5VkpTYghdae9C8x49OhgQ= -----END CERTIFICATE----- [root@centos7 cloudflare]# openssl x509 -in /var/tmp/cloudflare/addtrust.pem -pubkey | openssl pkey -pubin -outform der | openssl dgst -sha256 -binary | base64 lCppFqbkrlJ3EcVFAkeip0+44VaoJUymbnOaEUk7tEU= [root@centos7 cloudflare]# wget --quiet -O globalsign.pem https://www.crt.sh/?d=88 [root@centos7 cloudflare]# cat globalsign.pem -----BEGIN CERTIFICATE----- MIIDdTCCAl2gAwIBAgILBAAAAAABFUtaw5QwDQYJKoZIhvcNAQEFBQA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9TU/Qr6cf9tveCX4XSQRjbgbME HMUfpIBvFSDJ3gyICh3WZlXi/EjJKSZp4A== -----END CERTIFICATE----- [root@centos7 cloudflare]# openssl x509 -in /var/tmp/cloudflare/globalsign.pem -pubkey | openssl pkey -pubin -outform der | openssl dgst -sha256 -binary | base64 K87oWBWM9UZfyddvDfoxL+8lpNyoUB2ptGtn0fv6G2Q= # CloudFlare Dedicated Certificates are signed by DigiCert # https://www.crt.sh/?d=76 [root@centos7 cloudflare]# wget --quiet -O digicert.pem https://www.crt.sh/?d=76 [root@centos7 cloudflare]# cat digicert.pem -----BEGIN CERTIFICATE----- MIIDdzCCAl+gAwIBAgIEAgAAuTANBgkqhkiG9w0BAQUFADBaMQswCQYDVQQGEwJJ RTESMBAGA1UEChMJQmFsdGltb3JlMRMwEQYDVQQLEwpDeWJlclRydXN0MSIwIAYD VQQDExlCYWx0aW1vcmUgQ3liZXJUcnVzdCBSb290MB4XDTAwMDUxMjE4NDYwMFoX DTI1MDUxMjIzNTkwMFowWjELMAkGA1UEBhMCSUUxEjAQBgNVBAoTCUJhbHRpbW9y ZTETMBEGA1UECxMKQ3liZXJUcnVzdDEiMCAGA1UEAxMZQmFsdGltb3JlIEN5YmVy VHJ1c3QgUm9vdDCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAKMEuyKr mD1X6CZymrV51Cni4eiVgLGw41uOKymaZN+hXe2wCQVt2yguzmKiYv60iNoS6zjr IZ3AQSsBUnuId9Mcj8e6uYi1agnnc+gRQKfRzMpijS3ljwumUNKoUMMo6vWrJYeK mpYcqWe4PwzV9/lSEy/CG9VwcPCPwBLKBsua4dnKM3p31vjsufFoREJIE9LAwqSu XmD+tqYF/LTdB1kC1FkYmGP1pWPgkAx9XbIGevOF6uvUA65ehD5f/xXtabz5OTZy dc93Uk3zyZAsuT3lySNTPx8kmCFcB5kpvcY67Oduhjprl3RjM71oGDHweI12v/ye jl0qhqdNkNwnGjkCAwEAAaNFMEMwHQYDVR0OBBYEFOWdWTCCR1jMrPoIVDaGezq1 BE3wMBIGA1UdEwEB/wQIMAYBAf8CAQMwDgYDVR0PAQH/BAQDAgEGMA0GCSqGSIb3 DQEBBQUAA4IBAQCFDF2O5G9RaEIFoN27TyclhAO992T9Ldcw46QQF+vaKSm2eT92 9hkTI7gQCvlYpNRhcL0EYWoSihfVCr3FvDB81ukMJY2GQE/szKN+OMY3EU/t3Wgx jkzSswF07r51XgdIGn9w/xZchMB5hbgF/X++ZRGjD8ACtPhSNzkE1akxehi/oCr0 Epn3o0WC4zxe9Z2etciefC7IpJ5OCBRLbf1wbWsaY71k5h+3zvDyny67G7fyUIhz ksLi4xaNmjICq44Y3ekQEe5+NauQrz4wlHrQMz2nZQ/1/I6eYs9HRCwBXbsdtTLS R9I4LtD+gdwyah617jzV/OeBHRnDJELqYzmp -----END CERTIFICATE----- [root@centos7 cloudflare]# openssl x509 -in /var/tmp/cloudflare/digicert.pem -pubkey | openssl pkey -pubin -outform der | openssl dgst -sha256 -binary | base64 Y9mvm0exBk1JoQ57f9Vm28jKo5lFm/woKcVxrYxu80o= # GTE CyberTrust was acquired by DigiCert [root@centos7 cloudflare]# wget --quiet -O gtecybertrust.pem https://www.crt.sh/?d=10 [root@centos7 cloudflare]# cat gtecybertrust.pem -----BEGIN CERTIFICATE----- MIICWjCCAcMCAgGlMA0GCSqGSIb3DQEBBAUAMHUxCzAJBgNVBAYTAlVTMRgwFgYD VQQKEw9HVEUgQ29ycG9yYXRpb24xJzAlBgNVBAsTHkdURSBDeWJlclRydXN0IFNv bHV0aW9ucywgSW5jLjEjMCEGA1UEAxMaR1RFIEN5YmVyVHJ1c3QgR2xvYmFsIFJv b3QwHhcNOTgwODEzMDAyOTAwWhcNMTgwODEzMjM1OTAwWjB1MQswCQYDVQQGEwJV UzEYMBYGA1UEChMPR1RFIENvcnBvcmF0aW9uMScwJQYDVQQLEx5HVEUgQ3liZXJU cnVzdCBTb2x1dGlvbnMsIEluYy4xIzAhBgNVBAMTGkdURSBDeWJlclRydXN0IEds b2JhbCBSb290MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCVD6C28FCc6HrH iM3dFw4usJTQGz0O9pTAipTHBsiQl8i4ZBp6fmw8U+E3KHNgf7KXUwefU/ltWJTS r41tiGeA5u2ylc9yMcqlHHK6XALnZELn+aks1joNrI1CqiQBOeacPwGFVw1Yh0X4 04Wqk2kmhXBIgD8SFcd5tB8FLztimQIDAQABMA0GCSqGSIb3DQEBBAUAA4GBAG3r GwnpXtlR22ciYaQqPEh346B8pt5zohQDhT37qw4wxYMWM4ETCJ57NE7fQMh017l9 3PR2VX2bY1QY6fDq81yx2YtCHrnAlU66+tXifPVoYb+O7AWXX1uw16OFNMQkpw0P lZPvy5TYnh+dXIVtx6quTx8itc2VrbqnzPmrC3p/ -----END CERTIFICATE----- [root@centos7 cloudflare]# openssl x509 -in /var/tmp/cloudflare/gtecybertrust.pem -pubkey | openssl pkey -pubin -outform der | openssl dgst -sha256 -binary | base64 EGn6R6CqT4z3ERscrqNl7q7RC//zJmDe9uBhS/rnCHU= ################################################################# # pin ssl.com root CA certs if Let's Encrypt disappears one day # ################################################################# # https://www.ssl.com/repository/ [root@centos7 cloudflare]# mkdir /var/tmp/ssl.com [root@centos7 cloudflare]# cd /var/tmp/ssl.com [root@centos7 ssl.com]# wget --quiet https://www.ssl.com/repository/SSLcom-RootCA.zip [root@centos7 ssl.com]# unzip SSLcom-RootCA.zip Archive: SSLcom-RootCA.zip inflating: SSLcom-RootCA-EV-RSA-4096-R2.pem inflating: SSLcomEVRootCertificationAuthorityECC.pem inflating: SSLcomRootCertificationAuthorityECC.pem inflating: SSLcomRootCertificationAuthorityRSA.pem [root@centos7 ssl.com]# cat SSLcom-RootCA-EV-RSA-4096-R2.pem Subject: CN=SSL.com EV Root Certification Authority RSA R2,O=SSL Corporation,L=Houston,ST=Texas,C=US Issuer: CN=SSL.com EV Root Certification Authority RSA R2,O=SSL Corporation,L=Houston,ST=Texas,C=US -----BEG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CLg+SlmJuwgUHfbSguPvuUCYHBBXtSu UDkiFCbLsjtzdFVHB3mBOagwE0TlBIqulhMlQg+5U8Sb/M3kHN48+qvWBkofZ6aY MBzdLNvcGJVXZsb/XItW9XcCAwEAAaNjMGEwDwYDVR0TAQH/BAUwAwEB/zAfBgNV HSMEGDAWgBT5YLvU49U09rj1BoAlp3PbRmmonjAdBgNVHQ4EFgQU+WC71OPVNPa4 9QaAJadz20ZpqJ4wDgYDVR0PAQH/BAQDAgGGMA0GCSqGSIb3DQEBCwUAA4ICAQBW s47LCp1Jjr+kxJG7ZhcFUZh1++VQLHqe8RT6q9OKPv+RKY9ji9i0qVQBDb6Thi/5 Sm3HXvVX+cpVHBK+Rw82xd9qt9t1wkclf7nxY/hoLVUE0fKNsKTPvDxeH3jnpaAg cLAExbf3cqfeIg29MyVGjGSSJuM+LmOW2puMPfgYCdcDzH2GguDKBAdRUNf/ktUM 79qGn5nX67evaOI5JpS6aLe/g9Pqemc9YmeuJeVy6OLk7K4S9ksrPJ/psEDzOFSz /bdoyNrGj1E8svuR3Bznm53htw1yj+KkxKl4+esUrMZDBcJlOSgYAsOCsp0FvmXt ll9ldDz7CTUue5wT/RsPXcdtgTpWD8w74a8CLyKsRspGPKAcTNZEtF4uXBVmCeEm Kf7GUmG6sXP/wwyc5WxqlD8UykAWlYTzWamsX0xhk23RO8yilQwipmdnRC652dKK QbNmC1r7fSOl8hqw/96bg5Qu0T/fkreRrwU7ZcegbLHNYhLDkBvjJc40vG93drEQ w/cFGsDWr3RiSBd3kmmQYRzelYB0VI8YHMPzA9C/pEN1hlMYegouCRw2n5H9gooi S9EOUCXdywMMF8mDAAhONU2Ki+3wApRmLER/y5UnlhetCTCstnEXbosX9hwJ1C07 mKVx01QT2WDz9UtmT/rx7iASjbSsV7FFY6GsdqnC+w== -----END CERTIFICATE----- [root@centos7 ssl.com]# cat SSLcomEVRootCertificationAuthorityECC.pem -----BEGIN CERTIFICATE----- MIIClDCCAhqgAwIBAgIILCmcW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A1UdDwEB/wQEAwIBhjANBgkqhkiG9w0BAQsFAAOCAgEAIBgRlCn7Jp0cHh5wYfGV cpNxJK1ok1iOMq8bs3AD/CUrdIWQPXhq9LmLpZc7tRiRux6n+UBbkflVma8eEdBc Hadm47GUBwwyOabqG7B52B2ccETjit3E+ZUfijhDPwGFpUenPUayvOUiaPd7nNgs PgohyC0zrL/FgZkxdMF1ccW+sfAjRfSda/wZY52jvATGGAslu1OJD7OAUN5F7kR/ q5R4ZJjT9ijdh9hwZXT7DrkT66cPYakylszeu+1jTBi7qUD3oFRuIIhxdRjqerQ0 cuAjJ3dctpDqhiVAq+8zD8ufgr6iIPv2tS0a5sKFsXQP+8hlAqRSAUfdSSLBv9jr a6x+3uxjMxW3IwiPxg+NQVrdjsW5j+VFP3jbutIbQLH+cU0/4IGiul607BXgk90I H37hVZkLId6Tngr75qNJvTYw/ud3sqB1l7UtgYgXZSD32pAAn8lSzDLKNXz1PQ/Y K9f1JmzJBjSWFupwWRoyeXkLtoh/D1JIPb9s2KJELtFOt3JY04kTlf5Eq/jXixtu nLwsoFvVagCvXzfh1foQC5ichucmj87w7G6KVwuA406ywKBjYZC6VWg3dGq2ktuf oYYitmUnDuy2n0Jg5GfCtdpBC8TTi2EbvPofkSvXRAdeuims2cXp71NIWuuA8ShY Ic2wBlX7Jz9TkHCpBB5XJ7k= -----END CERTIFICATE----- [root@centos7 ssl.com]# for file in $(ls *.pem); do echo /var/tmp/ssl.com/$file; openssl x509 -in /var/tmp/ssl.com/$file -pubkey | openssl pkey -pubin -outform der | openssl dgst -sha256 -binary | base64; done /var/tmp/ssl.com/SSLcomEVRootCertificationAuthorityECC.pem NIdnza073SiyuN1TUa7DDGjOxc1p0nbfOCfbxPWAZGQ= /var/tmp/ssl.com/SSLcom-RootCA-EV-RSA-4096-R2.pem fNZ8JI9p2D/C+bsB3LH3rWejY9BGBDeW0JhMOiMfa7A= /var/tmp/ssl.com/SSLcomRootCertificationAuthorityECC.pem oyD01TTXvpfBro3QSZc1vIlcMjrdLTiL/M9mLCPX+Zo= /var/tmp/ssl.com/SSLcomRootCertificationAuthorityRSA.pem 0cRTd+vc1hjNFlHcLgLCHXUeWqn80bNDH/bs9qMTSPo=
Put it all together
Extracting just the public key pins from above, that gives us 14 hashes:
UbSbHFsFhuCrSv9GNsqnGv4CbaVh5UV5/zzgjLgHh9c= YLh1dUR9y6Kja30RrAn7JKnbQG/uEtLMkBgFF2Fuihg= C5+lpZ7tcVwmwQIMcRtPbsQtWLABXhQzejna0wHFr8M= Vjs8r4z+80wjNcr1YKepWQboSIRi63WsWXhIMN+eWys= lCppFqbkrlJ3EcVFAkeip0+44VaoJUymbnOaEUk7tEU= K87oWBWM9UZfyddvDfoxL+8lpNyoUB2ptGtn0fv6G2Q= Y9mvm0exBk1JoQ57f9Vm28jKo5lFm/woKcVxrYxu80o= EGn6R6CqT4z3ERscrqNl7q7RC//zJmDe9uBhS/rnCHU= NIdnza073SiyuN1TUa7DDGjOxc1p0nbfOCfbxPWAZGQ= fNZ8JI9p2D/C+bsB3LH3rWejY9BGBDeW0JhMOiMfa7A= oyD01TTXvpfBro3QSZc1vIlcMjrdLTiL/M9mLCPX+Zo= 0cRTd+vc1hjNFlHcLgLCHXUeWqn80bNDH/bs9qMTSPo= MDhNnV1cmaPdDDONbiVionUHH2QIf2aHJwq/lshMWfA= OIZP7FgTBf7hUpWHIA7OaPVO2WrsGzTl9vdOHLPZmJU=
We’ll use these in our web server config below.
Add to Webserver config
To enable HPKP with the backup public key pins calculated above, add the following to your cooresponding web server’s configuration file & reload your web server.
Be sure to test this on a disposable domain first. After you’ve validated everything (I’d wait 6 months–or through a few Let’s Encrypt certificate renewals at least), you should consider increasing the “max-age” to something like 6 months = “15552001” seconds.
Note that you should change the “report-uri” argument as needed to your domain. This can be very useful in troubleshooting issues with client-side HPKP issues which would otherwise be invisible to a System Administrator.
Apache
If you’re using apache, you need to add this line to your <VirtualHost> block.
Header set Public-Key-Pins "pin-sha256=\"UbSbHFsFhuCrSv9GNsqnGv4CbaVh5UV5/zzgjLgHh9c=\"; pin-sha256=\"YLh1dUR9y6Kja30RrAn7JKnbQG/uEtLMkBgFF2Fuihg=\"; pin-sha256=\"C5+lpZ7tcVwmwQIMcRtPbsQtWLABXhQzejna0wHFr8M=\"; pin-sha256=\"Vjs8r4z+80wjNcr1YKepWQboSIRi63WsWXhIMN+eWys=\"; pin-sha256=\"lCppFqbkrlJ3EcVFAkeip0+44VaoJUymbnOaEUk7tEU=\"; pin-sha256=\"K87oWBWM9UZfyddvDfoxL+8lpNyoUB2ptGtn0fv6G2Q=\"; pin-sha256=\"Y9mvm0exBk1JoQ57f9Vm28jKo5lFm/woKcVxrYxu80o=\"; pin-sha256=\"EGn6R6CqT4z3ERscrqNl7q7RC//zJmDe9uBhS/rnCHU=\"; pin-sha256=\"NIdnza073SiyuN1TUa7DDGjOxc1p0nbfOCfbxPWAZGQ=\"; pin-sha256=\"fNZ8JI9p2D/C+bsB3LH3rWejY9BGBDeW0JhMOiMfa7A=\"; pin-sha256=\"oyD01TTXvpfBro3QSZc1vIlcMjrdLTiL/M9mLCPX+Zo=\"; pin-sha256=\"0cRTd+vc1hjNFlHcLgLCHXUeWqn80bNDH/bs9qMTSPo=\"; pin-sha256=\"MDhNnV1cmaPdDDONbiVionUHH2QIf2aHJwq/lshMWfA=\"; pin-sha256=\"OIZP7FgTBf7hUpWHIA7OaPVO2WrsGzTl9vdOHLPZmJU=\"; max-age=3600; includeSubDomains; report-uri=\"http://opensourceecology.org/hpkp-report\""
Nginx
If you’re using nginx, you need to add this line to your http{ } block.
add_header Public-Key-Pins 'pin-sha256="UbSbHFsFhuCrSv9GNsqnGv4CbaVh5UV5/zzgjLgHh9c="; pin-sha256="YLh1dUR9y6Kja30RrAn7JKnbQG/uEtLMkBgFF2Fuihg="; pin-sha256="C5+lpZ7tcVwmwQIMcRtPbsQtWLABXhQzejna0wHFr8M="; pin-sha256="Vjs8r4z+80wjNcr1YKepWQboSIRi63WsWXhIMN+eWys="; pin-sha256="lCppFqbkrlJ3EcVFAkeip0+44VaoJUymbnOaEUk7tEU="; pin-sha256="K87oWBWM9UZfyddvDfoxL+8lpNyoUB2ptGtn0fv6G2Q="; pin-sha256="Y9mvm0exBk1JoQ57f9Vm28jKo5lFm/woKcVxrYxu80o="; pin-sha256="EGn6R6CqT4z3ERscrqNl7q7RC//zJmDe9uBhS/rnCHU="; pin-sha256="NIdnza073SiyuN1TUa7DDGjOxc1p0nbfOCfbxPWAZGQ="; pin-sha256="fNZ8JI9p2D/C+bsB3LH3rWejY9BGBDeW0JhMOiMfa7A="; pin-sha256="oyD01TTXvpfBro3QSZc1vIlcMjrdLTiL/M9mLCPX+Zo="; pin-sha256="0cRTd+vc1hjNFlHcLgLCHXUeWqn80bNDH/bs9qMTSPo="; pin-sha256="MDhNnV1cmaPdDDONbiVionUHH2QIf2aHJwq/lshMWfA="; pin-sha256="OIZP7FgTBf7hUpWHIA7OaPVO2WrsGzTl9vdOHLPZmJU="; max-age=5256000; includeSubDomains'; report-uri="http://opensourceecology.org/hpkp-report"
Conclusion
HPKP can be dangerous if deployed incorrectly, but–if done properly–it can be a valuable way to reduce the risk of MITM attacks.
In this guide, we certainly pinned a large number of certificates, including many root CA’s certificates. With each pin, we increase the MITM attack surface area, but we also reduce the risk of “bricking” a domain.
I think the approach shown here is the best middleground for risk & security that applies to most SysAdmins using Let’s Encrypt on their webservers today.
Further Reading
If you like using TOFU to further lock-down https on your websites, you would probably also be interested in HSTS & CAA:
Related Posts
Hi, I’m Michael Altfield. I write articles about opsec, privacy, and devops ➡
You said that HPKP can be dangerous if deployed incorrectly, which is so true.
What I am curious about is to know if you think that HPKP is worth the effort considering what little benefit it actually provides.
In my opinion, there is little gain in security by using HPKP, but you add a hell of a lot of risk to your service if you decide to use it.
I picture it like putting an explosive device on a hair trigger in order to protect against the risk that zombies from the Resident Evil will set up a lemonade stand in front of your fast food chain franchise. Isn’t it an overkill solution to an extremely unlikely threat? I’d like to know your opinion.
@Tomas Thanks for your question [and for publishing your own awesome blog 🙂 ]. I think you have to weigh the pros & cons. Your position definitely has valid concerns, and is generally accepted by many website administrators.
Personally, I do think the pros outweigh the cons of using HPKP when you follow the above best-practices guide.
The breadth of CAs whitelisted by popular browsers today is dangerous. If we use HPKP to limit this whiltelist to only a few popular & trusted CA’s root certificates, then we’ll be safely able to generate a new cert for our site in the future–signed by one of these CAs. While I think this pinning is more broad than what HPKP was probably intended for, I think it’s the best middle-ground to gaining the benefits of HPKP without the dangers of pinning only a few of our own pre-generated certs.
In fact, as a customer, I’d greatly appreciate if the websites I send sensitive data to (CCNs, SSNs, or any PII really) would implement HPKP. I don’t think it’s an “extremely unlikely” threat that someone might use a rogue “trusted” CA in the browser’s whitelist to MITM an https connection. We have countless examples (Comodo, d-link, eDellroot, Startcom, Diginotar, MCS Holdings, etc) of such rogue CAs in the past, and I’m confident that there are still trusted CAs in that whilteist that are in the hands of someone wishing to preform malicious deeds.
Rather than relying on the Browser’s reactive game of whack-a-mole, why not just explicitly limit the whitelist for your site to a few redundant, trusted CAs using HPKP? That seems like the best middle-ground to me.
[…] X-XSS-Protection, CSP, HSTS, and HPKP […]