Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
a02c69a7
Commit
a02c69a7
authored
Dec 02, 2013
by
Christian Heimes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add check_hostname arg to ssl._create_stdlib_context()
parent
a5768f72
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
5 additions
and
2 deletions
+5
-2
Lib/ssl.py
Lib/ssl.py
+2
-1
Lib/test/test_ssl.py
Lib/test/test_ssl.py
+3
-1
No files found.
Lib/ssl.py
View file @
a02c69a7
...
...
@@ -405,7 +405,7 @@ def create_default_context(purpose=Purpose.SERVER_AUTH, *, cafile=None,
def
_create_stdlib_context
(
protocol
=
PROTOCOL_SSLv23
,
*
,
cert_reqs
=
None
,
purpose
=
Purpose
.
SERVER_AUTH
,
check_hostname
=
False
,
purpose
=
Purpose
.
SERVER_AUTH
,
certfile
=
None
,
keyfile
=
None
,
cafile
=
None
,
capath
=
None
,
cadata
=
None
):
"""Create a SSLContext object for Python stdlib modules
...
...
@@ -424,6 +424,7 @@ def _create_stdlib_context(protocol=PROTOCOL_SSLv23, *, cert_reqs=None,
if
cert_reqs
is
not
None
:
context
.
verify_mode
=
cert_reqs
context
.
check_hostname
=
check_hostname
if
keyfile
and
not
certfile
:
raise
ValueError
(
"certfile must be specified"
)
...
...
Lib/test/test_ssl.py
View file @
a02c69a7
...
...
@@ -1032,9 +1032,11 @@ class ContextTests(unittest.TestCase):
self
.
assertEqual
(
ctx
.
options
&
ssl
.
OP_NO_SSLv2
,
ssl
.
OP_NO_SSLv2
)
ctx
=
ssl
.
_create_stdlib_context
(
ssl
.
PROTOCOL_TLSv1
,
cert_reqs
=
ssl
.
CERT_REQUIRED
)
cert_reqs
=
ssl
.
CERT_REQUIRED
,
check_hostname
=
True
)
self
.
assertEqual
(
ctx
.
protocol
,
ssl
.
PROTOCOL_TLSv1
)
self
.
assertEqual
(
ctx
.
verify_mode
,
ssl
.
CERT_REQUIRED
)
self
.
assertTrue
(
ctx
.
check_hostname
)
self
.
assertEqual
(
ctx
.
options
&
ssl
.
OP_NO_SSLv2
,
ssl
.
OP_NO_SSLv2
)
ctx
=
ssl
.
_create_stdlib_context
(
purpose
=
ssl
.
Purpose
.
CLIENT_AUTH
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment