|
|
71928b |
From 412ccf4c6f8c417006c0a93392a8274a425074c0 Mon Sep 17 00:00:00 2001
|
|
|
71928b |
From: Victor Stinner <vstinner@redhat.com>
|
|
|
71928b |
Date: Wed, 29 May 2019 04:04:54 +0200
|
|
|
71928b |
Subject: [PATCH 1/5] bpo-32947: test_ssl fixes for TLS 1.3 and OpenSSL 1.1.1
|
|
|
71928b |
(GH-11612)
|
|
|
71928b |
|
|
|
71928b |
Backport partially commit 529525fb5a8fd9b96ab4021311a598c77588b918:
|
|
|
71928b |
complete the previous partial backport (commit
|
|
|
71928b |
2a4ee8aa01d61b6a9c8e9c65c211e61bdb471826.
|
|
|
71928b |
|
|
|
71928b |
Co-Authored-By: Christian Heimes <christian@python.org>
|
|
|
71928b |
---
|
|
|
71928b |
Lib/test/test_ssl.py | 15 +++++++++++++++
|
|
|
71928b |
.../2019-01-18-17-46-10.bpo-32947.Hk0KnM.rst | 1 +
|
|
|
71928b |
2 files changed, 16 insertions(+)
|
|
|
71928b |
create mode 100644 Misc/NEWS.d/next/Tests/2019-01-18-17-46-10.bpo-32947.Hk0KnM.rst
|
|
|
71928b |
|
|
|
71928b |
diff --git a/Lib/test/test_ssl.py b/Lib/test/test_ssl.py
|
|
|
71928b |
index cb0acda..639109f 100644
|
|
|
71928b |
--- a/Lib/test/test_ssl.py
|
|
|
71928b |
+++ b/Lib/test/test_ssl.py
|
|
|
71928b |
@@ -2043,6 +2043,16 @@ if _have_threads:
|
|
|
71928b |
sys.stdout.write(" server: read %r (%s), sending back %r (%s)...\n"
|
|
|
71928b |
% (msg, ctype, msg.lower(), ctype))
|
|
|
71928b |
self.write(msg.lower())
|
|
|
71928b |
+ except ConnectionResetError:
|
|
|
71928b |
+ # XXX: OpenSSL 1.1.1 sometimes raises ConnectionResetError
|
|
|
71928b |
+ # when connection is not shut down gracefully.
|
|
|
71928b |
+ if self.server.chatty and support.verbose:
|
|
|
71928b |
+ sys.stdout.write(
|
|
|
71928b |
+ " Connection reset by peer: {}\n".format(
|
|
|
71928b |
+ self.addr)
|
|
|
71928b |
+ )
|
|
|
71928b |
+ self.close()
|
|
|
71928b |
+ self.running = False
|
|
|
71928b |
except OSError:
|
|
|
71928b |
if self.server.chatty:
|
|
|
71928b |
handle_error("Test server failure:\n")
|
|
|
71928b |
@@ -2122,6 +2132,11 @@ if _have_threads:
|
|
|
71928b |
pass
|
|
|
71928b |
except KeyboardInterrupt:
|
|
|
71928b |
self.stop()
|
|
|
71928b |
+ except BaseException as e:
|
|
|
71928b |
+ if support.verbose and self.chatty:
|
|
|
71928b |
+ sys.stdout.write(
|
|
|
71928b |
+ ' connection handling failed: ' + repr(e) + '\n')
|
|
|
71928b |
+
|
|
|
71928b |
self.sock.close()
|
|
|
71928b |
|
|
|
71928b |
def stop(self):
|
|
|
71928b |
diff --git a/Misc/NEWS.d/next/Tests/2019-01-18-17-46-10.bpo-32947.Hk0KnM.rst b/Misc/NEWS.d/next/Tests/2019-01-18-17-46-10.bpo-32947.Hk0KnM.rst
|
|
|
71928b |
new file mode 100644
|
|
|
71928b |
index 0000000..f508504
|
|
|
71928b |
--- /dev/null
|
|
|
71928b |
+++ b/Misc/NEWS.d/next/Tests/2019-01-18-17-46-10.bpo-32947.Hk0KnM.rst
|
|
|
71928b |
@@ -0,0 +1 @@
|
|
|
71928b |
+test_ssl fixes for TLS 1.3 and OpenSSL 1.1.1.
|
|
|
71928b |
--
|
|
|
71928b |
2.21.0
|
|
|
71928b |
|
|
|
71928b |
|
|
|
71928b |
From 6b728ec778067849dd1f0d9b73cf1ac47dafa270 Mon Sep 17 00:00:00 2001
|
|
|
71928b |
From: "Miss Islington (bot)"
|
|
|
71928b |
<31488909+miss-islington@users.noreply.github.com>
|
|
|
71928b |
Date: Wed, 25 Sep 2019 09:12:59 -0700
|
|
|
71928b |
Subject: [PATCH 2/5] bpo-38271: encrypt private key test files with AES256
|
|
|
71928b |
(GH-16385)
|
|
|
71928b |
|
|
|
71928b |
The private keys for test_ssl were encrypted with 3DES in traditional
|
|
|
71928b |
PKCSGH-5 format. 3DES and the digest algorithm of PKCSGH-5 are blocked by
|
|
|
71928b |
some strict crypto policies. Use PKCSGH-8 format with AES256 encryption
|
|
|
71928b |
instead.
|
|
|
71928b |
|
|
|
71928b |
Signed-off-by: Christian Heimes <christian@python.org>
|
|
|
71928b |
|
|
|
71928b |
https://bugs.python.org/issue38271
|
|
|
71928b |
|
|
|
71928b |
Automerge-Triggered-By: @tiran
|
|
|
71928b |
(cherry picked from commit bfd0c963d88f3df69489ee250655e2b8f3d235bd)
|
|
|
71928b |
|
|
|
71928b |
Co-authored-by: Christian Heimes <christian@python.org>
|
|
|
71928b |
---
|
|
|
71928b |
Lib/test/keycert.passwd.pem | 85 ++++++++++---------
|
|
|
71928b |
Lib/test/make_ssl_certs.py | 4 +-
|
|
|
71928b |
Lib/test/ssl_key.passwd.pem | 84 +++++++++---------
|
|
|
71928b |
.../2019-09-25-13-11-29.bpo-38271.iHXNIg.rst | 4 +
|
|
|
71928b |
4 files changed, 91 insertions(+), 86 deletions(-)
|
|
|
71928b |
create mode 100644 Misc/NEWS.d/next/Tests/2019-09-25-13-11-29.bpo-38271.iHXNIg.rst
|
|
|
71928b |
|
|
|
71928b |
diff --git a/Lib/test/keycert.passwd.pem b/Lib/test/keycert.passwd.pem
|
|
|
71928b |
index cbb3c3b..c330c36 100644
|
|
|
71928b |
--- a/Lib/test/keycert.passwd.pem
|
|
|
71928b |
+++ b/Lib/test/keycert.passwd.pem
|
|
|
71928b |
@@ -1,45 +1,45 @@
|
|
|
71928b |
------BEGIN RSA PRIVATE KEY-----
|
|
|
71928b |
-Proc-Type: 4,ENCRYPTED
|
|
|
71928b |
-DEK-Info: DES-EDE3-CBC,D134E931C96D9DEC
|
|
|
71928b |
-
|
|
|
71928b |
-nuGFEej7vIjkYWSMz5OJeVTNntDRQi6ZM4DBm3g8T7i/0odr3WFqGMMKZcIhLYQf
|
|
|
71928b |
-rgRq7RSKtrJ1y5taVucMV+EuCjyfzDo0TsYt+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xWFykouBwmd7bXooNYXmDRNmjTdVhKJuOEOQw8hDzx7e
|
|
|
71928b |
-pWFJ9Z/V4Qm1tvXbCD7QFqMCDoY3qFvVG8DBqXpmxe1yPfz21FWrT7IuqDXAD3ns
|
|
|
71928b |
-vxfN/2a+Cy04U9FBNVCvWqWIs5AgNpdCMJC2FlXKTy+H3/7rIjNyFyvbX0vxIXtK
|
|
|
71928b |
-liOVNXiyVM++KZXqktqMUDlsJENmIHV9B046luqbgW018fHkyEYlL3iRZGbYegwr
|
|
|
71928b |
-XO9VVIKVPw1BEvJ8VNdGFGuZGepd8qX2ezfYADrNR+4t85HDm8inbjTobSjWuljs
|
|
|
71928b |
-ftUNkOeCHqAvWCFQTLCfdykvV08EJfVY79y7yFPtfRV2gxYokXFifjo3su9sVQr1
|
|
|
71928b |
-UiIS5ZAsIC1hBXWeXoBN7QVTkFi7Yto6E1q2k10LiT3obpUUUQ/oclhrJOCJVjrS
|
|
|
71928b |
-oRcj2QBy8OT4T9slJr5maTWdgd7Lt6+I6cGQXPaDvjGOJl0eBYM14vhx4rRQWytJ
|
|
|
71928b |
-k07hhHFO4+9CGCuHS8AAy2gR6acYFWt2ZiiNZ0z/iPIHNK4YEyy9aLf6uZH/KQjE
|
|
|
71928b |
-jmHToo7XD6QvCAEC5qTHby3o3LfHIhyZi/4L+AhS4FKUHF6M0peeyYt4z3HaK2d2
|
|
|
71928b |
-N6mHLPdjwNjra7GOmcns4gzcrdfoF+R293KpPal4PjknvR3dZL4kKP/ougTAM5zv
|
|
|
71928b |
-qDIvRbkHzjP8ChTpoLcJsNVXykNcNkjcSi0GHtIpYjh6QX6P2uvR/S4+Bbb9p9rn
|
|
|
71928b |
-hIy/ovu9tWN2hiPxGPe6torF6BulAxsTYlDercC204AyzsrdA0pr6HBgJH9C6ML1
|
|
|
71928b |
-TchwodbFJqn9rSv91i1liusAGoOvE81AGBdrXY7LxfSNhYY1IK6yR/POJPTd53sA
|
|
|
71928b |
-uX2/j6Rtoksd/2BHPM6AUnI/2B9slhuzWX2aCtWLeuwvXDS6rYuTigaQmLkzTRfM
|
|
|
71928b |
-dlMI3s9KLXxgi5YVumUZleJWXwBNP7KiKajd+VTSD+7WAhyhM5FIG5wVOaxmy4G2
|
|
|
71928b |
-TyqZ/Ax9d2VEjTQHWvQlLPQ4Mp0EIz0aEl94K/S8CK8bJRH6+PRkar+dJi1xqlL+
|
|
|
71928b |
-BYb42At9mEJ8odLlFikvNi1+t7jqXk5jRi5C0xFKx3nTtzoH2zNUeuA3R6vSocVK
|
|
|
71928b |
-45jnze9IkKmxMlJ4loR5sgszdpDCD3kXqjtCcbMTmcrGyzJek3HSOTpiEORoTFOe
|
|
|
71928b |
-Rhg6jH5lm+QcC263oipojS0qEQcnsWJP2CylNYMYHR9O/9NQxT3o2lsRHqZTMELV
|
|
|
71928b |
-uQa/SFH+paQNbZOj8MRwPSqqiIxJFuLswKte1R+W7LKn1yBSM7Pp39lNbzGvJD2E
|
|
|
71928b |
-YRfnCwFpJ54voVAuQ4jXJvigCW2qeCjXlxeD6K2j4eGJEEOmIjIW1wjubyBY6OI3
|
|
|
71928b |
------END RSA PRIVATE KEY-----
|
|
|
71928b |
+-----BEGIN ENCRYPTED PRIVATE KEY-----
|
|
|
71928b |
+MIIHbTBXBgkqhkiG9w0BBQ0wSjApBgkqhkiG9w0BBQwwHAQIhD+rJdxqb6ECAggA
|
|
|
71928b |
+MAwGCCqGSIb3DQIJBQAwHQYJYIZIAWUDBAEqBBDTdyjCP3riOSUfxix4aXEvBIIH
|
|
|
71928b |
+ECGkbsFabrcFMZcplw5jHMaOlG7rYjUzwDJ80JM8uzbv2Jb8SvNlns2+xmnEvH/M
|
|
|
71928b |
+mNvRmnXmplbVjH3XBMK8o2Psnr2V/a0j7/pgqpRxHykG+koOY4gzdt3MAg8JPbS2
|
|
|
71928b |
+hymSl+Y5EpciO3xLfz4aFL1ZNqspQbO/TD13Ij7DUIy7xIRBMp4taoZCrP0cEBAZ
|
|
|
71928b |
++wgu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AMoukDBkqUdOj6jE0BlJQlHk5iwgnJlt
|
|
|
71928b |
+uEdkTjHZEjIUxWC6llPcAzaPNlmnD45AgfEW+Jn21IvutmJiQAz5lm9Z9PXaR0C8
|
|
|
71928b |
+hXB6owRY67C0YKQwXhoNf6xQun2xGBGYy5rPEEezX1S1tUH5GR/KW1Lh+FzFqHXI
|
|
|
71928b |
+ZEb5avfDqHKehGAjPON+Br7akuQ125M9LLjKuSyPaQzeeCAy356Xd7XzVwbPddbm
|
|
|
71928b |
+9S9WSPqzaPgh10chIHoNoC8HMd33dB5j9/Q6jrbU/oPlptu/GlorWblvJdcTuBGI
|
|
|
71928b |
+IVn45RFnkG8hCz0GJSNzW7+70YdESQbfJW79vssWMaiSjFE0pMyFXrFR5lBywBTx
|
|
|
71928b |
+PiGEUWtvrKG94X1TMlGUzDzDJOQNZ9dT94bonNe9pVmP5BP4/DzwwiWh6qrzWk6p
|
|
|
71928b |
+j8OE4cfCSh2WvHnhJbH7/N0v+JKjtxeIeJ16jx/K2oK5
|
|
|
71928b |
+-----END ENCRYPTED PRIVATE KEY-----
|
|
|
71928b |
-----BEGIN CERTIFICATE-----
|
|
|
71928b |
MIIEWTCCAsGgAwIBAgIJAJinz4jHSjLtMA0GCSqGSIb3DQEBCwUAMF8xCzAJBgNV
|
|
|
71928b |
BAYTAlhZMRcwFQYDVQQHDA5DYXN0bGUgQW50aHJheDEjMCEGA1UECgwaUHl0aG9u
|
|
|
71928b |
@@ -66,3 +66,4 @@ jMqTFlmO7kpf/jpCSmamp3/JSEE1BJKHwQ6Ql4nzRA2N1mnvWH7Zxcv043gkHeAu
|
|
|
71928b |
9Wc2uXpw9xF8itV4Uvcdr3dwqByvIqn7iI/gB+4l41e0u8OmH2MKOx4Nxlly5TNW
|
|
|
71928b |
HcVKQHyOeyvnINuBAQ==
|
|
|
71928b |
-----END CERTIFICATE-----
|
|
|
71928b |
+
|
|
|
71928b |
diff --git a/Lib/test/make_ssl_certs.py b/Lib/test/make_ssl_certs.py
|
|
|
71928b |
index 3622765..41b5f46 100644
|
|
|
71928b |
--- a/Lib/test/make_ssl_certs.py
|
|
|
71928b |
+++ b/Lib/test/make_ssl_certs.py
|
|
|
71928b |
@@ -206,8 +206,8 @@ if __name__ == '__main__':
|
|
|
71928b |
with open('ssl_key.pem', 'w') as f:
|
|
|
71928b |
f.write(key)
|
|
|
71928b |
print("password protecting ssl_key.pem in ssl_key.passwd.pem")
|
|
|
71928b |
- check_call(['openssl','rsa','-in','ssl_key.pem','-out','ssl_key.passwd.pem','-des3','-passout','pass:somepass'])
|
|
|
71928b |
- check_call(['openssl','rsa','-in','ssl_key.pem','-out','keycert.passwd.pem','-des3','-passout','pass:somepass'])
|
|
|
71928b |
+ check_call(['openssl','pkey','-in','ssl_key.pem','-out','ssl_key.passwd.pem','-aes256','-passout','pass:somepass'])
|
|
|
71928b |
+ check_call(['openssl','pkey','-in','ssl_key.pem','-out','keycert.passwd.pem','-aes256','-passout','pass:somepass'])
|
|
|
71928b |
|
|
|
71928b |
with open('keycert.pem', 'w') as f:
|
|
|
71928b |
f.write(key)
|
|
|
71928b |
diff --git a/Lib/test/ssl_key.passwd.pem b/Lib/test/ssl_key.passwd.pem
|
|
|
71928b |
index e4f1370..46de61a 100644
|
|
|
71928b |
--- a/Lib/test/ssl_key.passwd.pem
|
|
|
71928b |
+++ b/Lib/test/ssl_key.passwd.pem
|
|
|
71928b |
@@ -1,42 +1,42 @@
|
|
|
71928b |
------BEGIN RSA PRIVATE KEY-----
|
|
|
71928b |
-Proc-Type: 4,ENCRYPTED
|
|
|
71928b |
-DEK-Info: DES-EDE3-CBC,8064BE1494B24B13
|
|
|
71928b |
-
|
|
|
71928b |
-KJrffOMbo8M0I3PzcYxRZGMpKD1yB3Ii4+bT5XoanxjIJ+4fdx6LfZ0Rsx+riyzs
|
|
|
71928b |
-tymsQu/iYY9j+4rCvN9+eetsL1X6iZpiimKsLexcid9M3fb0vxED5Sgw0dvunCUA
|
|
|
71928b |
-xhqjLIK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|
-X6PVA04g66r1NBw+3RQASVorZ3g1MSFvITHXcbKkBDeJH2z1+c6t/VVyTONnQhM5
|
|
|
71928b |
-lLgRSk6HCbetvT9PKxWrWutA12pdBYEHdZhMHVf2+xclky7l09w8hg2/qqcdGRGe
|
|
|
71928b |
-oAOZ72t0l5ObNyaruDKUS6f4AjOyWq/Xj5xuFtf1n3tQHyslSyCTPcAbQhDfTHUx
|
|
|
71928b |
-vixb/V9qvYPt7OCn8py7v1M69NH42QVFAvwveDIFjZdqfIKBoJK2V4qPoevJI6uj
|
|
|
71928b |
-Q5ByMt8OXOjSXNpHXpYQWUiWeCwOEBXJX8rzCHdMtg37jJ0zCmeErR1NTdg+EujM
|
|
|
71928b |
-TWYgd06jlT67tURST0aB2kg4ijKgUJefD313LW1zC6gVsTbjSZxYyRbPfSP6flQB
|
|
|
71928b |
-yCi1C19E2OsgleqbkBVC5GlYUzaJT7SGjCRmGx1eqtbrALu+LVH24Wceexlpjydl
|
|
|
71928b |
-+s2nf/DZlKun/tlPh6YioifPCJjByZMQOCEfIox6BkemZETz8uYA4TTWimG13Z03
|
|
|
71928b |
-gyDGC2jdpEW414J2qcQDvrdUgJ+HlhrAAHaWpMQDbXYxBGoZ+3+ORvQV4kAsCwL8
|
|
|
71928b |
-k3EIrVpePdik+1xgOWsyLj6QxFXlTMvL6Wc5pnArFPORsgHEolJvxSPTf9aAHNPn
|
|
|
71928b |
-V2WBvxiLBtYpGrujAUM40Syx/aN2RPtcXYPAusHUBw+S8/p+/8Kg8GZmnIXG3F89
|
|
|
71928b |
-45Eepl2quZYIrou7a1fwIpIIZ0hFiBQ1mlHVMFtxwVHS1bQb3SU2GeO+JcGjdVXc
|
|
|
71928b |
-04qeGuQ5M164eQ5C0T7ZQ1ULiUlFWKD30m+cjqmZzt3d7Q0mKpMKuESIuZJo/wpD
|
|
|
71928b |
-Nas432aLKUhcNx/pOYLkKJRpGZKOupQoD5iUj/j44o8JoFkDK33v2S57XB5QGz28
|
|
|
71928b |
-9Zuhx49b3W8mbM6EBanlQKLWJGCxXqc/jhYhFWn+b0MhidynFgA0oeWvf6ZDyt6H
|
|
|
71928b |
-Yi5Etxsar09xp0Do3NxtQXLuSUu0ji2pQzSIKuoqQWKqldm6VrpwojiqJhy4WQBQ
|
|
|
71928b |
-aVVyFeWBC7G3Zj76dO+yp2sfJ0itJUQ8AIB9Cg0f34rEZu+r9luPmqBoUeL95Tk7
|
|
|
71928b |
-YvCOU3Jl8Iqysv8aNpVXT8sa8rrSbruWCByEePZ37RIdHLMVBwVY0eVaFQjrjU7E
|
|
|
71928b |
-mXmM9eaoYLfXOllsQ+M2+qPFUITr/GU3Qig13DhK/+yC1R6V2a0l0WRhMltIPYKW
|
|
|
71928b |
-Ztvvr4hK5LcYCeS113BLiMbDIMMZZYGDZGMdC8DnnVbT2loF0Rfmp80Af31KmMQ4
|
|
|
71928b |
-6XvMatW9UDjBoY5a/YMpdm7SRwm+MgV2KNPpc2kST87/yi9oprGAb8qiarHiHTM0
|
|
|
71928b |
------END RSA PRIVATE KEY-----
|
|
|
71928b |
+-----BEGIN ENCRYPTED PRIVATE KEY-----
|
|
|
71928b |
+MIIHbTBXBgkqhkiG9w0BBQ0wSjApBgkqhkiG9w0BBQwwHAQI072N7W+PDDMCAggA
|
|
|
71928b |
+MAwGCCqGSIb3DQIJBQAwHQYJYIZIAWUDBAEqBBA/AuaRNi4vE4KGqI4In+70BIIH
|
|
|
71928b |
+ENGS5Vex5NID873frmd1UZEHZ+O/Bd0wDb+NUpIqesHkRYf7kKi6Gnr+nKQ/oVVn
|
|
|
71928b |
+Lm3JjE7c8ECP0OkOOXmiXuWL1SkzBBWqCI4stSGUPvBiHsGwNnvJAaGjUffgMlcC
|
|
|
71928b |
+aJOA2+dnejLkzblq4CB2LQdm06N3Xoe9tyqtQaUHxfzJAf5Ydd8uj7vpKN2MMhY7
|
|
|
71928b |
+icIPJwSyh0N7S6XWVtHEokr9Kp4y2hS5a+BgCWV1/1z0aF7agnSVndmT1VR+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LabX4tbGk79PswjnjLLEOr0
|
|
|
71928b |
+Ghf6RF6qf5/iFyJoG4vrbKT8kx6ywh0InILCdjUunuDskIBxX6tEcr9XwajoIvb2
|
|
|
71928b |
+kcmGdjam5kKLS7QOWQTl8/r/cuFes0dj34cX5Qpq+Gd7tRq/D+b0207926Cxvftv
|
|
|
71928b |
+qQ1cVn8HiLxKkZzd3tpf2xnoV1zkTL0oHrNg+qzxoxXUTUcwtIf1d/HRbYEAhi/d
|
|
|
71928b |
+bBBoFeftEHWNq+sJgS9bH+XNzo/yK4u04B5miOq8v4CSkJdzu+ZdF22d4cjiGmtQ
|
|
|
71928b |
+8BTmcn0Unzm+u5H0+QSZe54QBHJGNXXOIKMTkgnOdW27g4DbI1y7fCqJiSMbRW6L
|
|
|
71928b |
+oHmMfbdB3GWqGbsUkhY8i6h9op0MU6WOX7ea2Rxyt4t6
|
|
|
71928b |
+-----END ENCRYPTED PRIVATE KEY-----
|
|
|
71928b |
diff --git a/Misc/NEWS.d/next/Tests/2019-09-25-13-11-29.bpo-38271.iHXNIg.rst b/Misc/NEWS.d/next/Tests/2019-09-25-13-11-29.bpo-38271.iHXNIg.rst
|
|
|
71928b |
new file mode 100644
|
|
|
71928b |
index 0000000..8f43d32
|
|
|
71928b |
--- /dev/null
|
|
|
71928b |
+++ b/Misc/NEWS.d/next/Tests/2019-09-25-13-11-29.bpo-38271.iHXNIg.rst
|
|
|
71928b |
@@ -0,0 +1,4 @@
|
|
|
71928b |
+The private keys for test_ssl were encrypted with 3DES in traditional
|
|
|
71928b |
+PKCS#5 format. 3DES and the digest algorithm of PKCS#5 are blocked by
|
|
|
71928b |
+some strict crypto policies. Use PKCS#8 format with AES256 encryption
|
|
|
71928b |
+instead.
|
|
|
71928b |
--
|
|
|
71928b |
2.21.0
|
|
|
71928b |
|
|
|
71928b |
|
|
|
71928b |
From d8584f9bb3fb841a1b21ed25abc2237ea8bbc206 Mon Sep 17 00:00:00 2001
|
|
|
71928b |
From: Charalampos Stratakis <cstratak@redhat.com>
|
|
|
71928b |
Date: Tue, 26 Nov 2019 23:57:21 +0100
|
|
|
71928b |
Subject: [PATCH 3/5] Use PROTOCOL_TLS_CLIENT/SERVER
|
|
|
71928b |
|
|
|
71928b |
Replaces PROTOCOL_TLSv* and PROTOCOL_SSLv23 with PROTOCOL_TLS_CLIENT and
|
|
|
71928b |
PROTOCOL_TLS_SERVER.
|
|
|
71928b |
|
|
|
71928b |
Partially backports a170fa162dc03f0a014373349e548954fff2e567
|
|
|
71928b |
---
|
|
|
71928b |
Lib/ssl.py | 7 +-
|
|
|
71928b |
Lib/test/test_logging.py | 2 +-
|
|
|
71928b |
Lib/test/test_ssl.py | 169 +++++++++++++++++++--------------------
|
|
|
71928b |
3 files changed, 87 insertions(+), 91 deletions(-)
|
|
|
71928b |
|
|
|
71928b |
diff --git a/Lib/ssl.py b/Lib/ssl.py
|
|
|
71928b |
index 0114387..c5c5529 100644
|
|
|
71928b |
--- a/Lib/ssl.py
|
|
|
71928b |
+++ b/Lib/ssl.py
|
|
|
71928b |
@@ -473,7 +473,7 @@ def create_default_context(purpose=Purpose.SERVER_AUTH, *, cafile=None,
|
|
|
71928b |
context.load_default_certs(purpose)
|
|
|
71928b |
return context
|
|
|
71928b |
|
|
|
71928b |
-def _create_unverified_context(protocol=PROTOCOL_TLS, *, cert_reqs=None,
|
|
|
71928b |
+def _create_unverified_context(protocol=PROTOCOL_TLS, *, cert_reqs=CERT_NONE,
|
|
|
71928b |
check_hostname=False, purpose=Purpose.SERVER_AUTH,
|
|
|
71928b |
certfile=None, keyfile=None,
|
|
|
71928b |
cafile=None, capath=None, cadata=None):
|
|
|
71928b |
@@ -492,9 +492,12 @@ def _create_unverified_context(protocol=PROTOCOL_TLS, *, cert_reqs=None,
|
|
|
71928b |
# by default.
|
|
|
71928b |
context = SSLContext(protocol)
|
|
|
71928b |
|
|
|
71928b |
+ if not check_hostname:
|
|
|
71928b |
+ context.check_hostname = False
|
|
|
71928b |
if cert_reqs is not None:
|
|
|
71928b |
context.verify_mode = cert_reqs
|
|
|
71928b |
- context.check_hostname = check_hostname
|
|
|
71928b |
+ if check_hostname:
|
|
|
71928b |
+ context.check_hostname = True
|
|
|
71928b |
|
|
|
71928b |
if keyfile and not certfile:
|
|
|
71928b |
raise ValueError("certfile must be specified")
|
|
|
71928b |
diff --git a/Lib/test/test_logging.py b/Lib/test/test_logging.py
|
|
|
71928b |
index 763a5d1..d5c63b4 100644
|
|
|
71928b |
--- a/Lib/test/test_logging.py
|
|
|
71928b |
+++ b/Lib/test/test_logging.py
|
|
|
71928b |
@@ -1830,7 +1830,7 @@ class HTTPHandlerTest(BaseTest):
|
|
|
71928b |
else:
|
|
|
71928b |
here = os.path.dirname(__file__)
|
|
|
71928b |
localhost_cert = os.path.join(here, "keycert.pem")
|
|
|
71928b |
- sslctx = ssl.SSLContext(ssl.PROTOCOL_SSLv23)
|
|
|
71928b |
+ sslctx = ssl.SSLContext(ssl.PROTOCOL_TLS_SERVER)
|
|
|
71928b |
sslctx.load_cert_chain(localhost_cert)
|
|
|
71928b |
|
|
|
71928b |
context = ssl.create_default_context(cafile=localhost_cert)
|
|
|
71928b |
diff --git a/Lib/test/test_ssl.py b/Lib/test/test_ssl.py
|
|
|
71928b |
index 639109f..a7bf2f7 100644
|
|
|
71928b |
--- a/Lib/test/test_ssl.py
|
|
|
71928b |
+++ b/Lib/test/test_ssl.py
|
|
|
71928b |
@@ -155,6 +155,8 @@ def test_wrap_socket(sock, ssl_version=ssl.PROTOCOL_TLS, *,
|
|
|
71928b |
**kwargs):
|
|
|
71928b |
context = ssl.SSLContext(ssl_version)
|
|
|
71928b |
if cert_reqs is not None:
|
|
|
71928b |
+ if cert_reqs == ssl.CERT_NONE:
|
|
|
71928b |
+ context.check_hostname = False
|
|
|
71928b |
context.verify_mode = cert_reqs
|
|
|
71928b |
if ca_certs is not None:
|
|
|
71928b |
context.load_verify_locations(ca_certs)
|
|
|
71928b |
@@ -1377,7 +1379,7 @@ class ContextTests(unittest.TestCase):
|
|
|
71928b |
self._assert_context_options(ctx)
|
|
|
71928b |
|
|
|
71928b |
def test_check_hostname(self):
|
|
|
71928b |
- ctx = ssl.SSLContext(ssl.PROTOCOL_TLSv1)
|
|
|
71928b |
+ ctx = ssl.SSLContext(ssl.PROTOCOL_TLS)
|
|
|
71928b |
self.assertFalse(ctx.check_hostname)
|
|
|
71928b |
|
|
|
71928b |
# Requires CERT_REQUIRED or CERT_OPTIONAL
|
|
|
71928b |
@@ -2386,17 +2388,13 @@ if _have_threads:
|
|
|
71928b |
server_params_test(context, context,
|
|
|
71928b |
chatty=True, connectionchatty=True)
|
|
|
71928b |
|
|
|
71928b |
- client_context = ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT)
|
|
|
71928b |
- client_context.load_verify_locations(SIGNING_CA)
|
|
|
71928b |
- server_context = ssl.SSLContext(ssl.PROTOCOL_TLS_SERVER)
|
|
|
71928b |
- # server_context.load_verify_locations(SIGNING_CA)
|
|
|
71928b |
- server_context.load_cert_chain(SIGNED_CERTFILE2)
|
|
|
71928b |
+ client_context, server_context, hostname = testing_context()
|
|
|
71928b |
|
|
|
71928b |
with self.subTest(client=ssl.PROTOCOL_TLS_CLIENT, server=ssl.PROTOCOL_TLS_SERVER):
|
|
|
71928b |
server_params_test(client_context=client_context,
|
|
|
71928b |
server_context=server_context,
|
|
|
71928b |
chatty=True, connectionchatty=True,
|
|
|
71928b |
- sni_name='fakehostname')
|
|
|
71928b |
+ sni_name='localhost')
|
|
|
71928b |
|
|
|
71928b |
client_context.check_hostname = False
|
|
|
71928b |
with self.subTest(client=ssl.PROTOCOL_TLS_SERVER, server=ssl.PROTOCOL_TLS_CLIENT):
|
|
|
71928b |
@@ -2404,7 +2402,7 @@ if _have_threads:
|
|
|
71928b |
server_params_test(client_context=server_context,
|
|
|
71928b |
server_context=client_context,
|
|
|
71928b |
chatty=True, connectionchatty=True,
|
|
|
71928b |
- sni_name='fakehostname')
|
|
|
71928b |
+ sni_name='localhost')
|
|
|
71928b |
self.assertIn('called a function you should not call',
|
|
|
71928b |
str(e.exception))
|
|
|
71928b |
|
|
|
71928b |
@@ -2469,39 +2467,38 @@ if _have_threads:
|
|
|
71928b |
if support.verbose:
|
|
|
71928b |
sys.stdout.write("\n")
|
|
|
71928b |
|
|
|
71928b |
- server_context = ssl.SSLContext(ssl.PROTOCOL_TLSv1)
|
|
|
71928b |
- server_context.load_cert_chain(SIGNED_CERTFILE)
|
|
|
71928b |
+ client_context, server_context, hostname = testing_context()
|
|
|
71928b |
|
|
|
71928b |
- context = ssl.SSLContext(ssl.PROTOCOL_TLSv1)
|
|
|
71928b |
- context.verify_mode = ssl.CERT_REQUIRED
|
|
|
71928b |
- context.load_verify_locations(SIGNING_CA)
|
|
|
71928b |
tf = getattr(ssl, "VERIFY_X509_TRUSTED_FIRST", 0)
|
|
|
71928b |
- self.assertEqual(context.verify_flags, ssl.VERIFY_DEFAULT | tf)
|
|
|
71928b |
+ self.assertEqual(client_context.verify_flags, ssl.VERIFY_DEFAULT | tf)
|
|
|
71928b |
|
|
|
71928b |
# VERIFY_DEFAULT should pass
|
|
|
71928b |
server = ThreadedEchoServer(context=server_context, chatty=True)
|
|
|
71928b |
with server:
|
|
|
71928b |
- with context.wrap_socket(socket.socket()) as s:
|
|
|
71928b |
+ with client_context.wrap_socket(socket.socket(),
|
|
|
71928b |
+ server_hostname=hostname) as s:
|
|
|
71928b |
s.connect((HOST, server.port))
|
|
|
71928b |
cert = s.getpeercert()
|
|
|
71928b |
self.assertTrue(cert, "Can't get peer certificate.")
|
|
|
71928b |
|
|
|
71928b |
# VERIFY_CRL_CHECK_LEAF without a loaded CRL file fails
|
|
|
71928b |
- context.verify_flags |= ssl.VERIFY_CRL_CHECK_LEAF
|
|
|
71928b |
+ client_context.verify_flags |= ssl.VERIFY_CRL_CHECK_LEAF
|
|
|
71928b |
|
|
|
71928b |
server = ThreadedEchoServer(context=server_context, chatty=True)
|
|
|
71928b |
with server:
|
|
|
71928b |
- with context.wrap_socket(socket.socket()) as s:
|
|
|
71928b |
+ with client_context.wrap_socket(socket.socket(),
|
|
|
71928b |
+ server_hostname=hostname) as s:
|
|
|
71928b |
with self.assertRaisesRegex(ssl.SSLError,
|
|
|
71928b |
"certificate verify failed"):
|
|
|
71928b |
s.connect((HOST, server.port))
|
|
|
71928b |
|
|
|
71928b |
# now load a CRL file. The CRL file is signed by the CA.
|
|
|
71928b |
- context.load_verify_locations(CRLFILE)
|
|
|
71928b |
+ client_context.load_verify_locations(CRLFILE)
|
|
|
71928b |
|
|
|
71928b |
server = ThreadedEchoServer(context=server_context, chatty=True)
|
|
|
71928b |
with server:
|
|
|
71928b |
- with context.wrap_socket(socket.socket()) as s:
|
|
|
71928b |
+ with client_context.wrap_socket(socket.socket(),
|
|
|
71928b |
+ server_hostname=hostname) as s:
|
|
|
71928b |
s.connect((HOST, server.port))
|
|
|
71928b |
cert = s.getpeercert()
|
|
|
71928b |
self.assertTrue(cert, "Can't get peer certificate.")
|
|
|
71928b |
@@ -2510,19 +2507,13 @@ if _have_threads:
|
|
|
71928b |
if support.verbose:
|
|
|
71928b |
sys.stdout.write("\n")
|
|
|
71928b |
|
|
|
71928b |
- server_context = ssl.SSLContext(ssl.PROTOCOL_TLSv1)
|
|
|
71928b |
- server_context.load_cert_chain(SIGNED_CERTFILE)
|
|
|
71928b |
-
|
|
|
71928b |
- context = ssl.SSLContext(ssl.PROTOCOL_TLSv1)
|
|
|
71928b |
- context.verify_mode = ssl.CERT_REQUIRED
|
|
|
71928b |
- context.check_hostname = True
|
|
|
71928b |
- context.load_verify_locations(SIGNING_CA)
|
|
|
71928b |
+ client_context, server_context, hostname = testing_context()
|
|
|
71928b |
|
|
|
71928b |
# correct hostname should verify
|
|
|
71928b |
server = ThreadedEchoServer(context=server_context, chatty=True)
|
|
|
71928b |
with server:
|
|
|
71928b |
- with context.wrap_socket(socket.socket(),
|
|
|
71928b |
- server_hostname="localhost") as s:
|
|
|
71928b |
+ with client_context.wrap_socket(socket.socket(),
|
|
|
71928b |
+ server_hostname=hostname) as s:
|
|
|
71928b |
s.connect((HOST, server.port))
|
|
|
71928b |
cert = s.getpeercert()
|
|
|
71928b |
self.assertTrue(cert, "Can't get peer certificate.")
|
|
|
71928b |
@@ -2530,7 +2521,7 @@ if _have_threads:
|
|
|
71928b |
# incorrect hostname should raise an exception
|
|
|
71928b |
server = ThreadedEchoServer(context=server_context, chatty=True)
|
|
|
71928b |
with server:
|
|
|
71928b |
- with context.wrap_socket(socket.socket(),
|
|
|
71928b |
+ with client_context.wrap_socket(socket.socket(),
|
|
|
71928b |
server_hostname="invalid") as s:
|
|
|
71928b |
with self.assertRaisesRegex(ssl.CertificateError,
|
|
|
71928b |
"hostname 'invalid' doesn't match 'localhost'"):
|
|
|
71928b |
@@ -2542,7 +2533,7 @@ if _have_threads:
|
|
|
71928b |
with socket.socket() as s:
|
|
|
71928b |
with self.assertRaisesRegex(ValueError,
|
|
|
71928b |
"check_hostname requires server_hostname"):
|
|
|
71928b |
- context.wrap_socket(s)
|
|
|
71928b |
+ client_context.wrap_socket(s)
|
|
|
71928b |
|
|
|
71928b |
def test_wrong_cert(self):
|
|
|
71928b |
"""Connecting when the server rejects the client's certificate
|
|
|
71928b |
@@ -2767,7 +2758,6 @@ if _have_threads:
|
|
|
71928b |
msgs = (b"msg 1", b"MSG 2", b"STARTTLS", b"MSG 3", b"msg 4", b"ENDTLS", b"msg 5", b"msg 6")
|
|
|
71928b |
|
|
|
71928b |
server = ThreadedEchoServer(CERTFILE,
|
|
|
71928b |
- ssl_version=ssl.PROTOCOL_TLSv1,
|
|
|
71928b |
starttls_server=True,
|
|
|
71928b |
chatty=True,
|
|
|
71928b |
connectionchatty=True)
|
|
|
71928b |
@@ -2795,7 +2785,7 @@ if _have_threads:
|
|
|
71928b |
sys.stdout.write(
|
|
|
71928b |
" client: read %r from server, starting TLS...\n"
|
|
|
71928b |
% msg)
|
|
|
71928b |
- conn = test_wrap_socket(s, ssl_version=ssl.PROTOCOL_TLSv1)
|
|
|
71928b |
+ conn = test_wrap_socket(s)
|
|
|
71928b |
wrapped = True
|
|
|
71928b |
elif indata == b"ENDTLS" and msg.startswith(b"ok"):
|
|
|
71928b |
# ENDTLS ok, switch back to clear text
|
|
|
71928b |
@@ -2882,7 +2872,7 @@ if _have_threads:
|
|
|
71928b |
|
|
|
71928b |
server = ThreadedEchoServer(CERTFILE,
|
|
|
71928b |
certreqs=ssl.CERT_NONE,
|
|
|
71928b |
- ssl_version=ssl.PROTOCOL_TLSv1,
|
|
|
71928b |
+ ssl_version=ssl.PROTOCOL_TLS_SERVER,
|
|
|
71928b |
cacerts=CERTFILE,
|
|
|
71928b |
chatty=True,
|
|
|
71928b |
connectionchatty=False)
|
|
|
71928b |
@@ -2892,7 +2882,7 @@ if _have_threads:
|
|
|
71928b |
certfile=CERTFILE,
|
|
|
71928b |
ca_certs=CERTFILE,
|
|
|
71928b |
cert_reqs=ssl.CERT_NONE,
|
|
|
71928b |
- ssl_version=ssl.PROTOCOL_TLSv1)
|
|
|
71928b |
+ ssl_version=ssl.PROTOCOL_TLS_CLIENT)
|
|
|
71928b |
s.connect((HOST, server.port))
|
|
|
71928b |
# helper methods for standardising recv* method signatures
|
|
|
71928b |
def _recv_into():
|
|
|
71928b |
@@ -3034,7 +3024,7 @@ if _have_threads:
|
|
|
71928b |
def test_nonblocking_send(self):
|
|
|
71928b |
server = ThreadedEchoServer(CERTFILE,
|
|
|
71928b |
certreqs=ssl.CERT_NONE,
|
|
|
71928b |
- ssl_version=ssl.PROTOCOL_TLSv1,
|
|
|
71928b |
+ ssl_version=ssl.PROTOCOL_TLS_SERVER,
|
|
|
71928b |
cacerts=CERTFILE,
|
|
|
71928b |
chatty=True,
|
|
|
71928b |
connectionchatty=False)
|
|
|
71928b |
@@ -3044,7 +3034,7 @@ if _have_threads:
|
|
|
71928b |
certfile=CERTFILE,
|
|
|
71928b |
ca_certs=CERTFILE,
|
|
|
71928b |
cert_reqs=ssl.CERT_NONE,
|
|
|
71928b |
- ssl_version=ssl.PROTOCOL_TLSv1)
|
|
|
71928b |
+ ssl_version=ssl.PROTOCOL_TLS_CLIENT)
|
|
|
71928b |
s.connect((HOST, server.port))
|
|
|
71928b |
s.setblocking(False)
|
|
|
71928b |
|
|
|
71928b |
@@ -3190,9 +3180,11 @@ if _have_threads:
|
|
|
71928b |
Basic tests for SSLSocket.version().
|
|
|
71928b |
More tests are done in the test_protocol_*() methods.
|
|
|
71928b |
"""
|
|
|
71928b |
- context = ssl.SSLContext(ssl.PROTOCOL_TLSv1)
|
|
|
71928b |
+ context = ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT)
|
|
|
71928b |
+ context.check_hostname = False
|
|
|
71928b |
+ context.verify_mode = ssl.CERT_NONE
|
|
|
71928b |
with ThreadedEchoServer(CERTFILE,
|
|
|
71928b |
- ssl_version=ssl.PROTOCOL_TLSv1,
|
|
|
71928b |
+ ssl_version=ssl.PROTOCOL_TLS_SERVER,
|
|
|
71928b |
chatty=False) as server:
|
|
|
71928b |
with context.wrap_socket(socket.socket()) as s:
|
|
|
71928b |
self.assertIs(s.version(), None)
|
|
|
71928b |
@@ -3247,7 +3239,7 @@ if _have_threads:
|
|
|
71928b |
|
|
|
71928b |
server = ThreadedEchoServer(CERTFILE,
|
|
|
71928b |
certreqs=ssl.CERT_NONE,
|
|
|
71928b |
- ssl_version=ssl.PROTOCOL_TLSv1,
|
|
|
71928b |
+ ssl_version=ssl.PROTOCOL_TLS_SERVER,
|
|
|
71928b |
cacerts=CERTFILE,
|
|
|
71928b |
chatty=True,
|
|
|
71928b |
connectionchatty=False)
|
|
|
71928b |
@@ -3257,7 +3249,7 @@ if _have_threads:
|
|
|
71928b |
certfile=CERTFILE,
|
|
|
71928b |
ca_certs=CERTFILE,
|
|
|
71928b |
cert_reqs=ssl.CERT_NONE,
|
|
|
71928b |
- ssl_version=ssl.PROTOCOL_TLSv1)
|
|
|
71928b |
+ ssl_version=ssl.PROTOCOL_TLS_CLIENT)
|
|
|
71928b |
s.connect((HOST, server.port))
|
|
|
71928b |
# get the data
|
|
|
71928b |
cb_data = s.get_channel_binding("tls-unique")
|
|
|
71928b |
@@ -3282,7 +3274,7 @@ if _have_threads:
|
|
|
71928b |
certfile=CERTFILE,
|
|
|
71928b |
ca_certs=CERTFILE,
|
|
|
71928b |
cert_reqs=ssl.CERT_NONE,
|
|
|
71928b |
- ssl_version=ssl.PROTOCOL_TLSv1)
|
|
|
71928b |
+ ssl_version=ssl.PROTOCOL_TLS_CLIENT)
|
|
|
71928b |
s.connect((HOST, server.port))
|
|
|
71928b |
new_cb_data = s.get_channel_binding("tls-unique")
|
|
|
71928b |
if support.verbose:
|
|
|
71928b |
@@ -3299,32 +3291,35 @@ if _have_threads:
|
|
|
71928b |
s.close()
|
|
|
71928b |
|
|
|
71928b |
def test_compression(self):
|
|
|
71928b |
- context = ssl.SSLContext(ssl.PROTOCOL_TLSv1)
|
|
|
71928b |
- context.load_cert_chain(CERTFILE)
|
|
|
71928b |
- stats = server_params_test(context, context,
|
|
|
71928b |
- chatty=True, connectionchatty=True)
|
|
|
71928b |
+ client_context, server_context, hostname = testing_context()
|
|
|
71928b |
+ stats = server_params_test(client_context, server_context,
|
|
|
71928b |
+ chatty=True, connectionchatty=True,
|
|
|
71928b |
+ sni_name=hostname)
|
|
|
71928b |
if support.verbose:
|
|
|
71928b |
sys.stdout.write(" got compression: {!r}\n".format(stats['compression']))
|
|
|
71928b |
self.assertIn(stats['compression'], { None, 'ZLIB', 'RLE' })
|
|
|
71928b |
|
|
|
71928b |
+
|
|
|
71928b |
@unittest.skipUnless(hasattr(ssl, 'OP_NO_COMPRESSION'),
|
|
|
71928b |
"ssl.OP_NO_COMPRESSION needed for this test")
|
|
|
71928b |
def test_compression_disabled(self):
|
|
|
71928b |
- context = ssl.SSLContext(ssl.PROTOCOL_TLSv1)
|
|
|
71928b |
- context.load_cert_chain(CERTFILE)
|
|
|
71928b |
- context.options |= ssl.OP_NO_COMPRESSION
|
|
|
71928b |
- stats = server_params_test(context, context,
|
|
|
71928b |
- chatty=True, connectionchatty=True)
|
|
|
71928b |
+ client_context, server_context, hostname = testing_context()
|
|
|
71928b |
+ client_context.options |= ssl.OP_NO_COMPRESSION
|
|
|
71928b |
+ server_context.options |= ssl.OP_NO_COMPRESSION
|
|
|
71928b |
+ stats = server_params_test(client_context, server_context,
|
|
|
71928b |
+ chatty=True, connectionchatty=True,
|
|
|
71928b |
+ sni_name=hostname)
|
|
|
71928b |
self.assertIs(stats['compression'], None)
|
|
|
71928b |
|
|
|
71928b |
def test_dh_params(self):
|
|
|
71928b |
# Check we can get a connection with ephemeral Diffie-Hellman
|
|
|
71928b |
- context = ssl.SSLContext(ssl.PROTOCOL_TLSv1)
|
|
|
71928b |
- context.load_cert_chain(CERTFILE)
|
|
|
71928b |
- context.load_dh_params(DHFILE)
|
|
|
71928b |
- context.set_ciphers("kEDH")
|
|
|
71928b |
- stats = server_params_test(context, context,
|
|
|
71928b |
- chatty=True, connectionchatty=True)
|
|
|
71928b |
+ client_context, server_context, hostname = testing_context()
|
|
|
71928b |
+ server_context.load_dh_params(DHFILE)
|
|
|
71928b |
+ server_context.set_ciphers("kEDH")
|
|
|
71928b |
+ server_context.options |= ssl.OP_NO_TLSv1_3
|
|
|
71928b |
+ stats = server_params_test(client_context, server_context,
|
|
|
71928b |
+ chatty=True, connectionchatty=True,
|
|
|
71928b |
+ sni_name=hostname)
|
|
|
71928b |
cipher = stats["cipher"][0]
|
|
|
71928b |
parts = cipher.split("-")
|
|
|
71928b |
if "ADH" not in parts and "EDH" not in parts and "DHE" not in parts:
|
|
|
71928b |
@@ -3332,22 +3327,20 @@ if _have_threads:
|
|
|
71928b |
|
|
|
71928b |
def test_selected_alpn_protocol(self):
|
|
|
71928b |
# selected_alpn_protocol() is None unless ALPN is used.
|
|
|
71928b |
- context = ssl.SSLContext(ssl.PROTOCOL_TLSv1)
|
|
|
71928b |
- context.load_cert_chain(CERTFILE)
|
|
|
71928b |
- stats = server_params_test(context, context,
|
|
|
71928b |
- chatty=True, connectionchatty=True)
|
|
|
71928b |
+ client_context, server_context, hostname = testing_context()
|
|
|
71928b |
+ stats = server_params_test(client_context, server_context,
|
|
|
71928b |
+ chatty=True, connectionchatty=True,
|
|
|
71928b |
+ sni_name=hostname)
|
|
|
71928b |
self.assertIs(stats['client_alpn_protocol'], None)
|
|
|
71928b |
|
|
|
71928b |
@unittest.skipUnless(ssl.HAS_ALPN, "ALPN support required")
|
|
|
71928b |
def test_selected_alpn_protocol_if_server_uses_alpn(self):
|
|
|
71928b |
# selected_alpn_protocol() is None unless ALPN is used by the client.
|
|
|
71928b |
- client_context = ssl.SSLContext(ssl.PROTOCOL_TLSv1)
|
|
|
71928b |
- client_context.load_verify_locations(CERTFILE)
|
|
|
71928b |
- server_context = ssl.SSLContext(ssl.PROTOCOL_TLSv1)
|
|
|
71928b |
- server_context.load_cert_chain(CERTFILE)
|
|
|
71928b |
+ client_context, server_context, hostname = testing_context()
|
|
|
71928b |
server_context.set_alpn_protocols(['foo', 'bar'])
|
|
|
71928b |
stats = server_params_test(client_context, server_context,
|
|
|
71928b |
- chatty=True, connectionchatty=True)
|
|
|
71928b |
+ chatty=True, connectionchatty=True,
|
|
|
71928b |
+ sni_name=hostname)
|
|
|
71928b |
self.assertIs(stats['client_alpn_protocol'], None)
|
|
|
71928b |
|
|
|
71928b |
@unittest.skipUnless(ssl.HAS_ALPN, "ALPN support needed for this test")
|
|
|
71928b |
@@ -3394,10 +3387,10 @@ if _have_threads:
|
|
|
71928b |
|
|
|
71928b |
def test_selected_npn_protocol(self):
|
|
|
71928b |
# selected_npn_protocol() is None unless NPN is used
|
|
|
71928b |
- context = ssl.SSLContext(ssl.PROTOCOL_TLSv1)
|
|
|
71928b |
- context.load_cert_chain(CERTFILE)
|
|
|
71928b |
- stats = server_params_test(context, context,
|
|
|
71928b |
- chatty=True, connectionchatty=True)
|
|
|
71928b |
+ client_context, server_context, hostname = testing_context()
|
|
|
71928b |
+ stats = server_params_test(client_context, server_context,
|
|
|
71928b |
+ chatty=True, connectionchatty=True,
|
|
|
71928b |
+ sni_name=hostname)
|
|
|
71928b |
self.assertIs(stats['client_npn_protocol'], None)
|
|
|
71928b |
|
|
|
71928b |
@unittest.skipUnless(ssl.HAS_NPN, "NPN support needed for this test")
|
|
|
71928b |
@@ -3430,12 +3423,11 @@ if _have_threads:
|
|
|
71928b |
self.assertEqual(server_result, expected, msg % (server_result, "server"))
|
|
|
71928b |
|
|
|
71928b |
def sni_contexts(self):
|
|
|
71928b |
- server_context = ssl.SSLContext(ssl.PROTOCOL_TLSv1)
|
|
|
71928b |
+ server_context = ssl.SSLContext(ssl.PROTOCOL_TLS_SERVER)
|
|
|
71928b |
server_context.load_cert_chain(SIGNED_CERTFILE)
|
|
|
71928b |
- other_context = ssl.SSLContext(ssl.PROTOCOL_TLSv1)
|
|
|
71928b |
+ other_context = ssl.SSLContext(ssl.PROTOCOL_TLS_SERVER)
|
|
|
71928b |
other_context.load_cert_chain(SIGNED_CERTFILE2)
|
|
|
71928b |
- client_context = ssl.SSLContext(ssl.PROTOCOL_TLSv1)
|
|
|
71928b |
- client_context.verify_mode = ssl.CERT_REQUIRED
|
|
|
71928b |
+ client_context = ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT)
|
|
|
71928b |
client_context.load_verify_locations(SIGNING_CA)
|
|
|
71928b |
return server_context, other_context, client_context
|
|
|
71928b |
|
|
|
71928b |
@@ -3448,6 +3440,8 @@ if _have_threads:
|
|
|
71928b |
calls = []
|
|
|
71928b |
server_context, other_context, client_context = self.sni_contexts()
|
|
|
71928b |
|
|
|
71928b |
+ client_context.check_hostname = False
|
|
|
71928b |
+
|
|
|
71928b |
def servername_cb(ssl_sock, server_name, initial_context):
|
|
|
71928b |
calls.append((server_name, initial_context))
|
|
|
71928b |
if server_name is not None:
|
|
|
71928b |
@@ -3533,11 +3527,7 @@ if _have_threads:
|
|
|
71928b |
self.assertIn("TypeError", stderr.getvalue())
|
|
|
71928b |
|
|
|
71928b |
def test_shared_ciphers(self):
|
|
|
71928b |
- server_context = ssl.SSLContext(ssl.PROTOCOL_TLSv1)
|
|
|
71928b |
- server_context.load_cert_chain(SIGNED_CERTFILE)
|
|
|
71928b |
- client_context = ssl.SSLContext(ssl.PROTOCOL_TLSv1)
|
|
|
71928b |
- client_context.verify_mode = ssl.CERT_REQUIRED
|
|
|
71928b |
- client_context.load_verify_locations(SIGNING_CA)
|
|
|
71928b |
+ client_context, server_context, hostname = testing_context()
|
|
|
71928b |
if ssl.OPENSSL_VERSION_INFO >= (1, 0, 2):
|
|
|
71928b |
client_context.set_ciphers("AES128:AES256")
|
|
|
71928b |
server_context.set_ciphers("AES256")
|
|
|
71928b |
@@ -3555,7 +3545,8 @@ if _have_threads:
|
|
|
71928b |
# TLS 1.3 ciphers are always enabled
|
|
|
71928b |
expected_algs.extend(["TLS_CHACHA20", "TLS_AES"])
|
|
|
71928b |
|
|
|
71928b |
- stats = server_params_test(client_context, server_context)
|
|
|
71928b |
+ stats = server_params_test(client_context, server_context,
|
|
|
71928b |
+ sni_name=hostname)
|
|
|
71928b |
ciphers = stats['server_shared_ciphers'][0]
|
|
|
71928b |
self.assertGreater(len(ciphers), 0)
|
|
|
71928b |
for name, tls_version, bits in ciphers:
|
|
|
71928b |
@@ -3595,14 +3586,13 @@ if _have_threads:
|
|
|
71928b |
self.assertEqual(s.recv(1024), TEST_DATA)
|
|
|
71928b |
|
|
|
71928b |
def test_session(self):
|
|
|
71928b |
- server_context = ssl.SSLContext(ssl.PROTOCOL_TLSv1)
|
|
|
71928b |
- server_context.load_cert_chain(SIGNED_CERTFILE)
|
|
|
71928b |
- client_context = ssl.SSLContext(ssl.PROTOCOL_TLSv1)
|
|
|
71928b |
- client_context.verify_mode = ssl.CERT_REQUIRED
|
|
|
71928b |
- client_context.load_verify_locations(SIGNING_CA)
|
|
|
71928b |
+ client_context, server_context, hostname = testing_context()
|
|
|
71928b |
+ # TODO: sessions aren't compatible with TLSv1.3 yet
|
|
|
71928b |
+ client_context.options |= ssl.OP_NO_TLSv1_3
|
|
|
71928b |
|
|
|
71928b |
# first connection without session
|
|
|
71928b |
- stats = server_params_test(client_context, server_context)
|
|
|
71928b |
+ stats = server_params_test(client_context, server_context,
|
|
|
71928b |
+ sni_name=hostname)
|
|
|
71928b |
session = stats['session']
|
|
|
71928b |
self.assertTrue(session.id)
|
|
|
71928b |
self.assertGreater(session.time, 0)
|
|
|
71928b |
@@ -3616,7 +3606,8 @@ if _have_threads:
|
|
|
71928b |
self.assertEqual(sess_stat['hits'], 0)
|
|
|
71928b |
|
|
|
71928b |
# reuse session
|
|
|
71928b |
- stats = server_params_test(client_context, server_context, session=session)
|
|
|
71928b |
+ stats = server_params_test(client_context, server_context,
|
|
|
71928b |
+ session=session, sni_name=hostname)
|
|
|
71928b |
sess_stat = server_context.session_stats()
|
|
|
71928b |
self.assertEqual(sess_stat['accept'], 2)
|
|
|
71928b |
self.assertEqual(sess_stat['hits'], 1)
|
|
|
71928b |
@@ -3629,7 +3620,8 @@ if _have_threads:
|
|
|
71928b |
self.assertGreaterEqual(session2.timeout, session.timeout)
|
|
|
71928b |
|
|
|
71928b |
# another one without session
|
|
|
71928b |
- stats = server_params_test(client_context, server_context)
|
|
|
71928b |
+ stats = server_params_test(client_context, server_context,
|
|
|
71928b |
+ sni_name=hostname)
|
|
|
71928b |
self.assertFalse(stats['session_reused'])
|
|
|
71928b |
session3 = stats['session']
|
|
|
71928b |
self.assertNotEqual(session3.id, session.id)
|
|
|
71928b |
@@ -3639,7 +3631,8 @@ if _have_threads:
|
|
|
71928b |
self.assertEqual(sess_stat['hits'], 1)
|
|
|
71928b |
|
|
|
71928b |
# reuse session again
|
|
|
71928b |
- stats = server_params_test(client_context, server_context, session=session)
|
|
|
71928b |
+ stats = server_params_test(client_context, server_context,
|
|
|
71928b |
+ session=session, sni_name=hostname)
|
|
|
71928b |
self.assertTrue(stats['session_reused'])
|
|
|
71928b |
session4 = stats['session']
|
|
|
71928b |
self.assertEqual(session4.id, session.id)
|
|
|
71928b |
--
|
|
|
71928b |
2.21.0
|
|
|
71928b |
|
|
|
71928b |
|
|
|
71928b |
From 743c3e09b485092b51a982ab9859ffc79cbb7791 Mon Sep 17 00:00:00 2001
|
|
|
71928b |
From: Charalampos Stratakis <cstratak@redhat.com>
|
|
|
71928b |
Date: Wed, 27 Nov 2019 00:01:17 +0100
|
|
|
71928b |
Subject: [PATCH 4/5] Adjust some tests for TLS 1.3 compatibility
|
|
|
71928b |
|
|
|
71928b |
Partially backports some changes from 529525fb5a8fd9b96ab4021311a598c77588b918
|
|
|
71928b |
and 2614ed4c6e4b32eafb683f2378ed20e87d42976d
|
|
|
71928b |
---
|
|
|
71928b |
Lib/test/test_ssl.py | 17 ++++++++++++++---
|
|
|
71928b |
1 file changed, 14 insertions(+), 3 deletions(-)
|
|
|
71928b |
|
|
|
71928b |
diff --git a/Lib/test/test_ssl.py b/Lib/test/test_ssl.py
|
|
|
71928b |
index a7bf2f7..43c2dbc 100644
|
|
|
71928b |
--- a/Lib/test/test_ssl.py
|
|
|
71928b |
+++ b/Lib/test/test_ssl.py
|
|
|
71928b |
@@ -3189,7 +3189,12 @@ if _have_threads:
|
|
|
71928b |
with context.wrap_socket(socket.socket()) as s:
|
|
|
71928b |
self.assertIs(s.version(), None)
|
|
|
71928b |
s.connect((HOST, server.port))
|
|
|
71928b |
- self.assertEqual(s.version(), 'TLSv1')
|
|
|
71928b |
+ if IS_OPENSSL_1_1:
|
|
|
71928b |
+ self.assertEqual(s.version(), 'TLSv1.3')
|
|
|
71928b |
+ elif ssl.OPENSSL_VERSION_INFO >= (1, 0, 2):
|
|
|
71928b |
+ self.assertEqual(s.version(), 'TLSv1.2')
|
|
|
71928b |
+ else: # 0.9.8 to 1.0.1
|
|
|
71928b |
+ self.assertIn(s.version(), ('TLSv1', 'TLSv1.2'))
|
|
|
71928b |
self.assertIs(s.version(), None)
|
|
|
71928b |
|
|
|
71928b |
@unittest.skipUnless(ssl.HAS_TLSv1_3,
|
|
|
71928b |
@@ -3259,7 +3264,10 @@ if _have_threads:
|
|
|
71928b |
|
|
|
71928b |
# check if it is sane
|
|
|
71928b |
self.assertIsNotNone(cb_data)
|
|
|
71928b |
- self.assertEqual(len(cb_data), 12) # True for TLSv1
|
|
|
71928b |
+ if s.version() == 'TLSv1.3':
|
|
|
71928b |
+ self.assertEqual(len(cb_data), 48)
|
|
|
71928b |
+ else:
|
|
|
71928b |
+ self.assertEqual(len(cb_data), 12) # True for TLSv1
|
|
|
71928b |
|
|
|
71928b |
# and compare with the peers version
|
|
|
71928b |
s.write(b"CB tls-unique\n")
|
|
|
71928b |
@@ -3283,7 +3291,10 @@ if _have_threads:
|
|
|
71928b |
# is it really unique
|
|
|
71928b |
self.assertNotEqual(cb_data, new_cb_data)
|
|
|
71928b |
self.assertIsNotNone(cb_data)
|
|
|
71928b |
- self.assertEqual(len(cb_data), 12) # True for TLSv1
|
|
|
71928b |
+ if s.version() == 'TLSv1.3':
|
|
|
71928b |
+ self.assertEqual(len(cb_data), 48)
|
|
|
71928b |
+ else:
|
|
|
71928b |
+ self.assertEqual(len(cb_data), 12) # True for TLSv1
|
|
|
71928b |
s.write(b"CB tls-unique\n")
|
|
|
71928b |
peer_data_repr = s.read().strip()
|
|
|
71928b |
self.assertEqual(peer_data_repr,
|
|
|
71928b |
--
|
|
|
71928b |
2.21.0
|
|
|
71928b |
|
|
|
71928b |
|
|
|
71928b |
From cd250c8a782f36c7a6f5ffabc922cb75744fa9c0 Mon Sep 17 00:00:00 2001
|
|
|
71928b |
From: Charalampos Stratakis <cstratak@redhat.com>
|
|
|
71928b |
Date: Tue, 26 Nov 2019 23:18:10 +0100
|
|
|
71928b |
Subject: [PATCH 5/5] Skip the ssl tests that rely on TLSv1 and TLSv1.1
|
|
|
71928b |
availability
|
|
|
71928b |
|
|
|
71928b |
---
|
|
|
71928b |
Lib/test/test_ssl.py | 32 +++++++++++++++++++++++---------
|
|
|
71928b |
1 file changed, 23 insertions(+), 9 deletions(-)
|
|
|
71928b |
|
|
|
71928b |
diff --git a/Lib/test/test_ssl.py b/Lib/test/test_ssl.py
|
|
|
71928b |
index 43c2dbc..b35db25 100644
|
|
|
71928b |
--- a/Lib/test/test_ssl.py
|
|
|
71928b |
+++ b/Lib/test/test_ssl.py
|
|
|
71928b |
@@ -39,6 +39,13 @@ IS_LIBRESSL = ssl.OPENSSL_VERSION.startswith('LibreSSL')
|
|
|
71928b |
IS_OPENSSL_1_1 = not IS_LIBRESSL and ssl.OPENSSL_VERSION_INFO >= (1, 1, 0)
|
|
|
71928b |
PY_SSL_DEFAULT_CIPHERS = sysconfig.get_config_var('PY_SSL_DEFAULT_CIPHERS')
|
|
|
71928b |
|
|
|
71928b |
+# On RHEL8 openssl disables TLSv1 and TLSv1.1 on runtime.
|
|
|
71928b |
+# Since we don't have a good way to detect runtime changes
|
|
|
71928b |
+# on the allowed protocols, we hardcode the default config
|
|
|
71928b |
+# with those flags.
|
|
|
71928b |
+TLSv1_enabled = False
|
|
|
71928b |
+TLSv1_1_enabled = False
|
|
|
71928b |
+
|
|
|
71928b |
def data_file(*name):
|
|
|
71928b |
return os.path.join(os.path.dirname(__file__), *name)
|
|
|
71928b |
|
|
|
71928b |
@@ -2380,7 +2387,8 @@ if _have_threads:
|
|
|
71928b |
if support.verbose:
|
|
|
71928b |
sys.stdout.write("\n")
|
|
|
71928b |
for protocol in PROTOCOLS:
|
|
|
71928b |
- if protocol in {ssl.PROTOCOL_TLS_CLIENT, ssl.PROTOCOL_TLS_SERVER}:
|
|
|
71928b |
+ if protocol in {ssl.PROTOCOL_TLS_CLIENT, ssl.PROTOCOL_TLS_SERVER,
|
|
|
71928b |
+ ssl.PROTOCOL_TLSv1, ssl.PROTOCOL_TLSv1_1}:
|
|
|
71928b |
continue
|
|
|
71928b |
with self.subTest(protocol=ssl._PROTOCOL_NAMES[protocol]):
|
|
|
71928b |
context = ssl.SSLContext(protocol)
|
|
|
71928b |
@@ -2650,17 +2658,20 @@ if _have_threads:
|
|
|
71928b |
if hasattr(ssl, 'PROTOCOL_SSLv3'):
|
|
|
71928b |
try_protocol_combo(ssl.PROTOCOL_SSLv23, ssl.PROTOCOL_SSLv3, False)
|
|
|
71928b |
try_protocol_combo(ssl.PROTOCOL_SSLv23, ssl.PROTOCOL_SSLv23, True)
|
|
|
71928b |
- try_protocol_combo(ssl.PROTOCOL_SSLv23, ssl.PROTOCOL_TLSv1, 'TLSv1')
|
|
|
71928b |
+ if TLSv1_enabled:
|
|
|
71928b |
+ try_protocol_combo(ssl.PROTOCOL_SSLv23, ssl.PROTOCOL_TLSv1, 'TLSv1')
|
|
|
71928b |
|
|
|
71928b |
if hasattr(ssl, 'PROTOCOL_SSLv3'):
|
|
|
71928b |
try_protocol_combo(ssl.PROTOCOL_SSLv23, ssl.PROTOCOL_SSLv3, False, ssl.CERT_OPTIONAL)
|
|
|
71928b |
try_protocol_combo(ssl.PROTOCOL_SSLv23, ssl.PROTOCOL_SSLv23, True, ssl.CERT_OPTIONAL)
|
|
|
71928b |
- try_protocol_combo(ssl.PROTOCOL_SSLv23, ssl.PROTOCOL_TLSv1, 'TLSv1', ssl.CERT_OPTIONAL)
|
|
|
71928b |
+ if TLSv1_enabled:
|
|
|
71928b |
+ try_protocol_combo(ssl.PROTOCOL_SSLv23, ssl.PROTOCOL_TLSv1, 'TLSv1', ssl.CERT_OPTIONAL)
|
|
|
71928b |
|
|
|
71928b |
if hasattr(ssl, 'PROTOCOL_SSLv3'):
|
|
|
71928b |
try_protocol_combo(ssl.PROTOCOL_SSLv23, ssl.PROTOCOL_SSLv3, False, ssl.CERT_REQUIRED)
|
|
|
71928b |
try_protocol_combo(ssl.PROTOCOL_SSLv23, ssl.PROTOCOL_SSLv23, True, ssl.CERT_REQUIRED)
|
|
|
71928b |
- try_protocol_combo(ssl.PROTOCOL_SSLv23, ssl.PROTOCOL_TLSv1, 'TLSv1', ssl.CERT_REQUIRED)
|
|
|
71928b |
+ if TLSv1_enabled:
|
|
|
71928b |
+ try_protocol_combo(ssl.PROTOCOL_SSLv23, ssl.PROTOCOL_TLSv1, 'TLSv1', ssl.CERT_REQUIRED)
|
|
|
71928b |
|
|
|
71928b |
# Server with specific SSL options
|
|
|
71928b |
if hasattr(ssl, 'PROTOCOL_SSLv3'):
|
|
|
71928b |
@@ -2698,9 +2709,10 @@ if _have_threads:
|
|
|
71928b |
"""Connecting to a TLSv1 server with various client options"""
|
|
|
71928b |
if support.verbose:
|
|
|
71928b |
sys.stdout.write("\n")
|
|
|
71928b |
- try_protocol_combo(ssl.PROTOCOL_TLSv1, ssl.PROTOCOL_TLSv1, 'TLSv1')
|
|
|
71928b |
- try_protocol_combo(ssl.PROTOCOL_TLSv1, ssl.PROTOCOL_TLSv1, 'TLSv1', ssl.CERT_OPTIONAL)
|
|
|
71928b |
- try_protocol_combo(ssl.PROTOCOL_TLSv1, ssl.PROTOCOL_TLSv1, 'TLSv1', ssl.CERT_REQUIRED)
|
|
|
71928b |
+ if TLSv1_enabled:
|
|
|
71928b |
+ try_protocol_combo(ssl.PROTOCOL_TLSv1, ssl.PROTOCOL_TLSv1, 'TLSv1')
|
|
|
71928b |
+ try_protocol_combo(ssl.PROTOCOL_TLSv1, ssl.PROTOCOL_TLSv1, 'TLSv1', ssl.CERT_OPTIONAL)
|
|
|
71928b |
+ try_protocol_combo(ssl.PROTOCOL_TLSv1, ssl.PROTOCOL_TLSv1, 'TLSv1', ssl.CERT_REQUIRED)
|
|
|
71928b |
if hasattr(ssl, 'PROTOCOL_SSLv2'):
|
|
|
71928b |
try_protocol_combo(ssl.PROTOCOL_TLSv1, ssl.PROTOCOL_SSLv2, False)
|
|
|
71928b |
if hasattr(ssl, 'PROTOCOL_SSLv3'):
|
|
|
71928b |
@@ -2716,7 +2728,8 @@ if _have_threads:
|
|
|
71928b |
Testing against older TLS versions."""
|
|
|
71928b |
if support.verbose:
|
|
|
71928b |
sys.stdout.write("\n")
|
|
|
71928b |
- try_protocol_combo(ssl.PROTOCOL_TLSv1_1, ssl.PROTOCOL_TLSv1_1, 'TLSv1.1')
|
|
|
71928b |
+ if TLSv1_1_enabled:
|
|
|
71928b |
+ try_protocol_combo(ssl.PROTOCOL_TLSv1_1, ssl.PROTOCOL_TLSv1_1, 'TLSv1.1')
|
|
|
71928b |
if hasattr(ssl, 'PROTOCOL_SSLv2'):
|
|
|
71928b |
try_protocol_combo(ssl.PROTOCOL_TLSv1_1, ssl.PROTOCOL_SSLv2, False)
|
|
|
71928b |
if hasattr(ssl, 'PROTOCOL_SSLv3'):
|
|
|
71928b |
@@ -2724,7 +2737,8 @@ if _have_threads:
|
|
|
71928b |
try_protocol_combo(ssl.PROTOCOL_TLSv1_1, ssl.PROTOCOL_SSLv23, False,
|
|
|
71928b |
client_options=ssl.OP_NO_TLSv1_1)
|
|
|
71928b |
|
|
|
71928b |
- try_protocol_combo(ssl.PROTOCOL_SSLv23, ssl.PROTOCOL_TLSv1_1, 'TLSv1.1')
|
|
|
71928b |
+ if TLSv1_1_enabled:
|
|
|
71928b |
+ try_protocol_combo(ssl.PROTOCOL_SSLv23, ssl.PROTOCOL_TLSv1_1, 'TLSv1.1')
|
|
|
71928b |
try_protocol_combo(ssl.PROTOCOL_TLSv1_1, ssl.PROTOCOL_TLSv1, False)
|
|
|
71928b |
try_protocol_combo(ssl.PROTOCOL_TLSv1, ssl.PROTOCOL_TLSv1_1, False)
|
|
|
71928b |
|
|
|
71928b |
--
|
|
|
71928b |
2.21.0
|
|
|
71928b |
|