##// END OF EJS Templates
sslutil: print a warning when using TLS 1.0 on legacy Python...
sslutil: print a warning when using TLS 1.0 on legacy Python Mercurial now requires TLS 1.1+ when TLS 1.1+ is supported by the client. Since we made the decision to require TLS 1.1+ when running with modern Python versions, it makes sense to do something for legacy Python versions that only support TLS 1.0. Feature parity would be to prevent TLS 1.0 connections out of the box and require a config option to enable them. However, this is extremely user hostile since Mercurial wouldn't talk to https:// by default in these installations! I can easily see how someone would do something foolish like use "--insecure" instead - and that would be worse than allowing TLS 1.0! This patch takes the compromise position of printing a warning when performing TLS 1.0 connections when running on old Python versions. While this warning is no more annoying than the CA certificate / fingerprint warnings in Mercurial 3.8, we provide a config option to disable the warning because to many people upgrading Python to make the warning go away is not an available recourse (unlike pinning fingerprints is for the CA warning). The warning appears as optional output in a lot of tests.
Gregory Szorc -
r29561:1a782fab default
Show More
Name Size Modified Last Commit Author
/ tests / sslcerts
README Loading ...
client-cert.pem Loading ...
client-key-decrypted.pem Loading ...
client-key.pem Loading ...
priv.pem Loading ...
pub-expired.pem Loading ...
pub-not-yet.pem Loading ...
pub-other.pem Loading ...
pub.pem Loading ...

Generate a private key (priv.pem):

$ openssl genrsa -out priv.pem 2048

Generate 2 self-signed certificates from this key (pub.pem, pub-other.pem):

$ printf '.\n.\n.\n.\n.\nlocalhost\nhg@localhost\n' | \
openssl req -new -x509 -key priv.pem -nodes -sha256 -days 9000 -out pub.pem

$ printf '.\n.\n.\n.\n.\nlocalhost\nhg@localhost\n' | \
openssl req -new -x509 -key priv.pem -nodes -sha256 -days 9000 -out pub-other.pem

Now generate an expired certificate by turning back the system time:

$ date --set='2016-01-01T00:00:00Z'
$ printf '.\n.\n.\n.\n.\nlocalhost\nhg@localhost\n' | \
openssl req -new -x509 -key priv.pem -nodes -sha256 -days 1 -out pub-expired.pem

Generate a certificate not yet active by advancing the system time:

$ date --set='2030-01-01T00:00:00Z'
$ printf '.\n.\n.\n.\n.\nlocalhost\nhg@localhost\n' | \
openssl req -new -x509 -key priv.pem -nodes -sha256 -days 1 -out pub-not-yet.pem

Note: When adjusting system time, verify the time change sticks. If running
systemd, you may want to use `timedatectl set-ntp false` and e.g.
`timedatectl set-time '2016-01-01 00:00:00'` to set system time.

Generate a passphrase protected client certificate private key:

$ openssl genrsa -aes256 -passout pass:1234 -out client-key.pem 2048

Create a copy of the private key without a passphrase:

$ openssl rsa -in client-key.pem -passin pass:1234 -out client-key-decrypted.pem

Create a CSR and sign the key using the server keypair:

$ printf '.\n.\n.\n.\n.\n.\nhg-client@localhost\n.\n.\n' | \
openssl req -new -key client-key.pem -passin pass:1234 -out client-csr.pem
$ openssl x509 -req -days 9000 -in client-csr.pem -CA pub.pem -CAkey priv.pem \
-set_serial 01 -out client-cert.pem

When replacing the certificates, references to certificate fingerprints will
need to be updated in test files.

Fingerprints for certs can be obtained by running:

$ openssl x509 -in pub.pem -noout -sha1 -fingerprint
$ openssl x509 -in pub.pem -noout -sha256 -fingerprint