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

cups/tls-gnutls.c: Use always GNUTLS_SHUT_WR #365

Merged
merged 1 commit into from Apr 7, 2022

Conversation

zdohnal
Copy link
Member

@zdohnal zdohnal commented Apr 6, 2022

The current mode for gnutls_bye() in client use cases strictly
follows TLS v1.2 standard, which in this particular part says:

Unless some other fatal alert has been transmitted, each party is
required to send a close_notify alert before closing the write
side of the connection.  The other party MUST respond with a
close_notify alert of its own and close down the connection immediately,
discarding any pending writes.  It is not required for the initiator
of the close to wait for the responding close_notify alert before
closing the read side of the connection.

and waits for the other side of TLS connection to confirm the close.

Unfortunately it can undesired for reasons:

  • we support switching of TLS versions in CUPS, and this mode strictly
    follows TLS v1.2 - so for older version this behavior is not expected
    and can cause delays
  • even some TLS v1.2 implementations (like Windows Server 2016) don't
    comply TLS v1.2 behavior even if it says it does - in that case,
    encrypted printing takes 30s till HTTP timeout is reached, because the
    other side didn't send confirmation
  • AFAIU openssl's SSL_shutdown() doesn't make this TLS v1.2 difference,
    so we could end up with two TLS implementations in CUPS which will
    behave differently

Since the standard defines that waiting for confirmation is not required
and due the problems above, I would propose using GNUTLS_SHUT_WR mode
regardless of HTTP mode.

The current mode for `gnutls_bye()` in client use cases strictly
follows TLS v1.2 standard, which in this particular part says:

```
Unless some other fatal alert has been transmitted, each party is
required to send a close_notify alert before closing the write
side of the connection.  The other party MUST respond with a
close_notify alert of its own and close down the connection immediately,
discarding any pending writes.  It is not required for the initiator
of the close to wait for the responding close_notify alert before
closing the read side of the connection.
```

and waits for the other side of TLS connection to confirm the close.

Unfortunately it can undesired for reasons:
- we support switching of TLS versions in CUPS, and this mode strictly
  follows TLS v1.2 - so for older version this behavior is not expected
  and can cause delays
- even some TLS v1.2 implementations (like Windows Server 2016) don't
  comply TLS v1.2 behavior even if it says it does - in that case,
  encrypted printing takes 30s till HTTP timeout is reached, because the
  other side didn't send confirmation
- AFAIU openssl's SSL_shutdown() doesn't make this TLS v1.2 difference,
  so we could end up with two TLS implementations in CUPS which will
  behave differently

Since the standard defines that waiting for confirmation is not required
and due the problems above, I would propose using GNUTLS_SHUT_WR mode
regardless of HTTP mode.
@zdohnal zdohnal added this to the 2.4.2 milestone Apr 6, 2022
Copy link
Member

@michaelrsweet michaelrsweet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK.

@zdohnal
Copy link
Member Author

zdohnal commented Apr 7, 2022

Thank you for the review!

@zdohnal zdohnal merged commit 6118495 into OpenPrinting:master Apr 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants