NAME


SSL_add_expected_rpk, SSL_get_negotiated_client_cert_type, SSL_get_negotiated_server_cert_type, SSL_get0_peer_rpk, SSL_SESSION_get0_peer_rpk - raw public key (RFC7250) support

SYNOPSIS


 #include <openssl/ssl.h>

 int SSL_add_expected_rpk(SSL *s, EVP_PKEY *rpk);
 int SSL_get_negotiated_client_cert_type(const SSL *s);
 int SSL_get_negotiated_server_cert_type(const SSL *s);
 EVP_PKEY *SSL_get0_peer_rpk(const SSL *s);
 EVP_PKEY *SSL_SESSION_get0_peer_rpk(const SSL_SESSION *ss);

DESCRIPTION


SSL_add_expected_rpk() adds a DANE TLSA record matching public key rpk to SSL s's DANE validation policy.

SSL_get_negotiated_client_cert_type() returns the connection's negotiated client certificate type.

SSL_get_negotiated_server_cert_type() returns the connection's negotiated server certificate type.

SSL_get0_peer_rpk() returns the peer's raw public key from SSL s.

SSL_SESSION_get0_peer_rpk() returns the peer's raw public key from SSL_SESSION ss.

NOTES


Raw public keys are used in place of certificates when the option is negotiated. SSL_add_expected_rpk() may be called multiple times to configure multiple trusted keys, this makes it possible to allow for key rotation, where a peer might be expected to offer an "old" or "new" key and the endpoint must be able to accept either one.

When raw public keys are used, the certificate verify callback is called, and may be used to inspect the public key via X509_STORE_CTX_get0_rpk(3). Raw public keys have no subject, issuer, validity dates nor digital signature to verify. They can, however, be matched verbatim or by their digest value, this is done by specifying one or more TLSA records, see SSL_CTX_dane_enable(3).

The raw public key is typically taken from the certificate assigned to the connection (e.g. via SSL_use_certificate(3)), but if a certificate is not configured, then the public key will be extracted from the assigned private key.

The SSL_add_expected_rpk() function is a wrapper around SSL_dane_tlsa_add(3). When DANE is enabled via SSL_dane_enable(3), the configured TLSA records will be used to validate the peer's public key or certificate. If DANE is not enabled, then no validation will occur.

RETURN VALUES


SSL_add_expected_rpk() returns 1 on success and 0 on failure.

SSL_get0_peer_rpk() and SSL_SESSION_get0_peer_rpk() return the peer's raw public key as an EVP_PKEY or NULL when the raw public key is not available.

SSL_get_negotiated_client_cert_type() and SSL_get_negotiated_server_cert_type() return one of the following values:

TLSEXT_cert_type_x509
TLSEXT_cert_type_rpk

SEE ALSO


SSL_CTX_dane_enable(3), SSL_CTX_set_options(3), SSL_dane_enable(3), SSL_get_verify_result(3), SSL_set_verify(3), SSL_use_certificate(3), X509_STORE_CTX_get0_rpk(3)

HISTORY


These functions were added in OpenSSL 3.2.


Copyright 2023 The OpenSSL Project Authors. All Rights Reserved.


OpenSSL Logo

Topics: