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
e5b4fee7
Commit
e5b4fee7
authored
Jan 14, 2016
by
Martin Panter
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue #25940: Update new SSL tests for self-signed.pythontest.net
parent
b644e8c2
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
12 deletions
+12
-12
Lib/test/test_ssl.py
Lib/test/test_ssl.py
+12
-12
No files found.
Lib/test/test_ssl.py
View file @
e5b4fee7
...
@@ -971,7 +971,7 @@ class ContextTests(unittest.TestCase):
...
@@ -971,7 +971,7 @@ class ContextTests(unittest.TestCase):
ctx
.
load_verify_locations
(
CERTFILE
)
ctx
.
load_verify_locations
(
CERTFILE
)
self
.
assertEqual
(
ctx
.
cert_store_stats
(),
self
.
assertEqual
(
ctx
.
cert_store_stats
(),
{
'x509_ca'
:
0
,
'crl'
:
0
,
'x509'
:
1
})
{
'x509_ca'
:
0
,
'crl'
:
0
,
'x509'
:
1
})
ctx
.
load_verify_locations
(
SVN_PYTHON_ORG_ROOT_
CERT
)
ctx
.
load_verify_locations
(
CAFILE_CA
CERT
)
self
.
assertEqual
(
ctx
.
cert_store_stats
(),
self
.
assertEqual
(
ctx
.
cert_store_stats
(),
{
'x509_ca'
:
1
,
'crl'
:
0
,
'x509'
:
2
})
{
'x509_ca'
:
1
,
'crl'
:
0
,
'x509'
:
2
})
...
@@ -981,8 +981,8 @@ class ContextTests(unittest.TestCase):
...
@@ -981,8 +981,8 @@ class ContextTests(unittest.TestCase):
# CERTFILE is not flagged as X509v3 Basic Constraints: CA:TRUE
# CERTFILE is not flagged as X509v3 Basic Constraints: CA:TRUE
ctx
.
load_verify_locations
(
CERTFILE
)
ctx
.
load_verify_locations
(
CERTFILE
)
self
.
assertEqual
(
ctx
.
get_ca_certs
(),
[])
self
.
assertEqual
(
ctx
.
get_ca_certs
(),
[])
# but
SVN_PYTHON_ORG_ROOT_
CERT is a CA cert
# but
CAFILE_CA
CERT is a CA cert
ctx
.
load_verify_locations
(
SVN_PYTHON_ORG_ROOT_
CERT
)
ctx
.
load_verify_locations
(
CAFILE_CA
CERT
)
self
.
assertEqual
(
ctx
.
get_ca_certs
(),
self
.
assertEqual
(
ctx
.
get_ca_certs
(),
[{
'issuer'
:
(((
'organizationName'
,
'Root CA'
),),
[{
'issuer'
:
(((
'organizationName'
,
'Root CA'
),),
((
'organizationalUnitName'
,
'http://www.cacert.org'
),),
((
'organizationalUnitName'
,
'http://www.cacert.org'
),),
...
@@ -998,7 +998,7 @@ class ContextTests(unittest.TestCase):
...
@@ -998,7 +998,7 @@ class ContextTests(unittest.TestCase):
((
'emailAddress'
,
'support@cacert.org'
),)),
((
'emailAddress'
,
'support@cacert.org'
),)),
'version'
:
3
}])
'version'
:
3
}])
with
open
(
SVN_PYTHON_ORG_ROOT_
CERT
)
as
f
:
with
open
(
CAFILE_CA
CERT
)
as
f
:
pem
=
f
.
read
()
pem
=
f
.
read
()
der
=
ssl
.
PEM_cert_to_DER_cert
(
pem
)
der
=
ssl
.
PEM_cert_to_DER_cert
(
pem
)
self
.
assertEqual
(
ctx
.
get_ca_certs
(
True
),
[
der
])
self
.
assertEqual
(
ctx
.
get_ca_certs
(
True
),
[
der
])
...
@@ -1335,15 +1335,15 @@ class NetworkedTests(unittest.TestCase):
...
@@ -1335,15 +1335,15 @@ class NetworkedTests(unittest.TestCase):
s
.
close
()
s
.
close
()
def
test_connect_cadata
(
self
):
def
test_connect_cadata
(
self
):
with
open
(
CAFILE_CA
CERT
)
as
f
:
with
open
(
REMOTE_ROOT_
CERT
)
as
f
:
pem
=
f
.
read
()
pem
=
f
.
read
()
der
=
ssl
.
PEM_cert_to_DER_cert
(
pem
)
der
=
ssl
.
PEM_cert_to_DER_cert
(
pem
)
with
support
.
transient_internet
(
"svn.python.org"
):
with
support
.
transient_internet
(
REMOTE_HOST
):
ctx
=
ssl
.
SSLContext
(
ssl
.
PROTOCOL_SSLv23
)
ctx
=
ssl
.
SSLContext
(
ssl
.
PROTOCOL_SSLv23
)
ctx
.
verify_mode
=
ssl
.
CERT_REQUIRED
ctx
.
verify_mode
=
ssl
.
CERT_REQUIRED
ctx
.
load_verify_locations
(
cadata
=
pem
)
ctx
.
load_verify_locations
(
cadata
=
pem
)
with
ctx
.
wrap_socket
(
socket
.
socket
(
socket
.
AF_INET
))
as
s
:
with
ctx
.
wrap_socket
(
socket
.
socket
(
socket
.
AF_INET
))
as
s
:
s
.
connect
((
"svn.python.org"
,
443
))
s
.
connect
((
REMOTE_HOST
,
443
))
cert
=
s
.
getpeercert
()
cert
=
s
.
getpeercert
()
self
.
assertTrue
(
cert
)
self
.
assertTrue
(
cert
)
...
@@ -1352,7 +1352,7 @@ class NetworkedTests(unittest.TestCase):
...
@@ -1352,7 +1352,7 @@ class NetworkedTests(unittest.TestCase):
ctx
.
verify_mode
=
ssl
.
CERT_REQUIRED
ctx
.
verify_mode
=
ssl
.
CERT_REQUIRED
ctx
.
load_verify_locations
(
cadata
=
der
)
ctx
.
load_verify_locations
(
cadata
=
der
)
with
ctx
.
wrap_socket
(
socket
.
socket
(
socket
.
AF_INET
))
as
s
:
with
ctx
.
wrap_socket
(
socket
.
socket
(
socket
.
AF_INET
))
as
s
:
s
.
connect
((
"svn.python.org"
,
443
))
s
.
connect
((
REMOTE_HOST
,
443
))
cert
=
s
.
getpeercert
()
cert
=
s
.
getpeercert
()
self
.
assertTrue
(
cert
)
self
.
assertTrue
(
cert
)
...
@@ -1475,13 +1475,13 @@ class NetworkedTests(unittest.TestCase):
...
@@ -1475,13 +1475,13 @@ class NetworkedTests(unittest.TestCase):
def
test_get_ca_certs_capath
(
self
):
def
test_get_ca_certs_capath
(
self
):
# capath certs are loaded on request
# capath certs are loaded on request
with
support
.
transient_internet
(
"svn.python.org"
):
with
support
.
transient_internet
(
REMOTE_HOST
):
ctx
=
ssl
.
SSLContext
(
ssl
.
PROTOCOL_SSLv23
)
ctx
=
ssl
.
SSLContext
(
ssl
.
PROTOCOL_SSLv23
)
ctx
.
verify_mode
=
ssl
.
CERT_REQUIRED
ctx
.
verify_mode
=
ssl
.
CERT_REQUIRED
ctx
.
load_verify_locations
(
capath
=
CAPATH
)
ctx
.
load_verify_locations
(
capath
=
CAPATH
)
self
.
assertEqual
(
ctx
.
get_ca_certs
(),
[])
self
.
assertEqual
(
ctx
.
get_ca_certs
(),
[])
s
=
ctx
.
wrap_socket
(
socket
.
socket
(
socket
.
AF_INET
))
s
=
ctx
.
wrap_socket
(
socket
.
socket
(
socket
.
AF_INET
))
s
.
connect
((
"svn.python.org"
,
443
))
s
.
connect
((
REMOTE_HOST
,
443
))
try
:
try
:
cert
=
s
.
getpeercert
()
cert
=
s
.
getpeercert
()
self
.
assertTrue
(
cert
)
self
.
assertTrue
(
cert
)
...
@@ -1492,12 +1492,12 @@ class NetworkedTests(unittest.TestCase):
...
@@ -1492,12 +1492,12 @@ class NetworkedTests(unittest.TestCase):
@
needs_sni
@
needs_sni
def
test_context_setget
(
self
):
def
test_context_setget
(
self
):
# Check that the context of a connected socket can be replaced.
# Check that the context of a connected socket can be replaced.
with
support
.
transient_internet
(
"svn.python.org"
):
with
support
.
transient_internet
(
REMOTE_HOST
):
ctx1
=
ssl
.
SSLContext
(
ssl
.
PROTOCOL_TLSv1
)
ctx1
=
ssl
.
SSLContext
(
ssl
.
PROTOCOL_TLSv1
)
ctx2
=
ssl
.
SSLContext
(
ssl
.
PROTOCOL_SSLv23
)
ctx2
=
ssl
.
SSLContext
(
ssl
.
PROTOCOL_SSLv23
)
s
=
socket
.
socket
(
socket
.
AF_INET
)
s
=
socket
.
socket
(
socket
.
AF_INET
)
with
ctx1
.
wrap_socket
(
s
)
as
ss
:
with
ctx1
.
wrap_socket
(
s
)
as
ss
:
ss
.
connect
((
"svn.python.org"
,
443
))
ss
.
connect
((
REMOTE_HOST
,
443
))
self
.
assertIs
(
ss
.
context
,
ctx1
)
self
.
assertIs
(
ss
.
context
,
ctx1
)
self
.
assertIs
(
ss
.
_sslobj
.
context
,
ctx1
)
self
.
assertIs
(
ss
.
_sslobj
.
context
,
ctx1
)
ss
.
context
=
ctx2
ss
.
context
=
ctx2
...
...
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