<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">Hi.<div class=""><br class=""></div><div class="">This is something that I’m also interested, as a contributor to Libevent, which provides SSL-socket support.</div><div class=""><br class=""></div><div class="">I’ve opened an OpenSSL issue:</div><div class=""><br class=""></div><div class=""><a href="https://github.com/openssl/openssl/issues/6911" class="">https://github.com/openssl/openssl/issues/6911</a></div><div class=""><br class=""></div><div class="">to collect the details on how a graceful shutdown can be implemented in Libevent.</div><div class=""><br class=""></div><div class="">Thanks,</div><div class=""><br class=""></div><div class="">-Philip</div><div class=""><br class=""><div><br class=""><blockquote type="cite" class=""><div class="">On Aug 1, 2018, at 1:46 PM, Alex H <<a href="mailto:alexhultman@gmail.com" class="">alexhultman@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class=""><div class="">[...] The other party MUST respond with a close_notify alert of its own and close down the connection immediately, <b class="">discarding any pending writes</b>.</div><div class=""><br class=""></div><div class="">I've read this before, but I've also checked the sources of SSL_write and they seem contradictory:<br class=""></div><div class=""><br class=""></div><div class="">SSL_write does not return with error when SSL_RECEIVED_SHUTDOWN is set, but does so when SSL_SENT_SHUTDOWN is set. Why is this? A minor bug? If the RFC states the end who receives a close_notify should <b class="">discard any pending writes</b> then it surely seems a bug to allow SSL_write for a connection where SSL_RECEIVED_SHUTDOWN is set?</div><div class=""><br class=""></div><div class="">....</div><div class=""><br class=""></div><div class="">> If your question is whether you can still read any data that may have<br class="">
been in flight when you send your close_notify, I believe the answer<br class="">
is no.  Further data received from the peer is discarded after a<br class="">
close_notify is sent.<br class=""></div><div class=""><br class=""></div><div class="">I also believe so, especially since SSL_shutdown docs seem to hint that once SSL_shutdown is called, it should be called again until fully done (serving SSL_WANT_READ/WRITE as needed). In other words, SSL_shutdown becomes the only function called until the SSL connection is fully closed, no more SSL_read is called and thus it cannot report any received data. SSL_shutdown does not return with any data.</div><div class=""><br class=""></div><div class="">Regarding the SSL_RECEIVED_SHUTDOWN - do you think this is a minor bug?<br class=""></div></div><br class=""><div class="gmail_quote"><div dir="ltr" class="">Den ons 1 aug. 2018 kl 21:16 skrev Viktor Dukhovni <<a href="mailto:openssl-users@dukhovni.org" class="">openssl-users@dukhovni.org</a>>:<br class=""></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br class="">
<br class="">
> On Aug 1, 2018, at 2:27 AM, Alex H <<a href="mailto:alexhultman@gmail.com" target="_blank" class="">alexhultman@gmail.com</a>> wrote:<br class="">
> <br class="">
> Is it possible to receive data after calling SSL_shutdown? Reading the specs and docs leaves this rather blurry.<br class="">
<br class="">
TLS *does not* support half-closed connections (RFC5246):<br class="">
<br class="">
   close_notify<br class="">
      This message notifies the recipient that the sender will not send<br class="">
      any more messages on this connection.  Note that as of TLS 1.1,<br class="">
      failure to properly close a connection no longer requires that a<br class="">
      session not be resumed.  This is a change from TLS 1.0 to conform<br class="">
      with widespread implementation practice.<br class="">
<br class="">
   Either party may initiate a close by sending a close_notify alert.<br class="">
   Any data received after a closure alert is ignored.<br class="">
<br class="">
   Unless some other fatal alert has been transmitted, each party is<br class="">
   required to send a close_notify alert before closing the write side<br class="">
   of the connection.  The other party MUST respond with a close_notify<br class="">
   alert of its own and close down the connection immediately,<br class="">
   discarding any pending writes.  It is not required for the initiator<br class="">
   of the close to wait for the responding close_notify alert before<br class="">
   closing the read side of the connection.<br class="">
<br class="">
   If the application protocol using TLS provides that any data may be<br class="">
   carried over the underlying transport after the TLS connection is<br class="">
   closed, the TLS implementation must receive the responding<br class="">
   close_notify alert before indicating to the application layer that<br class="">
   the TLS connection has ended.  If the application protocol will not<br class="">
   transfer any additional data, but will only close the underlying<br class="">
   transport connection, then the implementation MAY choose to close the<br class="">
   transport without waiting for the responding close_notify.  No part<br class="">
   of this standard should be taken to dictate the manner in which a<br class="">
   usage profile for TLS manages its data transport, including when<br class="">
   connections are opened or closed.<br class="">
<br class="">
   Note: It is assumed that closing a connection reliably delivers<br class="">
   pending data before destroying the transport.<br class="">
<br class="">
If your question is whether you can still read any data that may have<br class="">
been in flight when you send your close_notify, I believe the answer<br class="">
is no.  Further data received from the peer is discarded after a<br class="">
close_notify is sent.<br class="">
<br class="">
-- <br class="">
        Viktor.<br class="">
<br class="">
-- <br class="">
openssl-users mailing list<br class="">
To unsubscribe: <a href="https://mta.openssl.org/mailman/listinfo/openssl-users" rel="noreferrer" target="_blank" class="">https://mta.openssl.org/mailman/listinfo/openssl-users</a><br class="">
</blockquote></div>
-- <br class="">openssl-users mailing list<br class="">To unsubscribe: <a href="https://mta.openssl.org/mailman/listinfo/openssl-users" class="">https://mta.openssl.org/mailman/listinfo/openssl-users</a><br class=""></div></blockquote></div><br class=""></div></body></html>