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
d151e274
Commit
d151e274
authored
Aug 14, 2010
by
Antoine Pitrou
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
This is a better resolution than r84021 (because it will also affect
ssl.get_server_certificate()).
parent
35bebe12
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
12 deletions
+6
-12
Lib/test/test_ssl.py
Lib/test/test_ssl.py
+6
-12
No files found.
Lib/test/test_ssl.py
View file @
d151e274
...
...
@@ -295,12 +295,16 @@ class ContextTests(unittest.TestCase):
class
NetworkedTests
(
unittest
.
TestCase
):
timeout
=
30
def
setUp
(
self
):
self
.
old_timeout
=
socket
.
getdefaulttimeout
()
socket
.
setdefaulttimeout
(
30
)
def
tearDown
(
self
):
socket
.
setdefaulttimeout
(
self
.
old_timeout
)
def
test_connect
(
self
):
s
=
ssl
.
wrap_socket
(
socket
.
socket
(
socket
.
AF_INET
),
cert_reqs
=
ssl
.
CERT_NONE
)
s
.
settimeout
(
self
.
timeout
)
try
:
s
.
connect
((
"svn.python.org"
,
443
))
self
.
assertEqual
({},
s
.
getpeercert
())
...
...
@@ -310,7 +314,6 @@ class NetworkedTests(unittest.TestCase):
# this should fail because we have no verification certs
s
=
ssl
.
wrap_socket
(
socket
.
socket
(
socket
.
AF_INET
),
cert_reqs
=
ssl
.
CERT_REQUIRED
)
s
.
settimeout
(
self
.
timeout
)
self
.
assertRaisesRegexp
(
ssl
.
SSLError
,
"certificate verify failed"
,
s
.
connect
,
(
"svn.python.org"
,
443
))
s
.
close
()
...
...
@@ -319,7 +322,6 @@ class NetworkedTests(unittest.TestCase):
s
=
ssl
.
wrap_socket
(
socket
.
socket
(
socket
.
AF_INET
),
cert_reqs
=
ssl
.
CERT_REQUIRED
,
ca_certs
=
SVN_PYTHON_ORG_ROOT_CERT
)
s
.
settimeout
(
self
.
timeout
)
try
:
s
.
connect
((
"svn.python.org"
,
443
))
self
.
assertTrue
(
s
.
getpeercert
())
...
...
@@ -330,7 +332,6 @@ class NetworkedTests(unittest.TestCase):
# Same as test_connect, but with a separately created context
ctx
=
ssl
.
SSLContext
(
ssl
.
PROTOCOL_SSLv23
)
s
=
ctx
.
wrap_socket
(
socket
.
socket
(
socket
.
AF_INET
))
s
.
settimeout
(
self
.
timeout
)
s
.
connect
((
"svn.python.org"
,
443
))
try
:
self
.
assertEqual
({},
s
.
getpeercert
())
...
...
@@ -339,14 +340,12 @@ class NetworkedTests(unittest.TestCase):
# This should fail because we have no verification certs
ctx
.
verify_mode
=
ssl
.
CERT_REQUIRED
s
=
ctx
.
wrap_socket
(
socket
.
socket
(
socket
.
AF_INET
))
s
.
settimeout
(
self
.
timeout
)
self
.
assertRaisesRegexp
(
ssl
.
SSLError
,
"certificate verify failed"
,
s
.
connect
,
(
"svn.python.org"
,
443
))
s
.
close
()
# This should succeed because we specify the root cert
ctx
.
load_verify_locations
(
SVN_PYTHON_ORG_ROOT_CERT
)
s
=
ctx
.
wrap_socket
(
socket
.
socket
(
socket
.
AF_INET
))
s
.
settimeout
(
self
.
timeout
)
s
.
connect
((
"svn.python.org"
,
443
))
try
:
cert
=
s
.
getpeercert
()
...
...
@@ -364,7 +363,6 @@ class NetworkedTests(unittest.TestCase):
ctx
.
verify_mode
=
ssl
.
CERT_REQUIRED
ctx
.
load_verify_locations
(
capath
=
CAPATH
)
s
=
ctx
.
wrap_socket
(
socket
.
socket
(
socket
.
AF_INET
))
s
.
settimeout
(
self
.
timeout
)
s
.
connect
((
"svn.python.org"
,
443
))
try
:
cert
=
s
.
getpeercert
()
...
...
@@ -376,7 +374,6 @@ class NetworkedTests(unittest.TestCase):
ctx
.
verify_mode
=
ssl
.
CERT_REQUIRED
ctx
.
load_verify_locations
(
capath
=
BYTES_CAPATH
)
s
=
ctx
.
wrap_socket
(
socket
.
socket
(
socket
.
AF_INET
))
s
.
settimeout
(
self
.
timeout
)
s
.
connect
((
"svn.python.org"
,
443
))
try
:
cert
=
s
.
getpeercert
()
...
...
@@ -390,7 +387,6 @@ class NetworkedTests(unittest.TestCase):
# delay closing the underlying "real socket" (here tested with its
# file descriptor, hence skipping the test under Windows).
ss
=
ssl
.
wrap_socket
(
socket
.
socket
(
socket
.
AF_INET
))
ss
.
settimeout
(
self
.
timeout
)
ss
.
connect
((
"svn.python.org"
,
443
))
fd
=
ss
.
fileno
()
f
=
ss
.
makefile
()
...
...
@@ -406,7 +402,6 @@ class NetworkedTests(unittest.TestCase):
def
test_non_blocking_handshake
(
self
):
s
=
socket
.
socket
(
socket
.
AF_INET
)
s
.
settimeout
(
self
.
timeout
)
s
.
connect
((
"svn.python.org"
,
443
))
s
.
setblocking
(
False
)
s
=
ssl
.
wrap_socket
(
s
,
...
...
@@ -463,7 +458,6 @@ class NetworkedTests(unittest.TestCase):
s
=
ssl
.
wrap_socket
(
socket
.
socket
(
socket
.
AF_INET
),
cert_reqs
=
ssl
.
CERT_REQUIRED
,
ca_certs
=
sha256_cert
,)
s
.
settimeout
(
self
.
timeout
)
with
support
.
transient_internet
():
try
:
s
.
connect
(
remote
)
...
...
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