summaryrefslogtreecommitdiff
path: root/lib/libtls/tls_conninfo.c
diff options
context:
space:
mode:
authorJoel Sing <jsing@cvs.openbsd.org>2018-02-10 04:41:25 +0000
committerJoel Sing <jsing@cvs.openbsd.org>2018-02-10 04:41:25 +0000
commit995ed69762577d52380bf729ab06c8822257eb18 (patch)
treeced0f54d178cfb5810c63ef6afc6684ad6a26e98 /lib/libtls/tls_conninfo.c
parentc362bb3830fe2aeec3e45bae3d555b7f46132851 (diff)
Add support to libtls for client-side TLS session resumption.
A libtls client can specify a session file descriptor (a regular file with appropriate ownership and permissions) and libtls will manage reading and writing of session data across TLS handshakes. Discussed at length with deraadt@ and tedu@. Rides previous minor bump. ok beck@
Diffstat (limited to 'lib/libtls/tls_conninfo.c')
-rw-r--r--lib/libtls/tls_conninfo.c21
1 files changed, 20 insertions, 1 deletions
diff --git a/lib/libtls/tls_conninfo.c b/lib/libtls/tls_conninfo.c
index 685ed194e4e..34535b5668c 100644
--- a/lib/libtls/tls_conninfo.c
+++ b/lib/libtls/tls_conninfo.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: tls_conninfo.c,v 1.17 2018/02/08 10:02:48 jsing Exp $ */
+/* $OpenBSD: tls_conninfo.c,v 1.18 2018/02/10 04:41:24 jsing Exp $ */
/*
* Copyright (c) 2015 Joel Sing <jsing@openbsd.org>
* Copyright (c) 2015 Bob Beck <beck@openbsd.org>
@@ -221,6 +221,14 @@ tls_conninfo_cert_pem(struct tls *ctx)
return rv;
}
+static int
+tls_conninfo_session(struct tls *ctx)
+{
+ ctx->conninfo->session_resumed = SSL_session_reused(ctx->ssl_conn);
+
+ return 0;
+}
+
int
tls_conninfo_populate(struct tls *ctx)
{
@@ -260,6 +268,9 @@ tls_conninfo_populate(struct tls *ctx)
if (tls_conninfo_cert_pem(ctx) == -1)
goto err;
+ if (tls_conninfo_session(ctx) == -1)
+ goto err;
+
return (0);
err:
@@ -313,6 +324,14 @@ tls_conn_servername(struct tls *ctx)
return (ctx->conninfo->servername);
}
+int
+tls_conn_session_resumed(struct tls *ctx)
+{
+ if (ctx->conninfo == NULL)
+ return (0);
+ return (ctx->conninfo->session_resumed);
+}
+
const char *
tls_conn_version(struct tls *ctx)
{