pyopenssl icon indicating copy to clipboard operation
pyopenssl copied to clipboard

get_shutdown not properly working?

Open bortzmeyer opened this issue 4 years ago • 0 comments

In a TLS client, I observe that, after a session.shutdown(), session.get_shutdown() returns 1 (shutdown sent, no shutdown received). But OpenSSL on the command line with the same server show me that the server does send a close_notify:

<<< TLS 1.3 [length 0001]
    15
<<< TLS 1.3, Alert [length 0002], warning close_notify
    01 00
closed

I see in https://www.openssl.org/docs/man1.1.1/man3/SSL_get_shutdown.html that OpenSSL's get_shutdown can return 1 if we do not wait the close_notify from the server but, here, it is sent before my client sends its own shutdown.

The bug (?) comes from https://framagit.org/bortzmeyer/agunua/-/issues/50 Agunua is a Gemini client, available at https://framagit.org/bortzmeyer/agunua/ A full test is:


% ./agunua gemini://gemini.bortzmeyer.org/doesnotexist
get_shutdown returns: 1
Warning, no TLS shutdown received from the server
Problem, Not found (extra message: "File not found").

% printf "gemini://gemini.bortzmeyer.org/doesnotexist\r\n" |  openssl s_client -ign_eof -msg -connect gemini.bortzmeyer.org:1965
read R BLOCK
<<< ??? [length 0005]
    17 03 03 00 24
<<< TLS 1.3 [length 0001]
    17
51 File not found
<<< ??? [length 0005]
    17 03 03 00 13
<<< TLS 1.3 [length 0001]
    15
<<< TLS 1.3, Alert [length 0002], warning close_notify
    01 00
closed
>>> ??? [length 0005]
    17 03 03 00 13
>>> TLS 1.3 [length 0001]
    15
>>> TLS 1.3, Alert [length 0002], warning close_notify
    01 00
...


bortzmeyer avatar Nov 28 '21 09:11 bortzmeyer