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
48aae579
Kaydet (Commit)
48aae579
authored
Ara 02, 2013
tarafından
Christian Heimes
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue #19782: imaplib now supports SSLContext.check_hostname and server name
indication for TLS/SSL connections.
üst
0c924b83
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
43 additions
and
4 deletions
+43
-4
imaplib.rst
Doc/library/imaplib.rst
+8
-0
imaplib.py
Lib/imaplib.py
+6
-2
test_imaplib.py
Lib/test/test_imaplib.py
+26
-2
NEWS
Misc/NEWS
+3
-0
No files found.
Doc/library/imaplib.rst
Dosyayı görüntüle @
48aae579
...
...
@@ -80,6 +80,10 @@ There's also a subclass for secure connections:
.. versionchanged:: 3.3
*ssl_context* parameter added.
.. versionchanged:: 3.4
The class now supports hostname check with
:attr:`SSLContext.check_hostname` and *Server Name Indicator* (see
:data:`~ssl.HAS_SNI`).
The second subclass allows for connections created by a child process:
...
...
@@ -437,6 +441,10 @@ An :class:`IMAP4` instance has the following methods:
.. versionadded:: 3.2
.. versionchanged:: 3.4
The method now supports hostname check with
:attr:`SSLContext.check_hostname` and *Server Name Indicator* (see
:data:`~ssl.HAS_SNI`).
.. method:: IMAP4.status(mailbox, names)
...
...
Lib/imaplib.py
Dosyayı görüntüle @
48aae579
...
...
@@ -745,7 +745,9 @@ class IMAP4:
ssl_context
=
ssl
.
_create_stdlib_context
()
typ
,
dat
=
self
.
_simple_command
(
name
)
if
typ
==
'OK'
:
self
.
sock
=
ssl_context
.
wrap_socket
(
self
.
sock
)
server_hostname
=
self
.
host
if
ssl
.
HAS_SNI
else
None
self
.
sock
=
ssl_context
.
wrap_socket
(
self
.
sock
,
server_hostname
=
server_hostname
)
self
.
file
=
self
.
sock
.
makefile
(
'rb'
)
self
.
_tls_established
=
True
self
.
_get_capabilities
()
...
...
@@ -1216,7 +1218,9 @@ if HAVE_SSL:
def
_create_socket
(
self
):
sock
=
IMAP4
.
_create_socket
(
self
)
return
self
.
ssl_context
.
wrap_socket
(
sock
)
server_hostname
=
self
.
host
if
ssl
.
HAS_SNI
else
None
return
self
.
ssl_context
.
wrap_socket
(
sock
,
server_hostname
=
server_hostname
)
def
open
(
self
,
host
=
''
,
port
=
IMAP4_SSL_PORT
):
"""Setup connection to remote server on "host:port".
...
...
Lib/test/test_imaplib.py
Dosyayı görüntüle @
48aae579
...
...
@@ -20,6 +20,7 @@ except ImportError:
ssl
=
None
CERTFILE
=
None
CAFILE
=
None
class
TestImaplib
(
unittest
.
TestCase
):
...
...
@@ -348,6 +349,25 @@ class ThreadedNetworkedTestsSSL(BaseThreadedNetworkedTests):
server_class
=
SecureTCPServer
imap_class
=
IMAP4_SSL
@reap_threads
def
test_ssl_verified
(
self
):
ssl_context
=
ssl
.
SSLContext
(
ssl
.
PROTOCOL_SSLv23
)
ssl_context
.
verify_mode
=
ssl
.
CERT_REQUIRED
ssl_context
.
check_hostname
=
True
ssl_context
.
load_verify_locations
(
CAFILE
)
with
self
.
assertRaisesRegex
(
ssl
.
CertificateError
,
"hostname '127.0.0.1' doesn't match 'localhost'"
):
with
self
.
reaped_server
(
SimpleIMAPHandler
)
as
server
:
client
=
self
.
imap_class
(
*
server
.
server_address
,
ssl_context
=
ssl_context
)
client
.
shutdown
()
with
self
.
reaped_server
(
SimpleIMAPHandler
)
as
server
:
client
=
self
.
imap_class
(
"localhost"
,
server
.
server_address
[
1
],
ssl_context
=
ssl_context
)
client
.
shutdown
()
class
RemoteIMAPTest
(
unittest
.
TestCase
):
host
=
'cyrus.andrew.cmu.edu'
...
...
@@ -460,11 +480,15 @@ def load_tests(*args):
if
support
.
is_resource_enabled
(
'network'
):
if
ssl
:
global
CERTFILE
global
CERTFILE
,
CAFILE
CERTFILE
=
os
.
path
.
join
(
os
.
path
.
dirname
(
__file__
)
or
os
.
curdir
,
"keycert.pem"
)
"keycert
3
.pem"
)
if
not
os
.
path
.
exists
(
CERTFILE
):
raise
support
.
TestFailed
(
"Can't read certificate files!"
)
CAFILE
=
os
.
path
.
join
(
os
.
path
.
dirname
(
__file__
)
or
os
.
curdir
,
"pycacert.pem"
)
if
not
os
.
path
.
exists
(
CAFILE
):
raise
support
.
TestFailed
(
"Can't read CA file!"
)
tests
.
extend
([
ThreadedNetworkedTests
,
ThreadedNetworkedTestsSSL
,
RemoteIMAPTest
,
RemoteIMAP_SSLTest
,
RemoteIMAP_STARTTLSTest
,
...
...
Misc/NEWS
Dosyayı görüntüle @
48aae579
...
...
@@ -18,6 +18,9 @@ Core and Builtins
Library
-------
- Issue #19782: imaplib now supports SSLContext.check_hostname and server name
indication for TLS/SSL connections.
- Issue #19834: Support unpickling of exceptions pickled by Python 2.
- Issue #19781: ftplib now supports SSLContext.check_hostname and server name
...
...
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