SSL_GET0_PEER_RPK(3SSL)

✨ SSL_GET0_PEER_RPK ✨

okay bestie, welcome to the 3SSL corner of the OpenSSL man pages πŸ’… this one is all about raw public key (RFC7250) support and honestly? it's giving very "no certificate, just vibes." let's get into it πŸ¦‹


🌸 NAME 🌸

SSL_add_expected_rpk</p>, SSL_get_negotiated_client_cert_type</p>, SSL_get_negotiated_server_cert_type</p>, SSL_get0_peer_rpk</p>, SSL_SESSION_get0_peer_rpk</p> β€” that's the whole raw public key (RFC7250) glow-up, bestie πŸ”‘


πŸŽ€ SYNOPSIS πŸŽ€

like, here's how you actually call them:

#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 πŸ’–

so here's the tea, function by function β˜•

  • SSL_add_expected_rpk() β€” adds a DANE TLSA record matching the public key rpk to the DANE validation policy of SSL s. iconic behaviour fr.
  • SSL_get_negotiated_client_cert_type() β€” returns the connection's negotiated client certificate type. like, what did y'all agree on πŸ‘€
  • SSL_get_negotiated_server_cert_type() β€” returns the connection's negotiated server certificate type. same energy, other side of the handshake ✨
  • SSL_get0_peer_rpk() β€” returns the peer's raw public key from SSL s. that's your bestie's key, right there 🫢
  • SSL_SESSION_get0_peer_rpk() β€” returns the peer's raw public key from SSL_SESSION ss. same key, but pulled off the session this time, lowkey handy πŸ’œ

πŸ‘‘ NOTES πŸ‘‘

okay this part actually matters so pay attention bestie 🧚

Raw public keys get used in place of certificates when the option is negotiated. no cert, no problem, we're just raw-dogging the key (metaphorically, I promise πŸ™ˆ).

SSL_add_expected_rpk() can be called multiple times to configure multiple trusted keys. the way that enables key rotation?? obsessed. it means a peer might be expected to offer an "old" or "new" key, and the endpoint has to be able to accept either one. flexibility, periodt πŸ’…

When raw public keys are used, the certificate verify callback is called, and you can use it to inspect the public key via X509_STORE_CTX_get0_rpk(3). but heads up β€” raw public keys have no subject, no issuer, no validity dates, and no digital signature to verify. none. zero. nada. πŸ’€ instead, they can be matched verbatim or by their digest value, which 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 (like, e.g. via SSL_use_certificate(3)), but if a certificate isn't configured, then the public key gets extracted from the assigned private key instead. main character fallback energy ✨

And <hotpink>quietly important</hotpink>: SSL_add_expected_rpk() 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. like, none at all. so, y'know. enable DANE bestie 😭


🌈 RETURN VALUES 🌈

  • SSL_add_expected_rpk() β€” returns 1 on success and 0 on failure. slay or flop, no in between πŸ’…
  • 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. NULL is the "sorry babe, nothing here" answer πŸ™ˆ
  • SSL_get_negotiated_client_cert_type() and SSL_get_negotiated_server_cert_type() β€” return one of these two values:
TLSEXT_cert_type_x509
TLSEXT_cert_type_rpk

that's the entire menu, no secret third option πŸ’–


πŸ¦‹ SEE ALSO πŸ¦‹

go read these next, they're all connected, iykyk:


⭐ HISTORY ⭐

these functions were added in OpenSSL 3.2. so they're, like, new-new. relatively speaking. glow-up era πŸŽ€


Copyright 2023 The OpenSSL Project Authors. All Rights Reserved.


and that's the whole page, bestie β€” you ate that βœ¨πŸ’…

signing off from the OpenSSL 4.0.3 era, dated 2026-09-29 β€” this was SSL_GET0_PEER_RPK(3SSL), and yes you're absolutely welcome 🫢🌸

πŸ“¦ where this page comes from