Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

gh-107361: strengthen default SSL context flags#112389

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from1 commit
Commits
Show all changes
19 commits
Select commitHold shift + click to select a range
f0e262e
gh-107361: strengthen default SSL context flags
woodruffwNov 25, 2023
4782048
add news entry
woodruffwNov 25, 2023
732b953
ssl: expand comment
woodruffwNov 25, 2023
15c0313
ssl.rst: further explain new X509 flags
woodruffwNov 29, 2023
2aceb81
whatsnew: add ssl.create_default_context changes
woodruffwNov 29, 2023
eb2c6e4
gitattributes: mark certdata as generated
woodruffwNov 29, 2023
668803c
gitattributes: avoid {} glob syntax
woodruffwNov 29, 2023
da318a6
Update Doc/library/ssl.rst
woodruffwDec 1, 2023
4ae44d1
ssl.rst: explain how to disable VERIFY_X509_STRICT
woodruffwDec 1, 2023
792383a
Apply suggestions from code review
woodruffwDec 6, 2023
f1b59ed
whatsnew/3.13: add note for disabling VERIFY_X509_STRICT
woodruffwDec 6, 2023
c8a7bb5
Merge remote-tracking branch 'upstream/main' into default-ssl-verify-…
woodruffwFeb 1, 2024
f6c3af3
test: add a backstop test for VERIFY_X509_STRICT
woodruffwFeb 2, 2024
ff087fb
test: try a higher base error
woodruffwFeb 2, 2024
e46a672
test: require OpenSSL 3+ for test_verify_strict
woodruffwFeb 16, 2024
fe42d9a
Merge remote-tracking branch 'upstream/main' into default-ssl-verify-…
woodruffwFeb 16, 2024
1a3e037
test: whitespace
woodruffwFeb 16, 2024
cef6950
Merge remote-tracking branch 'upstream/main' into default-ssl-verify-…
woodruffwMar 4, 2024
2c7b14e
Merge remote-tracking branch 'upstream/main' into default-ssl-verify-…
woodruffwMar 6, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
PrevPrevious commit
NextNext commit
test: add a backstop test for VERIFY_X509_STRICT
  • Loading branch information
@woodruffw
woodruffw committedFeb 2, 2024
commitf6c3af3364f0c4d974ae503fb88b87270f657ea5
13 changes: 13 additions & 0 deletionsLib/test/certdata/leaf-missing-aki.ca.pem
View file
Open in desktop

Some generated files are not rendered by default. Learn more abouthow customized files appear on GitHub.

18 changes: 18 additions & 0 deletionsLib/test/certdata/leaf-missing-aki.keycert.pem
View file
Open in desktop

Some generated files are not rendered by default. Learn more abouthow customized files appear on GitHub.

39 changes: 38 additions & 1 deletionLib/test/test_ssl.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -38,7 +38,7 @@
ssl = import_helper.import_module("ssl")
import _ssl

from ssl import TLSVersion, _TLSContentType, _TLSMessageType, _TLSAlertType
from ssl importPurpose,TLSVersion, _TLSContentType, _TLSMessageType, _TLSAlertType

Py_DEBUG_WIN32 = support.Py_DEBUG and sys.platform == 'win32'

Expand DownExpand Up@@ -128,6 +128,13 @@ def data_file(*name):
SIGNED_CERTFILE_ECC = data_file("keycertecc.pem")
SIGNED_CERTFILE_ECC_HOSTNAME = 'localhost-ecc'

# A custom testcase, extracted from `rfc5280::aki::leaf-missing-aki` in x509-limbo:
# The leaf (server) certificate has no AKI, which is forbidden under RFC 5280.
# See: https://x509-limbo.com/testcases/rfc5280/#rfc5280akileaf-missing-aki
LEAF_MISSING_AKI_CERTFILE = data_file("leaf-missing-aki.keycert.pem")
LEAF_MISSING_AKI_CERTFILE_HOSTNAME = "example.com"
LEAF_MISSING_AKI_CA = data_file("leaf-missing-aki.ca.pem")

# Same certificate as pycacert.pem, but without extra text in file
SIGNING_CA = data_file("capath", "ceff1710.0")
# cert with all kinds of subject alt names
Expand DownExpand Up@@ -2949,6 +2956,36 @@ def test_ecc_cert(self):
cipher = s.cipher()[0].split('-')
self.assertTrue(cipher[:2], ('ECDHE', 'ECDSA'))

def test_verify_strict(self):
Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

@sethmlarson This test provides a backstop check onVERIFY_X509_STRICT, PTAL!

gpshead reacted with thumbs up emoji
# verification fails by default, since the server cert is non-conforming
client_context = ssl.create_default_context()
client_context.load_verify_locations(LEAF_MISSING_AKI_CA)
hostname = LEAF_MISSING_AKI_CERTFILE_HOSTNAME

server_context = ssl.create_default_context(purpose=Purpose.CLIENT_AUTH)
server_context.load_cert_chain(LEAF_MISSING_AKI_CERTFILE)
server = ThreadedEchoServer(context=server_context, chatty=True)
with server:
with client_context.wrap_socket(socket.socket(),
server_hostname=hostname) as s:
with self.assertRaises(ssl.SSLCertVerificationError):
s.connect((HOST, server.port))

# explicitly disabling VERIFY_X509_STRICT allows it to succeed
client_context = ssl.create_default_context()
client_context.load_verify_locations(LEAF_MISSING_AKI_CA)
client_context.verify_flags &= ~ssl.VERIFY_X509_STRICT

server_context = ssl.create_default_context(purpose=Purpose.CLIENT_AUTH)
server_context.load_cert_chain(LEAF_MISSING_AKI_CERTFILE)
server = ThreadedEchoServer(context=server_context, chatty=True)
with server:
with client_context.wrap_socket(socket.socket(),
server_hostname=hostname) as s:
s.connect((HOST, server.port))
cert = s.getpeercert()
self.assertTrue(cert, "Can't get peer certificate.")

def test_dual_rsa_ecc(self):
client_context = ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT)
client_context.load_verify_locations(SIGNING_CA)
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp