Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

failed incoming SSL connection stays open forever #62118

Closed
PeterSaveliev mannequin opened this issue May 6, 2013 · 4 comments
Closed

failed incoming SSL connection stays open forever #62118

PeterSaveliev mannequin opened this issue May 6, 2013 · 4 comments
Labels
performance Performance or resource usage

Comments

@PeterSaveliev
Copy link
Mannequin

PeterSaveliev mannequin commented May 6, 2013

BPO 17918
Nosy @pitrou
Files
  • ssl_handshake_testcase.py: simple SSL server testcase
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2013-05-06.20:20:30.902>
    created_at = <Date 2013-05-06.14:27:32.887>
    labels = ['performance']
    title = 'failed incoming SSL connection stays open forever'
    updated_at = <Date 2013-05-06.20:20:30.901>
    user = 'https://bugs.python.org/PeterSaveliev'

    bugs.python.org fields:

    activity = <Date 2013-05-06.20:20:30.901>
    actor = 'pitrou'
    assignee = 'none'
    closed = True
    closed_date = <Date 2013-05-06.20:20:30.902>
    closer = 'pitrou'
    components = []
    creation = <Date 2013-05-06.14:27:32.887>
    creator = 'Peter.Saveliev'
    dependencies = []
    files = ['30150']
    hgrepos = []
    issue_num = 17918
    keywords = []
    message_count = 4.0
    messages = ['188544', '188559', '188582', '188584']
    nosy_count = 3.0
    nosy_names = ['pitrou', 'python-dev', 'Peter.Saveliev']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'resource usage'
    url = 'https://bugs.python.org/issue17918'
    versions = ['Python 2.6', 'Python 2.7']

    @PeterSaveliev
    Copy link
    Mannequin Author

    PeterSaveliev mannequin commented May 6, 2013

    Important: only Python2 versions are affected. Python3 works OK.
    Possibly related issue: http://bugs.python.org/issue12378 (differs: see the line above)

    Having a server with SSLSocket waiting for connections, the incoming connection, failed on automatic do_handshake(), stays open forever — accept() raises the SSLError and does not return client connection socket.

    Steps to reproduce
    ==================

    server side:

    1. create a SOCK_STREAM socket
    2. wrap it with wrap_socket()
    3. listen()
    4. accept()

    client side:

    1. telnet to this port
    2. enter any random text

    How reproducible
    ================

    In all 146%

    Expected results
    ================

    1. Incoming connection is closed and client disconnected

    Actual results
    ==============

    1. On the server side, due to exception, the reference to the incoming connection gets lost.
    2. The client stays connected as long as the server operates.

    @PeterSaveliev PeterSaveliev mannequin added the performance Performance or resource usage label May 6, 2013
    @PeterSaveliev
    Copy link
    Mannequin Author

    PeterSaveliev mannequin commented May 6, 2013

    Possible solution would be something like that in SSLSocket.do_handshake():

    try:
        self._sslobj.do_handshake()
    except SSLError as e:  # or even any Exception?
        self._sock.close()
        raise e
    

    @pitrou
    Copy link
    Member

    pitrou commented May 6, 2013

    Thanks for reporting. For maximum backwards compatibility, the safer fix is to close the socket only in SSLSocket.accept().
    Unfortunately I can't think of a way to write a unittest for it, so I'll just commit the fix.

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented May 6, 2013

    New changeset 85e5a93e534e by Antoine Pitrou in branch '2.7':
    Issue bpo-17918: When using SSLSocket.accept(), if the SSL handshake failed on the new socket, the socket would linger indefinitely.
    http://hg.python.org/cpython/rev/85e5a93e534e

    @pitrou pitrou closed this as completed May 6, 2013
    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    performance Performance or resource usage
    Projects
    None yet
    Development

    No branches or pull requests

    1 participant