Skip to content

Commit f97011d

Browse files
committed
doc: Import cdn-cert.md documentation
Imported with minor changes, from private infra repo at <https://github.com/jquery/infrastructure/blob/1f8c332e728b9d150b42cf27de84c122c2631142/modules/jquery/files/cert/README.md>
1 parent f96ee05 commit f97011d

File tree

3 files changed

+130
-0
lines changed

3 files changed

+130
-0
lines changed

bin/decrypt_cert_key.sh

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/bin/bash
2+
3+
# SPDX-License-Identifier: MIT
4+
# Copyright 2022 Timo Tijhof
5+
#
6+
# Save the decrypted form of a private key provided by the issuer.
7+
# This will prompt for an encryption password.
8+
#
9+
10+
set -eu
11+
12+
if [ "$#" -ne 2 ]; then
13+
echo "Usage: ./decrypt_cert_key.sh encrypted_input.key plaintext_output.key"
14+
exit
15+
fi
16+
17+
keyfilesrc=$1
18+
keyfiledest=$2
19+
20+
openssl pkcs8 -in "$keyfilesrc" -out "$keyfiledest"

bin/verify_cert.sh

+59
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
#!/bin/bash
2+
3+
# SPDX-License-Identifier: MIT
4+
# Copyright 2021 Brian Warner
5+
# Copyright 2023 Timo Tijhof
6+
#
7+
# Very basic utility to run checks on SSL certs prior to deployment.
8+
#
9+
# Usage: ./verify_certs.sh <path to star.jquery.com.pem>
10+
#
11+
# certname.pem: This is the PEM file created from concatenating the .crt with the .ca-bundle
12+
# certname.key: This is the private key provided by the issuer
13+
# certname.ca-bundle: These are the intermediate certs provided by the issuer
14+
#
15+
16+
if [ "$#" -ne 1 ]; then
17+
echo "Usage: ./verify_certs.sh <path to star.jquery.com.pem>"
18+
exit
19+
fi
20+
21+
pemfilename="$1"
22+
keyfilename="${1%.pem}.key"
23+
cabundlefilename="${1%.pem}.ca-bundle"
24+
if [ ! -f "$pemfilename" ]; then
25+
echo -e "Error: Could not find $pemfilename"
26+
exit 1
27+
fi
28+
if [ ! -f "$keyfilename" ]; then
29+
echo -e "Error: Could not find $keyfilename"
30+
exit 1
31+
fi
32+
if [ ! -f "$cabundlefilename" ]; then
33+
echo -e "Error: Could not find $cabundlefilename"
34+
exit 1
35+
fi
36+
37+
bold=$(tput bold)
38+
normal=$(tput sgr0)
39+
40+
echo -e "\n${bold}Dates the cert is valid (expect today to be within this range):${normal}"
41+
openssl x509 -noout -dates -in "$pemfilename"
42+
43+
echo -e "\n${bold}Verifying validity of the certificate chain (expect \"OK\"):${normal}"
44+
openssl verify -CAfile "$cabundlefilename" "$pemfilename"
45+
46+
echo -e "\n${bold}Verify the public keys match (expect \"Keys match\"):${normal}"
47+
pemkey=`openssl x509 -noout -pubkey -in "$pemfilename"`
48+
pubkey=`openssl rsa -pubout -in "$keyfilename" 2>/dev/null`
49+
keydiff=`diff <(echo $pemkey) <(echo $pubkey)`
50+
51+
if [ ${#keydiff} -eq 0 ]; then
52+
echo -e "Keys match"
53+
else
54+
echo -e "\033[0;31mKeys do not match, check you have the correct .key and .pem files.\033[0;37m"
55+
fi
56+
57+
echo -e "\n${bold}Verify the PEM file is in the right order (expect issuer to match next subject)${normal}"
58+
openssl crl2pkcs7 -nocrl -certfile "$pemfilename" | openssl pkcs7 -print_certs -noout
59+

doc/cdn-cert.md

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# jQuery CDN: TLS Certificate
2+
3+
Every year we need to renew the TLS certificate used by the jQuery CDN. Linux Foundation IT provisions these as needed.
4+
5+
## Process to obtain new certificate
6+
7+
1. Create a ticket with LF IT under "Project Support Services" <https://support.linuxfoundation.org>.
8+
9+
LF IT purchases a 3-year certificate and mints a 1-year certificate for us to use. They share the `.crt` and `.ca-bundle` files via email, and share the private key via 1Password.
10+
2. The `.crt` and `.ca-bundle` file for each domain needs to be converted to `.pem` format by concatenating them with the `.crt` file first.
11+
* `cat __jquery_com.crt __jquery_com.ca-bundle > star.jquery.com.pem`
12+
* The `.crt` file may not have an EOL character, so open `star.jquery.com.pem` and make sure that all block terminators look like this (i.e., not on one line, and no blank lines between):
13+
```
14+
-----END CERTIFICATE-----
15+
-----BEGIN CERTIFICATE-----
16+
```
17+
3. Copy the contents of the private key (shared via 1Password) into a file called `star.jquery.com.key`
18+
4. **Test it!** by running `bin/verify_cert.sh path/to/your/star.jquery.com.pem`
19+
20+
Note that if the `.key` file contains `ENCRYPTED` (that is, if `verify_cert.sh` causes openssl to prompt you for a password), then **convert this to plaintext first** via `bin/decrypt_cert_key.sh`, so that the file can be safely used by a webserver.
21+
22+
## Example ticket
23+
24+
> Project: Open JS Foundation
25+
> Services: DNS management, Domain ownership
26+
>
27+
> The wildcart cert for jquery.com, as used for the jQuery CDN at code.jquery.com is expiring soon on ….
28+
>
29+
> We ideally take a few days to test it first, and after that I can upload it to Fastly (at least 48 hours after issuing, which ensures the a majority of browser clients that suffer clockskew, will accept the new certificate).
30+
>
31+
> Our current one was issued in … by ….
32+
>
33+
> Thanks!
34+
35+
## Process to deploy new certificate
36+
37+
When in doubt, refer to a recent issue that documents what we actually did.
38+
Renewal in 2023: https://github.com/jquery/infrastructure-puppet/issues/21
39+
40+
1. **Upload**. After obtaining and locally **testing** the new certificate in the above process,
41+
upload it to Fastly management as new unused certificate.
42+
2. Enable for a **secondary service** at Fastly, such as "miscweb" (podcast.jquery.com) or "code2".
43+
3. **Verify**. In a browser of your choice, verify that when viewing a page on the secondary domain, that the browser is in fact using our new certificate. Check the expiry date to confirm this.
44+
4. **Test cross-browser**. Once you've confirmed that the new cert is deployed and used, it's time to test it across a wide range of browsers. Especially old browsers that don't support certain kinds of TLS versions or cipher suites. You can use BrowserStack to go through old Windows and IE versions until you encounter a failure. Then confirm that there are no old browsers that fail on the new certificate, unless that same browser also already fails to open https://releases.jquery.com. Confirm that the old/new domain are both browseable over plain HTTP without issue/redirect.
45+
5. **Wait 48 hours** before deploying the new cert to our primary services. This is to account for clockskew on real devices. Certificates will be considered invalid by browsers if their local system clock says the new certificate's begin date ("Not before") has not yet started. Learn more about why at https://phabricator.wikimedia.org/T196248.
46+
6. Enable the new cert for all services.
47+
7. **Delete your unencrypted** star.jquery.com.key file from your workstation.
48+
49+
## Fastly docs
50+
51+
https://docs.fastly.com/en/guides/setting-up-tls-with-your-own-certificates

0 commit comments

Comments
 (0)