[New-bugs-announce] [issue18880] ssl.SSLSocket shutdown doesn't behave like socket.shutdown

Michał Zieliński report at bugs.python.org
Thu Aug 29 23:36:58 CEST 2013


New submission from Michał Zieliński:

SSLSocket documentation mentions shutdown as analogue to socket.shutdown. However, instead of forbidding communication, it removes SSL wrapper from socket. For example, the following script doesn't work and returns garbage:

    import socket
    import ssl

    s = socket.socket()
    s.connect(('google.com', 443))
    client = ssl.wrap_socket(s)
    client.sendall(b'GET / HTTP/1.0\nConnection: close\n\n')
    client.shutdown(socket.SHUT_WR)

    print(repr(client.recv(40)))

Attached patch makes shutdown raise exception if how != SHUT_RDWR, as closing one side of socket over SSL doesn't make sense (unless I'm missing something).

----------
components: Library (Lib)
files: ssl-shutdown-fail.patch
keywords: patch
messages: 196494
nosy: zielmicha
priority: normal
severity: normal
status: open
title: ssl.SSLSocket shutdown doesn't behave like socket.shutdown
type: behavior
versions: Python 2.6, Python 2.7, Python 3.1, Python 3.2, Python 3.3, Python 3.4, Python 3.5
Added file: http://bugs.python.org/file31514/ssl-shutdown-fail.patch

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue18880>
_______________________________________


More information about the New-bugs-announce mailing list