Hi,

On Tue, Jul 31, 2018 at 9:56 PM Xuelei Fan <xuelei....@oracle.com> wrote:
> Hm, I see your point.  Because of the half-close policy, I think the
> server could keep sending messages other than the close_notify alert.

Exactly.

> My concern of the CLOSED+NOT_HANDSHAKING is that it does not indicate
> the following operations.

Sure it does. CLOSED while unwrapping tells the application that the
other side has closed.
Now the application has a choice: it can wrap() more data, or call
closeOutbound().
>From there, it follows SSLEngine instructions via the states.
Having to take into consideration not only the Result, not only the
HandshakeStatus, but also bytes produced seems weird to me.
I'd prefer to just rely only on Result and HandshakeStatus.

> Yes, but it is the desired behavior to me.  For the TLS 1.3 half close
> policy, it is not expected to generate close_notify reply unless the
> server close its outbound.  So the server can keep sending the
> application data after the read close, as it write side is open.

Exactly.

> The TLS 1.3 spec says:
>    "Each party MUST send a "close_notify" alert before closing its write
>     side of the connection, unless it has already sent some error alert.
>     This does not have any effect on its read side of the connection."
>
> And the SSLEngine.closeOutbound() spec says:
>     "Signals that no more outbound application data will be sent on
>      this SSLEngine."
>
> I think it is fine to keep the write side open while the read side closed.
>
> In this update, for TLS 1.2 connection, the duplex-close behavior is
> reserved: as the server received the close_notify, it moving to
> NEED_WRAP; and the a close_notify will be delivered, and then duplex
> close the connection.

Exactly, and without the need for the receiver of the close_notify to
call closeOutbound().
That will be a difference between TLS 1.2 and TLS 1.3 that
applications should take into consideration.

> However, for TLS 1.3 connection, if there is no call to
> server.closeOutbound(), the server write side keeps open even the read
> side has been closed.
>
> In this update, for TLS 1.3, I tried to support half-close for:
> 1. SSLEngine.closeIn/Outbound()
> 2. SSLSocket.shutdownIn/Output()
>
> and duplex-close for:
> 3. SSLSocket.close()
>
> Unfortunately, it does introduce a compatibility issue that an existing
> application may not close both inbound and outbound if the connection is
> desired to be duplex-closed.  In order to mitigate the impact, a new
> System Property in introduced, "jdk.tls.acknowledgeCloseNotify".  This
> compatibility issues could be mitigated by closing both inbound and
> outbound explicitly, or set the property to "true".  If the property
> value is "true", a corresponding close_notify alert will be sent when
> receiving a close_notify alert, and therefore the connection will be
> duplex closed.
>
> Does it make sense to you?

Yes.

Although I think application will need to make adjustments for TLS 1.3 anyway.
That system property will smooth things, but won't guarantee that an
application written for SSLEngine TLS 1.2 will work for SSLEngine TLS
1.3.

Thanks!

-- 
Simone Bordet
---
Finally, no matter how good the architecture and design are,
to deliver bug-free software with optimal performance and reliability,
the implementation technique must be flawless.   Victoria Livschitz

Reply via email to