summaryrefslogtreecommitdiffstats
path: root/ssl
diff options
context:
space:
mode:
authorTomas Mraz <tomas@openssl.org>2023-10-17 10:00:58 +0200
committerMatt Caswell <matt@openssl.org>2023-10-20 16:29:28 +0100
commit7757f5ef731ad4e8d6c0f59ef752e4f726ba4f90 (patch)
treebac56bfc65b11b4d72cff176130d95fa780fa2d8 /ssl
parent8e520d2714abf4c6254ceec24b57f238433541ee (diff)
QUIC: Add handling of SSL_get_shutdown()
Return SSL_SENT_SHUTDOWN and SSL_RECEIVED_SHUTDOWN with semantics similar to TLS connections. Reviewed-by: Hugo Landau <hlandau@openssl.org> Reviewed-by: Matt Caswell <matt@openssl.org> (Merged from https://github.com/openssl/openssl/pull/22408)
Diffstat (limited to 'ssl')
-rw-r--r--ssl/quic/quic_channel.c2
-rw-r--r--ssl/quic/quic_impl.c21
-rw-r--r--ssl/ssl_lib.c13
3 files changed, 31 insertions, 5 deletions
diff --git a/ssl/quic/quic_channel.c b/ssl/quic/quic_channel.c
index 3b9993b96a..8e75eda539 100644
--- a/ssl/quic/quic_channel.c
+++ b/ssl/quic/quic_channel.c
@@ -635,7 +635,7 @@ int ossl_quic_channel_is_active(const QUIC_CHANNEL *ch)
return ch != NULL && ch->state == QUIC_CHANNEL_STATE_ACTIVE;
}
-static int ossl_quic_channel_is_closing(const QUIC_CHANNEL *ch)
+int ossl_quic_channel_is_closing(const QUIC_CHANNEL *ch)
{
return ch->state == QUIC_CHANNEL_STATE_TERMINATING_CLOSING;
}
diff --git a/ssl/quic/quic_impl.c b/ssl/quic/quic_impl.c
index 29a283dca0..bdf5d5fea8 100644
--- a/ssl/quic/quic_impl.c
+++ b/ssl/quic/quic_impl.c
@@ -3572,6 +3572,27 @@ const SSL_CIPHER *ossl_quic_get_cipher(unsigned int u)
}
/*
+ * SSL_get_shutdown()
+ * ------------------
+ */
+int ossl_quic_get_shutdown(const SSL *s)
+{
+ QCTX ctx;
+ int shut = 0;
+
+ if (!expect_quic_conn_only(s, &ctx))
+ return 0;
+
+ if (ossl_quic_channel_is_term_any(ctx.qc->ch)) {
+ shut |= SSL_SENT_SHUTDOWN;
+ if (!ossl_quic_channel_is_closing(ctx.qc->ch))
+ shut |= SSL_RECEIVED_SHUTDOWN;
+ }
+
+ return shut;
+}
+
+/*
* Internal Testing APIs
* =====================
*/
diff --git a/ssl/ssl_lib.c b/ssl/ssl_lib.c
index f15fe126a2..bd9160b756 100644
--- a/ssl/ssl_lib.c
+++ b/ssl/ssl_lib.c
@@ -5142,7 +5142,7 @@ void SSL_set_quiet_shutdown(SSL *s, int mode)
{
SSL_CONNECTION *sc = SSL_CONNECTION_FROM_SSL_ONLY(s);
- /* TODO(QUIC): Currently not supported for QUIC. */
+ /* Not supported with QUIC */
if (sc == NULL)
return;
@@ -5153,7 +5153,7 @@ int SSL_get_quiet_shutdown(const SSL *s)
{
const SSL_CONNECTION *sc = SSL_CONNECTION_FROM_CONST_SSL_ONLY(s);
- /* TODO(QUIC): Currently not supported for QUIC. */
+ /* Not supported with QUIC */
if (sc == NULL)
return 0;
@@ -5164,7 +5164,7 @@ void SSL_set_shutdown(SSL *s, int mode)
{
SSL_CONNECTION *sc = SSL_CONNECTION_FROM_SSL_ONLY(s);
- /* TODO(QUIC): Do we want this for QUIC? */
+ /* Not supported with QUIC */
if (sc == NULL)
return;
@@ -5175,7 +5175,12 @@ int SSL_get_shutdown(const SSL *s)
{
const SSL_CONNECTION *sc = SSL_CONNECTION_FROM_CONST_SSL_ONLY(s);
- /* TODO(QUIC): Do we want this for QUIC? */
+#ifndef OPENSSL_NO_QUIC
+ /* QUIC: Just indicate whether the connection was shutdown cleanly. */
+ if (IS_QUIC(s))
+ return ossl_quic_get_shutdown(s);
+#endif
+
if (sc == NULL)
return 0;