diff options
| author | jsing <> | 2022-08-17 07:39:19 +0000 |
|---|---|---|
| committer | jsing <> | 2022-08-17 07:39:19 +0000 |
| commit | 5f133a78eec6f3a2549c066b9a561d6350d6e07a (patch) | |
| tree | d4b208572f46a7c773aecb3e2d410aeaae5e817a /src/lib/libssl/ssl_lib.c | |
| parent | 726478d55d7f47f50feb22b91bfcb268950310ac (diff) | |
| download | openbsd-5f133a78eec6f3a2549c066b9a561d6350d6e07a.tar.gz openbsd-5f133a78eec6f3a2549c066b9a561d6350d6e07a.tar.bz2 openbsd-5f133a78eec6f3a2549c066b9a561d6350d6e07a.zip | |
Deduplicate peer certificate chain processing code.
Rather than reimplement this in each TLS client and server, deduplicate it
into a single function. Furthermore, rather than dealing with the API
hazard that is SSL_get_peer_cert_chain() in this code, simply produce two
chains - one that has the leaf and one that does not.
SSL_get_peer_cert_chain() can then return the appropriate one.
This also moves the peer cert chain from the SSL_SESSION to the
SSL_HANDSHAKE, which makes more sense since it is not available on
resumption.
ok tb@
Diffstat (limited to '')
| -rw-r--r-- | src/lib/libssl/ssl_lib.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/src/lib/libssl/ssl_lib.c b/src/lib/libssl/ssl_lib.c index e346e3cf7f..9af1934dd6 100644 --- a/src/lib/libssl/ssl_lib.c +++ b/src/lib/libssl/ssl_lib.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: ssl_lib.c,v 1.300 2022/07/24 15:05:16 jsing Exp $ */ | 1 | /* $OpenBSD: ssl_lib.c,v 1.301 2022/08/17 07:39:19 jsing Exp $ */ |
| 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) |
| 3 | * All rights reserved. | 3 | * All rights reserved. |
| 4 | * | 4 | * |
| @@ -880,14 +880,17 @@ SSL_get_peer_certificate(const SSL *s) | |||
| 880 | STACK_OF(X509) * | 880 | STACK_OF(X509) * |
| 881 | SSL_get_peer_cert_chain(const SSL *s) | 881 | SSL_get_peer_cert_chain(const SSL *s) |
| 882 | { | 882 | { |
| 883 | if (s == NULL || s->session == NULL) | 883 | if (s == NULL) |
| 884 | return NULL; | 884 | return NULL; |
| 885 | 885 | ||
| 886 | /* | 886 | /* |
| 887 | * If we are a client, cert_chain includes the peer's own | 887 | * Achtung! Due to API inconsistency, a client includes the peer's leaf |
| 888 | * certificate; if we are a server, it does not. | 888 | * certificate in the peer certificate chain, while a server does not. |
| 889 | */ | 889 | */ |
| 890 | return s->session->cert_chain; | 890 | if (!s->server) |
| 891 | return s->s3->hs.peer_certs; | ||
| 892 | |||
| 893 | return s->s3->hs.peer_certs_no_leaf; | ||
| 891 | } | 894 | } |
| 892 | 895 | ||
| 893 | STACK_OF(X509) * | 896 | STACK_OF(X509) * |
