summaryrefslogtreecommitdiff
path: root/src/lib/libtls/tls.h (follow)
Commit message (Collapse)AuthorAgeFilesLines
* Provide tls_peer_cert_common_name()tb2024-12-101-1/+2
| | | | | | | | | | | | | | | | There is currently no sane way of getting your hands on the common name or subject alternative name of the peer certificate from libtls. It is possible to extract it from the peer cert's PEM by hand, but that way lies madness. While the common name is close to being deprecated in the webpki, it is still the de facto standard to identify client certs. It would be nice to have a way to access the subject alternative names as well, but this is a lot more difficult to expose in a clean and sane C interface due to its multivaluedness. Initial diff from henning, with input from beck, jsing and myself henning and bluhm have plans of using this in syslogd. ok beck
* libtls: fix legacy protocol parsingtb2024-08-021-3/+3
| | | | | | | | | | | | | | | | | | | | Redefining TLS_PROTOCOL_TLSv1_0 and TLS_PROTOCOL_TLSv1_1 to be the same as TLS_PROTOCOL_TLSv1_2 had undesired side effects, as witnessed in the accompanying regress tests. The protocol string all:tlsv1.0 would disable TLSv1.2 (so only enable TLSv1.3) and tlsv1.2:!tlsv1.1 would disable all protocols. It makes more sense to ignore any setting of TLSv1.0 and TLSv1.1, so if you request 'tlsv1.1' you get no protocol, but 'all:!tlsv1.1' will enable the two supported protocols TLSv1.3 and TLSv1.2. Restore the defines to their original values and adjust the parsing code to set/unset them. Issue reported by Kenjiro Nakayama Fixes https://github.com/libressl/openbsd/issues/151 with/ok jsing
* Add TLS_ERROR_INVALID_ARGUMENT error code to libtlsjoshua2024-03-271-1/+2
| | | | | | | This is an initial pass, defining the error code and using it for "too long"/length-related errors. ok beck jsing
* Add TLS_ERROR_INVALID_CONTEXT error code to libtlsjoshua2024-03-261-1/+2
| | | | ok jsing@ beck@
* Add error code support to libtlsjoshua2024-03-261-1/+11
| | | | | | | | | This adds tls_config_error_code() and tls_error_code(), which will become public API at a later date. Additional error codes will be added in follow-up commits. ok jsing@ beck@
* Remove the ability to do tls 1.0 and 1.1 from libtls.beck2023-07-021-5/+9
| | | | | | | | With this change any requests from configurations to request versions of tls before tls 1.2 will use tls 1.2. This prepares us to deprecate tls 1.0 and tls 1.1 support from libssl. ok tb@
* Hide the tls_signer from public visibility. It's not ready yet andtb2022-03-241-21/+1
| | | | | | should not be used. It will be revisited after release. ok beck inoguchi jsing
* Provide our own signature padding defines.jsing2022-02-011-1/+5
| | | | | | | | Rather than leaking libcrypto defines through the tls_sign_cb and tls_signer_sign() interfaces, provide and use our own TLS_PADDING_* defines. ok inoguchi@ tb@
* Revise signer callback interface.jsing2022-02-011-7/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | The current design of tls_sign_cb provides a pointer to a buffer where the signature needs to be copied, however it fails to provide a length which could result in buffer overwrites. Furthermore, tls_signer_sign() is designed such that it allocates and returns ownership to the caller. Revise tls_sign_cb so that the called function is expected to allocate a buffer, returning ownership of the buffer (along with its length) to the caller of the callback. This makes it far easier (and safer) to implement a tls_sign_cb callback, plus tls_signer_sign can be directly plugged in (with an appropriate cast). While here, rename and reorder some arguments - while we will normally sign a digest, there is no requirement for this to be the case hence use 'input' and 'input_len'. Move padding (an input) before the outputs and add some additional bounds/return value checks. This is technically an API/ABI break that would need a libtls major bump, however since nothing is using the signer interface (outside of regress), we'll ride the original minor bump. With input from tb@ ok inoguchi@ tb@
* Introduce a signer interface intented to make TLS privsep simplereric2022-01-251-1/+17
| | | | | | | | | | | | | | | | to implement. Add a tls_config_set_sign_cb() function that allows to register a callback for the signing operation on a tls_config. When used, the context installs fake pivate keys internally, and the callback receives the hash of the public key. Add a tls_signer_*() set of functions to manage tls_signer objects. A tls_signer is an opaque structure on which keys are added. It is used to compute signatures with private keys identified by their associated public key hash. Discussed with and ok jsing@ tb@
* Enable TLS version 1.3 in the default protocols for libtls.beck2020-01-221-2/+2
| | | | | | | This will as yet not do anything, until we turn it on in the lower level libraries. ok jsing@
* Add support for TLSv1.3 as a protocol to libtls.jsing2020-01-201-3/+6
| | | | | | | This makes tls_config_parse_protocols() recognise and handle "tlsv1.3". If TLSv1.3 is enabled libtls will also request libssl to enable it. ok beck@ tb@
* Provide tls_conn_cipher_strength().jsing2019-11-021-1/+2
| | | | | | | | | This returns the strength in bits of the symmetric cipher used for the connection. Diff from gilles@ ok tb@
* expose the default cert file as a function, not a define. it's reallytedu2018-11-291-3/+3
| | | | | | an internal detail of the library, so the string should live inside it, not in the application code. ok jsing
* Define TLS_CA_CERT_FILE rather than having every application create theirjsing2018-11-061-1/+3
| | | | | | own define for /etc/ssl/cert.pem. ok beck@ bluhm@ tb@
* Bump TLS API version since we've added more functionality.jsing2018-02-101-2/+2
|
* Add support to libtls for client-side TLS session resumption.jsing2018-02-101-1/+3
| | | | | | | | | | | | 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@
* Add a tls_config_set_ecdhecurves() function to libtls, which allows thejsing2017-08-101-2/+3
| | | | | | | | | | names of the elliptic curves that may be used during client and server key exchange to be specified. This deprecates tls_config_set_ecdhecurve(), which could only be used to specify a single supported curve. ok beck@
* Add support for providing CRLs to libtls - once a CRL is provided wejsing2017-07-061-1/+4
| | | | | | | | enable CRL checking for the full certificate chain. Based on a diff from Jack Burton <jack at saosce dot com dot au>, thanks! Discussed with beck@
* Provide a tls_unload_file() function, that frees the memory returned fromjsing2017-05-061-1/+2
| | | | | | | | a tls_load_file() call, ensuring that it the contents become inaccessible. This is specifically needed on platforms where the library allocators may be different from the application allocator. ok beck@
* Add tls_peer_cert_chain_pem - To retreive the peer certificate and chainbeck2017-04-051-1/+2
| | | | | | | as PEM format. This allows for it to be used or examined with tools external to libtls bump minor ok jsing@
* Add tls_config_[add|set]keypair_ocsp functions so that ocsp staples may bebeck2017-01-311-4/+14
| | | | | | | | added associated to a keypair used for SNI, and are usable for more than just the "main" certificate. Modify httpd to use this. Bump libtls minor. ok jsing@
* Bump TLS_API due to new features being added earlier this week.jsing2017-01-261-2/+2
|
* Introduce ticket support. To enable them it is enough to set a positiveclaudio2017-01-241-1/+10
| | | | | | | | | | | | | | | | | | | | lifetime with tls_config_set_session_lifetime(). This enables tickets and uses an internal automatic rekeying mode for the ticket keys. If multiple processes are involved the following functions can be used to make tickets work accross all instances: - tls_config_set_session_id() sets the session identifier - tls_config_add_ticket_key() adds an encryption and authentication key For now only the last 4 keys added will be used (unless they are too old). If tls_config_add_ticket_key() is used the caller must ensure to add new keys regularly. It is best to do this 4 times per session lifetime (which is also the ticket key lifetime). Since tickets break PFS it is best to minimize the session lifetime according to needs. With a lot of help, input and OK beck@, jsing@
* Wrap long lines.jsing2017-01-221-4/+7
|
* Bump TLS_API due to recent feature additions and changes.jsing2016-11-111-2/+2
|
* Change the return value of tls_config_set_protocols() andjsing2016-11-111-3/+3
| | | | | | | | | | tls_config_set_verify_depth() from void to int. This makes them consistent with all other tls_config_set_* functions and will allow for call time validation to be implemented. Rides libtls major bump. ok beck@
* Add support for server side OCSP stapling to libtls.beck2016-11-051-1/+3
| | | | Add support for server side OCSP stapling to netcat.
* Add ocsp_require_stapling config option for tls - allows a connectionbeck2016-11-041-1/+2
| | | | | | to indicate that it requires the peer to provide a stapled OCSP response with the handshake. Provide a "-T muststaple" for nc that uses it. ok jsing@, guenther@
* Add OCSP client side support to libtls.beck2016-11-021-1/+36
| | | | | | | | | | | | | - Provide access to certificate OCSP URL - Provide ability to check a raw OCSP reply against an established TLS ctx - Check and validate OCSP stapling info in the TLS handshake if a stapled OCSP response is provided.` Add example code to show OCSP URL and stapled info into netcat. ok jsing@
* add a little more typing to the first callback argument.tedu2016-09-131-3/+3
| | | | it's always a tls context.
* Bump TLS_API for addition of callbacks.jsing2016-09-041-2/+2
|
* Add callback-based interface to libtls.bcook2016-09-041-1/+10
| | | | | | | 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@
* Bump TLS_API due to the addition of server side SNI functions.jsing2016-08-221-2/+2
|
* Provide an API that enables server side SNI support - add the ability tojsing2016-08-221-1/+7
| | | | | | | | provide additional keypairs (via tls_config_add_keypair_{file,mem}()) and allow the server to determine what servername the client requested (via tls_conn_servername()). ok beck@
* Add ALPN support to libtls.jsing2016-08-121-3/+5
| | | | ok beck@ doug@
* Revert previous since it adds new symbols.jsing2016-08-021-4/+2
| | | | Requested by deraadt@
* Bump TLS_API for addition of ALPN support.jsing2016-08-011-2/+2
|
* Add ALPN support to libtls.jsing2016-08-011-2/+4
| | | | ok beck@ doug@
* Fix function parameters that do not have an underscore prefix.jsing2016-05-271-10/+10
|
* Factor our the keypair handling in libtls. This results in more readablejsing2016-04-281-1/+5
| | | | | | | | | 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@
* Rework the error handling in libtls so that we can associate errors withjsing2016-04-281-1/+2
| | | | | | | | | | | both configuration and contexts. This allows us to propagate errors that occur during configuration, rather than either just failing with no reason or delaying the failure until it can be propagated via the tls context. Also provide a tls_config_error() function for retrieving the last error from a tls_config *. ok bcook@
* Add tls_peer_cert_notbefore and tls_peer_cert_notafter to expose peer ↵beck2015-10-071-1/+4
| | | | | | | certificate validity times for tls connections. ok jsing@
* include <sys/types.h> for ssize_tbcook2015-10-011-1/+3
| | | | ok jsing@, deraadt@
* Provide tls_config_insecure_noverifytime() in order to be able to disablejsing2015-09-141-1/+2
| | | | | | certificate validity checking. ok beck@
* add visibility of ciper and connection version stringsbeck2015-09-131-1/+3
| | | | ok jsing@
* Move connection info into it's own private structure allocated and filled inbeck2015-09-121-4/+4
| | | | | | at handshake time. change accessors to return const char * to remove need for caller to free memory. ok jsing@
* Put tls_peer_cert* functions in the same place.jsing2015-09-121-6/+6
|
* add tls_peer functions for checking names and issuers of peer certificates.beck2015-09-111-1/+6
| | | | ok jsing@
* Provide tls_peer_cert_hash() which returns a hash of the raw certificatejsing2015-09-111-1/+3
| | | | | | | | | | | | | that was presented by the peer. The hash used is currently SHA256, however since we prefix the result with the hash name, we can change this in the future as the need arises. The same output can be generated by using: h=$(openssl x509 -outform der -in mycert.crt | sha256) printf "SHA256:${h}\n" ok beck@