Bugzilla (bugzilla.redhat.com) will be under maintenance for infrastructure upgrades and will not be available on July 31st between 12:30 AM - 05:30 AM UTC. We appreciate your understanding and patience. You can follow status.redhat.com for details.
Bug 1565943 - Don't recommend ssl.wrap_socket()
Summary: Don't recommend ssl.wrap_socket()
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: Red_Hat_Enterprise_Linux-Release_Notes-7-en-US
Version: 7.5
Hardware: Unspecified
OS: Unspecified
Target Milestone: rc
: ---
Assignee: Lenka Špačková
QA Contact:
Depends On:
TreeView+ depends on / blocked
Reported: 2018-04-11 06:37 UTC by Christian Heimes
Modified: 2019-03-06 01:04 UTC (History)
3 users (show)

Fixed In Version:
Doc Type: Deprecated Functionality
Doc Text:
sslwrap() removed from Python The sslwrap() function has been removed from Python 2.7. After the 466 Python Enhancement Proposal (https://www.python.org/dev/peps/pep-0466/) was implemented, using this function resulted in a segmentation fault. The removal is consistent with upstream. Red Hat recommends using the ssl.SSLContext class and the ssl.SSLContext.wrap_socket() function instead. Most applications can simply use the ssl.create_default_context() function, which creates a context with secure default settings. The default context uses the system's default trust store, too.
Clone Of:
Last Closed: 2018-04-17 15:56:18 UTC
Target Upstream Version:

Attachments (Terms of Use)

System ID Private Priority Status Summary Last Updated
Red Hat Bugzilla 1331425 0 unspecified CLOSED Segmentation fault in sslwrap function 2021-02-22 00:41:40 UTC

Description Christian Heimes 2018-04-11 06:37:12 UTC
Document URL: 

Section Number and Name: 
sslwrap() removed from Python

Describe the issue: 
The section recommends ssl.wrap_socket() as replacement for sslwrap. As upstream maintainer of Python's ssl module and Red Hat security engineer for IdM, I strongly advise against the function. ssl.wrap_socket() has multiple deficiencies. Most importantly the function is insecure. It doesn't validate host names and opens applications to MitM attacks. Further more the function has no option to load the system trust store, so applications have to hard-code the path to CA cert bundle. Application developers usually don't bother and rather disable cert validation. The function is also inefficient. It has to parse cert, key, and CA and create a temporary SSLContext object for every call.

Suggestions for improvement: 
Please advise users to use ssl.SSLContext and ssl.SSLContext.wrap_socket() instead. Most applications can simply use ssl.create_default_context(), which creates a context with secure default settings. The default context uses the system's default trust store, too.

>>> import ssl
>>> ctx = ssl.create_default_context()
>>> ctx.wrap_socket(sock, server_hostname=HOSTNAME)

Additional information: 
ssl.wrap_socket() will be deprecated soon, too.

Comment 2 Lenka Špačková 2018-04-11 08:33:33 UTC
Hi Christian, 
Thanks a lot for your suggestion. Please review the proposed doc text and let me know if this is sufficient.

Charis, you were the original reporter in BZ#1331425, please let me know if you have any suggestions, too.

Once I get acks from both of you, I will republish RHEL 7.3, 7.4, and 7.5 Release Notes with this fix.


Comment 3 Christian Heimes 2018-04-16 14:17:16 UTC

Thanks, Lenka!

Comment 4 Charalampos Stratakis 2018-04-16 14:41:50 UTC
LGTM as well!

Note You need to log in before you can comment on or make changes to this bug.