[pyOpenSSL] how to shutdown a socket?

Yann Leboulanger asterix at lagaule.org
Thu Aug 23 11:53:28 CEST 2012


On 08/22/2012 10:51 PM, Yann Leboulanger wrote:
> On 08/22/2012 10:44 PM, exarkun at twistedmatrix.com wrote:
>> On 07:13 pm, asterix at lagaule.org wrote:
>>> Hi,
>>>
>>> I'm having problems closing a OpenSSL.SSL.Conection.
>>
>> Hi Yann,
>>
>> Perhaps you can explain your goals in a little more detail. "Shutdown"
>> unfortunately has several possible meanings in the context of an SSL
>> connection.
>>
>> It could mean you want to perform an orderly SSL protocol shutdown.
>> There are two variations of this. You might want to do so without
>> shutting down the underlying (TCP?) connection. Or you might want to
>> shut down that underlying connection.
>>
>> Or it could just mean you want to close the connection, either in an
>> orderly fashion or otherwise (people tend to be sloppy about closing SSL
>> connections, particularly when using SSL for HTTPS).
>>
>> Shutdown and close are also distinct operations when it comes to the
>> underlying TCP connection. You might want to actually close the
>> underlying TCP connection, rather than just shutting it down.
>>
>> So, are any of those close to what you want to do? Please elaborate,
>> perhaps providing a short, self-contained, complete (minimal) example in
>> doing so (<http://sscce.org/>).
>>
>> Also, I have copied the Launchpad user list on this reply, as I would
>> consider it a great boon if pyOpenSSL eventually completely moved off of
>> sourceforge, including no longer using the sourceforge hosted mailing
>> list service.
>
> Hi,
>
> Thanks for your reply.
>
> What I want to do is to completly close the socket.
> My application opens a socket, transfer things, and once finished I want
> to close the socket.
>
>   From what I understand I'm supposed to call shutdown() then close() but
> that doesn't work for me :/
>
> It's hard for me to provide a small example, because haveing
> non-blocking sockets isn't donein 2 lines :/
>

After debugging and debugging again, I found that I did SSL over SSL ... 
And in this case I was not able to shutdown the second SSL connection.

Now that my code doesn't do SSL over SSL, I can corecly shutdown() and 
then close() the connection.

[OT] sad that shutdwn() doesn't take an argument like the standads 
socket. I know it's discussed in bug 900792:
https://bugs.launchpad.net/pyopenssl/+bug/900792

Sorry for the noise!
-- 
Yann




More information about the pyopenssl-users mailing list