1
0
mirror of https://github.com/openbsd/src.git synced 2025-01-10 06:47:55 -08:00
Commit Graph

28 Commits

Author SHA1 Message Date
bcook
4e91ee0b35 Set callbacks on the right tls ctx on accept.
From Tobias Pape
2016-09-14 11:34:37 +00:00
jsing
2233a86c2f Maintain consistency with function naming. 2016-09-04 13:20:56 +00:00
bcook
ed19021f58 Add callback-based interface to libtls.
This allows working with buffers and callback functions instead of directly on
sockets or file descriptors.
Original patch from Tobias Pape <tobias_at_netshed.de>.
ok beck@
2016-09-04 12:26:43 +00:00
jsing
f89edc012d Create contexts for server side SNI - these include the additional SSL_CTX
that is required for certificate switching with libssl and the certificate
itself so that we can match against the subject and SANs. Hook up the
servername callback and switch to the appropriate SSL_CTX if we find a
matching certificate.

ok beck@
2016-08-22 14:51:37 +00:00
jsing
991d42a128 Split out the TLS server SSL_CTX allocation and configuration code, so
that it can be reused to allocate the additional SSL_CTXs needed for SNI.

ok reyk@
2016-08-18 15:52:03 +00:00
jsing
b7f318e776 Explicitly pass in an SSL_CTX * to the functions that operate on one,
instead of assuming that they should use the one associated with the TLS
context. This allows these functions to be used with the additional
SSL contexts that are needed to support server-side SNI.

Also rename tls_configure_keypair() to tls_configure_ssl_keypair(), so that
these functions have a common prefix.

ok reyk@
2016-08-15 14:04:23 +00:00
jsing
183da8c641 Add ALPN support to libtls.
ok beck@ doug@
2016-08-12 15:10:59 +00:00
jsing
380117c0ca Revert previous since it adds new symbols.
Requested by deraadt@
2016-08-02 07:47:11 +00:00
jsing
623e6e8282 Add ALPN support to libtls.
ok beck@ doug@
2016-08-01 17:32:19 +00:00
jsing
1fe9fea1eb Factor our the keypair handling in libtls. This results in more readable
and self-contained code, while preparing for the ability to handle
multiple keypairs. Also provide two additional functions that allow
a public certificate and private key to be set with a single function
call.

ok beck@
2016-04-28 17:05:59 +00:00
deraadt
810e306d0a clean some ugly intendation warts 2015-09-29 10:17:04 +00:00
jsing
9ba095aa2b Ensure that we clear the libssl error stack before we make a function call
that we will pass the result through tls_ssl_error() on failure. Otherwise
we can end up reporting spurious errors due to their being unrelated errors
already on the error stack.

Spotted by Marko Kreen.

ok beck@
2015-09-12 19:54:31 +00:00
beck
521d38f20c actually set return value to 0 on success.
ok jsing@ who wears the cone of shame.
2015-09-11 08:31:26 +00:00
jsing
e2b71c1183 Split tls_handshake() out from tls_accept/tls_connect. By doing this the
tls_accept/tls_connect functions can be guaranteed to succeed or fail and
will no longer return TLS_READ_AGAIN/TLS_WRITE_AGAIN. This also resolves
the semantics of tls_accept_*.

The tls_handshake() function now does I/O and can return
TLS_READ_AGAIN/TLS_WRITE_AGAIN. Calls to tls_read() and tls_write() will
trigger the handshake if it has not already completed, meaning that in many
cases existing code will continue to work.

Discussed over many coffees at l2k15.

ok beck@ bluhm@
2015-09-10 10:14:20 +00:00
jsing
c57e6ec010 Add support for preferring the server's cipher list or the client's cipher
list. Prefer the server's cipher list by default.

Based on a diff from Kyle Thompson <jmp at giga dot moe>.

ok beck@ bcook@
2015-09-10 09:10:42 +00:00
jsing
240d3da60b Indent labels with a space so that diff -p is more friendly.
Requested by bluhm@
2015-09-09 19:49:07 +00:00
beck
51f3bd3dbc Add client certificate support. Still needs a few tweaks but this will
ride upcoming minor bump
ok jsing@
2015-09-09 19:23:04 +00:00
jsing
aa7238e62d Only take ownership of a socket if we allocated it within libtls. If we are
passed a socket then the caller is responsible for closing it.

ok bcook@
2015-09-09 14:32:06 +00:00
jsing
fdb1c79f59 Improve libtls error messages.
The tls_set_error() function previously stored the errno but did nothing
with it. Change tls_set_error() to append the strerror(3) of the stored
errno so that we include useful information regarding failures.

Provide a tls_set_errorx() function that does not store the errno or
include strerror(3) in the error message. Call this function instead of
tls_set_error() for errors where the errno value has no useful meaning.

With feedback from and ok doug@
2015-08-27 15:26:49 +00:00
jsing
31ee3a2bbd Unify error message between client and server. 2015-08-22 14:52:39 +00:00
jsing
8c73da28b3 SSL_set_app_data is a macro for SSL_set_ex_data(), which is a wrapper
around CRYPTO_set_ex_data(), which can fail. Since this is the case, check
the return value of CRYPTO_set_ex_data^WSSL_set_ex_data^WSSL_set_app_data.
2015-08-22 14:51:34 +00:00
jsing
e1e4dea2b5 Provide a tls_accept_fds() function, which allows a TLS connection to be
accepted via an existing pair of file descriptors.

Based on a diff from Jan Klemkow.
2015-03-31 14:03:38 +00:00
jsing
5251ab8ebf Store errors that occur during a tls_accept_socket() call on the context
for the server, rather than on the context for the connection. This makes
more sense than the current behaviour does.

Issue reported by Tim van der Molen.
2015-03-31 12:21:27 +00:00
jsing
d474f84fda Convert tls_connect_fds() and tls_accept_socket() to the new OpenSSL error
dance handling code. This means that we get slightly useful messages when
a TLS connection or accept fails.

Requested by reyk@
2015-02-07 09:50:09 +00:00
jsing
9e5deb484b Add tls_config_set_dheparams() to allow specification of the parameters to
use for DHE. This enables the use of DHE cipher suites.

Rename tls_config_set_ecdhcurve() to tls_config_set_ecdhecurve() since it
is only used to specify the curve for ephemeral ECDH.

Discussed with reyk@
2015-02-07 06:19:26 +00:00
bluhm
f30b95a158 Make the TLS connect and accept error messages consistent.
OK jsing@
2015-01-30 14:25:37 +00:00
reyk
31413d7e14 The SSL/TLS session Id context is limited to 32 bytes. Instead of
using the name of relayd relay or smtpd pki, use a 32 byte arc4random
buffer that should be unique for the context.  This fixes an issue in
OpenSMTPD when a long pki name could break the configuration.

OK gilles@ benno@
2015-01-16 14:34:51 +00:00
jsing
b600beed7b Rename libressl to libtls to avoid confusion and to make it easier to
distinguish between LibreSSL (the project) and libressl (the library).

Discussed with many.
2014-10-31 13:46:17 +00:00