Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
15399c3f
Kaydet (Commit)
15399c3f
authored
Nis 28, 2011
tarafından
Antoine Pitrou
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue #11811: ssl.get_server_certificate() is now IPv6-compatible. Patch
by Charles-François Natali.
üst
9c39f3c4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
31 additions
and
20 deletions
+31
-20
ssl.rst
Doc/library/ssl.rst
+3
-0
ssl.py
Lib/ssl.py
+3
-3
test_ssl.py
Lib/test/test_ssl.py
+22
-17
NEWS
Misc/NEWS
+3
-0
No files found.
Doc/library/ssl.rst
Dosyayı görüntüle @
15399c3f
...
@@ -239,6 +239,9 @@ Certificate handling
...
@@ -239,6 +239,9 @@ Certificate handling
will attempt to validate the server certificate against that set of root
will attempt to validate the server certificate against that set of root
certificates, and will fail if the validation attempt fails.
certificates, and will fail if the validation attempt fails.
.. versionchanged:: 3.3
This function is now IPv6-compatible.
.. function:: DER_cert_to_PEM_cert(DER_cert_bytes)
.. function:: DER_cert_to_PEM_cert(DER_cert_bytes)
Given a certificate as a DER-encoded blob of bytes, returns a PEM-encoded
Given a certificate as a DER-encoded blob of bytes, returns a PEM-encoded
...
...
Lib/ssl.py
Dosyayı görüntüle @
15399c3f
...
@@ -81,7 +81,7 @@ from _ssl import HAS_SNI
...
@@ -81,7 +81,7 @@ from _ssl import HAS_SNI
from
socket
import
getnameinfo
as
_getnameinfo
from
socket
import
getnameinfo
as
_getnameinfo
from
socket
import
error
as
socket_error
from
socket
import
error
as
socket_error
from
socket
import
socket
,
AF_INET
,
SOCK_STREAM
from
socket
import
socket
,
AF_INET
,
SOCK_STREAM
,
create_connection
import
base64
# for DER-to-PEM translation
import
base64
# for DER-to-PEM translation
import
traceback
import
traceback
import
errno
import
errno
...
@@ -543,9 +543,9 @@ def get_server_certificate(addr, ssl_version=PROTOCOL_SSLv3, ca_certs=None):
...
@@ -543,9 +543,9 @@ def get_server_certificate(addr, ssl_version=PROTOCOL_SSLv3, ca_certs=None):
cert_reqs
=
CERT_REQUIRED
cert_reqs
=
CERT_REQUIRED
else
:
else
:
cert_reqs
=
CERT_NONE
cert_reqs
=
CERT_NONE
s
=
wrap_socket
(
socket
(),
ssl_version
=
ssl_version
,
s
=
create_connection
(
addr
)
s
=
wrap_socket
(
s
,
ssl_version
=
ssl_version
,
cert_reqs
=
cert_reqs
,
ca_certs
=
ca_certs
)
cert_reqs
=
cert_reqs
,
ca_certs
=
ca_certs
)
s
.
connect
(
addr
)
dercert
=
s
.
getpeercert
(
True
)
dercert
=
s
.
getpeercert
(
True
)
s
.
close
()
s
.
close
()
return
DER_cert_to_PEM_cert
(
dercert
)
return
DER_cert_to_PEM_cert
(
dercert
)
...
...
Lib/test/test_ssl.py
Dosyayı görüntüle @
15399c3f
...
@@ -604,25 +604,30 @@ class NetworkedTests(unittest.TestCase):
...
@@ -604,25 +604,30 @@ class NetworkedTests(unittest.TestCase):
sys
.
stdout
.
write
(
"
\n
Needed
%
d calls to do_handshake() to establish session.
\n
"
%
count
)
sys
.
stdout
.
write
(
"
\n
Needed
%
d calls to do_handshake() to establish session.
\n
"
%
count
)
def
test_get_server_certificate
(
self
):
def
test_get_server_certificate
(
self
):
with
support
.
transient_internet
(
"svn.python.org"
):
def
_test_get_server_certificate
(
host
,
port
,
cert
=
None
):
pem
=
ssl
.
get_server_certificate
((
"svn.python.org"
,
443
))
with
support
.
transient_internet
(
host
):
if
not
pem
:
pem
=
ssl
.
get_server_certificate
((
host
,
port
))
self
.
fail
(
"No server certificate on svn.python.org:443!"
)
if
not
pem
:
self
.
fail
(
"No server certificate on
%
s:
%
s!"
%
(
host
,
port
))
try
:
pem
=
ssl
.
get_server_certificate
((
"svn.python.org"
,
443
),
ca_certs
=
CERTFILE
)
try
:
except
ssl
.
SSLError
as
x
:
pem
=
ssl
.
get_server_certificate
((
host
,
port
),
ca_certs
=
CERTFILE
)
#should fail
except
ssl
.
SSLError
as
x
:
#should fail
if
support
.
verbose
:
sys
.
stdout
.
write
(
"
%
s
\n
"
%
x
)
else
:
self
.
fail
(
"Got server certificate
%
s for
%
s:
%
s!"
%
(
pem
,
host
,
port
))
pem
=
ssl
.
get_server_certificate
((
host
,
port
),
ca_certs
=
cert
)
if
not
pem
:
self
.
fail
(
"No server certificate on
%
s:
%
s!"
%
(
host
,
port
))
if
support
.
verbose
:
if
support
.
verbose
:
sys
.
stdout
.
write
(
"
%
s
\n
"
%
x
)
sys
.
stdout
.
write
(
"
\n
Verified certificate for
%
s:
%
s is
\n
%
s
\n
"
%
(
host
,
port
,
pem
))
else
:
self
.
fail
(
"Got server certificate
%
s for svn.python.org!"
%
pem
)
pem
=
ssl
.
get_server_certificate
((
"svn.python.org"
,
443
),
ca_certs
=
SVN_PYTHON_ORG_ROOT_CERT
)
_test_get_server_certificate
(
'svn.python.org'
,
443
,
SVN_PYTHON_ORG_ROOT_CERT
)
if
not
pem
:
if
support
.
IPV6_ENABLED
:
self
.
fail
(
"No server certificate on svn.python.org:443!"
)
_test_get_server_certificate
(
'ipv6.google.com'
,
443
)
if
support
.
verbose
:
sys
.
stdout
.
write
(
"
\n
Verified certificate for svn.python.org:443 is
\n
%
s
\n
"
%
pem
)
def
test_ciphers
(
self
):
def
test_ciphers
(
self
):
remote
=
(
"svn.python.org"
,
443
)
remote
=
(
"svn.python.org"
,
443
)
...
...
Misc/NEWS
Dosyayı görüntüle @
15399c3f
...
@@ -127,6 +127,9 @@ Core and Builtins
...
@@ -127,6 +127,9 @@ Core and Builtins
Library
Library
-------
-------
-
Issue
#
11811
:
ssl
.
get_server_certificate
()
is
now
IPv6
-
compatible
.
Patch
by
Charles
-
Fran
ç
ois
Natali
.
-
Issue
#
11763
:
don
't use difflib in TestCase.assertMultiLineEqual if the
-
Issue
#
11763
:
don
't use difflib in TestCase.assertMultiLineEqual if the
strings are too long.
strings are too long.
...
...
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