summaryrefslogtreecommitdiffstats
path: root/lib/libssl/ssl_lib.c
diff options
context:
space:
mode:
authortb <tb@openbsd.org>2020-12-01 07:46:01 +0000
committertb <tb@openbsd.org>2020-12-01 07:46:01 +0000
commitd12948999a0d2338528291933d8d2cc098bdf12c (patch)
treeb8b6c7666e2d8af2af7e0ef8ca7f7c3fe1ca88de /lib/libssl/ssl_lib.c
parentupdate currency exchange rates; (diff)
downloadwireguard-openbsd-d12948999a0d2338528291933d8d2cc098bdf12c.tar.xz
wireguard-openbsd-d12948999a0d2338528291933d8d2cc098bdf12c.zip
Bring back *_client_method() structs
The method unification broke an API promise of SSL_is_server(). According to the documentation, calling SSL_is_server() on SSL objects constructed from generic and server methods would result in 1 even before any call to SSL_set_accept_state(). This means the information needs to be available when SSL_new() is called, so must come from the method itself. Prior to the method unification, s->server would be set to 0 or 1 in SSL_new() depending on whether the accept method was undefined or not. Instead, introduce a flag to the internal structs to distinguish client methods from server and generic methods and copy that flag to s->server in SSL_new(). This problem was reported to otto due to breakage of DoH in net/dnsdist. The reason for this is that www/h2o relies on SSL_is_server() to decide whether to call SSL_accept() or SSL_connect(). Thus, the h2o server would end up responding to a ClientHello with another ClientHello, which results in a handshake failure. The bandaid applied to www/h2o can be removed once this fix has made it into snaps. No other breakage is known. This commit brings back only about half of the duplication removed in the method unification, so is preferable to a full revert. ok jsing
Diffstat (limited to 'lib/libssl/ssl_lib.c')
-rw-r--r--lib/libssl/ssl_lib.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/libssl/ssl_lib.c b/lib/libssl/ssl_lib.c
index 58b9dae9102..69628b48df7 100644
--- a/lib/libssl/ssl_lib.c
+++ b/lib/libssl/ssl_lib.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ssl_lib.c,v 1.238 2020/11/16 18:55:15 jsing Exp $ */
+/* $OpenBSD: ssl_lib.c,v 1.239 2020/12/01 07:46:01 tb Exp $ */
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
@@ -345,7 +345,7 @@ SSL_new(SSL_CTX *ctx)
goto err;
s->references = 1;
- s->server = 0;
+ s->server = ctx->method->internal->server;
SSL_clear(s);