SSL_GET0_PEER_RPK(3ossl)
π 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 toSSLs'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 fromSSLs. Iconic.SSL_SESSION_get0_peer_rpk()β returns the peer's raw public key fromSSL_SESSIONss. 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()β returns1on success and0on failure. Classic. π€·SSL_get0_peer_rpk()andSSL_SESSION_get0_peer_rpk()β return the peer's raw public key as anEVP_PKEY, orNULLwhen the raw public key is not available. πSSL_get_negotiated_client_cert_type()andSSL_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:
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. So if you're on something olderβ¦ bestie. Upgrade. π₯
π COPYRIGHT π
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
- freebsd 15.1: base 15.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms