SSL_GET0_PEER_RPK(3ossl)

πŸ“¦
version 15.1 Β· 2 versions
, in freebsd 15.1

πŸ’… SSL_GET0_PEER_RPK(3ossl) πŸ’…

Okay bestie, so this is the SSL_GET0_PEER_RPK(3ossl) page from the OpenSSL fam β€” it's the whole ✨raw public key✨ situation, aka RFC7250 support. Buckle up, it's actually so good.


🌸 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 β€” literally all the raw public key (RFC7250) support you could ever need. No cap. πŸ”‘


✨ 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 πŸ¦‹

Okay so here's the rundown, one function at a time:

  • SSL_add_expected_rpk() β€” adds a DANE TLSA record that matches the public key rpk to SSL s's DANE validation policy. It's giving "I expect to see this key, bestie." πŸŽ€
  • SSL_get_negotiated_client_cert_type() β€” returns the connection's negotiated client certificate type. Slay. πŸ’…
  • SSL_get_negotiated_server_cert_type() β€” returns the connection's negotiated server certificate type. Also slay. ✨
  • SSL_get0_peer_rpk() β€” returns the peer's raw public key from SSL s. Iconic.
  • SSL_SESSION_get0_peer_rpk() β€” returns the peer's raw public key from SSL_SESSION ss. Same energy, different object. 🫢

🧚 NOTES 🧚

So, when do raw public keys even happen? They're used in place of certificates when the option is negotiated. That's the whole vibe check. πŸ’«

SSL_add_expected_rpk() can be called multiple times to configure multiple trusted keys β€” which is honestly so smart, because it makes key rotation possible. Picture this: a peer might show up offering an "old" key or a "new" key, and your endpoint has to be able to accept either one. Main character flexibility. πŸ‘‘

When raw public keys are used, the certificate verify callback gets called, and you can use it to inspect the public key via X509_STORE_CTX_get0_rpk(3). Heads up though β€” raw public keys have no subject, no issuer, no validity dates, and no digital signature to verify. They're kinda bare-bones like that. πŸ™ˆ But they can be matched verbatim, or by their digest value, and that's done by specifying one or more TLSA records β€” see SSL_CTX_dane_enable(3).

Where does the raw public key actually come from? Typically it's taken from the certificate assigned to the connection (e.g. via SSL_use_certificate(3)). But β€” plot twist β€” if a certificate isn't configured, then the public key will be extracted from the assigned private key. πŸ“

And now, the lore on SSL_add_expected_rpk(): it's a wrapper around SSL_dane_tlsa_add(3). When DANE is enabled via SSL_dane_enable(3), the configured TLSA records get used to validate the peer's public key or certificate. If DANE is not enabled, then no validation will occur. ⚠️ Not me warning you β€” that's literally in the docs, bestie. Be careful.


πŸ’€ RETURN VALUES πŸ’€

  • SSL_add_expected_rpk() β€” returns 1 on success and 0 on failure. Classic. 🀷
  • 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 these two values, periodt:
TLSEXT_cert_type_x509
TLSEXT_cert_type_rpk

🌈 SEE ALSO 🌈

Go read these next, iykyk β€” they're the whole friend group:


⭐ HISTORY ⭐

These functions were added in OpenSSL 3.2. So if you're on something older… bestie. Upgrade. πŸ”₯


Copyright 2023 The OpenSSL Project Authors. All Rights Reserved.


Okay that's the whole page, you ate that πŸ’– go forth and validate those raw public keys, you absolute queen πŸ‘‘

Sign-off time, bestie: this gorgeous little page is from the OpenSSL 3.5.6 release, dated 2026-04-07 πŸ’œ Catch you in the next man page! πŸ¦‹βœ¨

πŸ“¦ where this page comes from