SSL_CTX_SET_TLSEXT_USE_SRTP(3ossl)
π SSL_CTX_set_tlsext_use_srtp β the OpenSSL 3ossl glow-up
okay bestie, sit down, because today we're talking about SSL_CTX_set_tlsext_use_srtp, SSL_set_tlsext_use_srtp, SSL_get_srtp_profiles and SSL_get_selected_srtp_profile β the four little functions that let you configure and query SRTP support in OpenSSL. this is from the 3ossl manual, and it's giving "niche but iconic" energy fr fr π
β¨ NAME β¨
SSL_CTX_set_tlsext_use_srtp, SSL_set_tlsext_use_srtp, SSL_get_srtp_profiles, SSL_get_selected_srtp_profile β configure and query SRTP support π
πΈ SYNOPSIS πΈ
#include <openssl/srtp.h>
int SSL_CTX_set_tlsext_use_srtp(SSL_CTX *ctx, const char *profiles);
int SSL_set_tlsext_use_srtp(SSL *ssl, const char *profiles);
STACK_OF(SRTP_PROTECTION_PROFILE) *SSL_get_srtp_profiles(SSL *ssl);
SRTP_PROTECTION_PROFILE *SSL_get_selected_srtp_profile(SSL *s);
literally just four signatures, no drama π
π¦ DESCRIPTION π¦
so. SRTP is the Secure Real-Time Transport Protocol, and OpenSSL implements support for the "use_srtp" DTLS extension defined in RFC5764. what does that give you? a whole mechanism for establishing SRTP keying material, algorithms and parameters using DTLS π«Ά and this capability may be used as part of an implementation that conforms to RFC5763.
β οΈ but bestie, read this part twice: OpenSSL does not implement SRTP itself or RFC5763. also, OpenSSL does not support the use of SRTP Master Key Identifiers (MKIs). and this extension is only supported in DTLS β any SRTP configuration will be ignored if a TLS connection is attempted π
an OpenSSL client wishing to send the "use_srtp" extension should call SSL_CTX_set_tlsext_use_srtp() to set its use for all SSL objects subsequently created from an SSL_CTX. alternatively a client may call SSL_set_tlsext_use_srtp() to set its use for an individual SSL object π₯
the profiles parameter should point to a NUL-terminated, colon delimited list of SRTP protection profile names.
the currently supported protection profile names are:
SRTP_AES128_CM_SHA1_80β this corresponds toSRTP_AES128_CM_HMAC_SHA1_80defined in RFC5764 πSRTP_AES128_CM_SHA1_32β this corresponds toSRTP_AES128_CM_HMAC_SHA1_32defined in RFC5764 πSRTP_AEAD_AES_128_GCMβ this corresponds to the profile of the same name defined in RFC7714 β¨SRTP_AEAD_AES_256_GCMβ this corresponds to the profile of the same name defined in RFC7714 β¨SRTP_DOUBLE_AEAD_AES_128_GCM_AEAD_AES_128_GCMβ this corresponds to the profile of the same name defined in RFC8723 πSRTP_DOUBLE_AEAD_AES_256_GCM_AEAD_AES_256_GCMβ this corresponds to the profile of the same name defined in RFC8723 πSRTP_ARIA_128_CTR_HMAC_SHA1_80β this corresponds to the profile of the same name defined in RFC8269 π§SRTP_ARIA_128_CTR_HMAC_SHA1_32β this corresponds to the profile of the same name defined in RFC8269 π§SRTP_ARIA_256_CTR_HMAC_SHA1_80β this corresponds to the profile of the same name defined in RFC8269 π§SRTP_ARIA_256_CTR_HMAC_SHA1_32β this corresponds to the profile of the same name defined in RFC8269 π§SRTP_AEAD_ARIA_128_GCMβ this corresponds to the profile of the same name defined in RFC8269 πSRTP_AEAD_ARIA_256_GCMβ this corresponds to the profile of the same name defined in RFC8269 π
π supplying an unrecognised protection profile name will result in an error. no vibes-based guessing allowed.
an OpenSSL server wishing to support the "use_srtp" extension should also call SSL_CTX_set_tlsext_use_srtp() or SSL_set_tlsext_use_srtp() to indicate the protection profiles that it is willing to negotiate π€
the currently configured list of protection profiles β for either a client or a server β can be obtained by calling SSL_get_srtp_profiles(). this returns a stack of SRTP_PROTECTION_PROFILE objects. and listen: the memory pointed to in the return value of this function should not be freed by the caller π (yes, that's you. put the free() down.)
after a handshake has been completed, the negotiated SRTP protection profile (if any) can be obtained (on the client or the server) by calling SSL_get_selected_srtp_profile(). this function will return NULL if no SRTP protection profile was negotiated. the memory returned from this function should not be freed by the caller either, periodt π
if an SRTP protection profile has been successfully negotiated, then the SRTP keying material (on both the client and server) should be obtained via a call to SSL_export_keying_material(3). that call should provide:
- a label value of
"EXTRACTOR-dtls_srtp" - a
NULLcontext value (use_contextis0)
the total length of keying material obtained should be equal to two times the sum of the master key length and the salt length as defined for the protection profile in use. and the order matters, bestie β this gives you:
- the client write master key
- the server write master key
- the client write master salt
- the server write master salt
...in that order π₯π
π one more thing and it's important: these functions cannot be used with QUIC SSL objects.SSL_CTX_set_tlsext_use_srtp()fails if called on a QUIC SSL context.SSL_set_tlsext_use_srtp()fails if called on a QUIC SSL object. no cap.
π RETURN VALUES π
SSL_CTX_set_tlsext_use_srtp()andSSL_set_tlsext_use_srtp()return0on success or1on error. yes, that's inverted from what your brain expects β that's just how it is, don't @ me πSSL_get_srtp_profiles()returns a stack ofSRTP_PROTECTION_PROFILEobjects on success, orNULLon error or if no protection profiles have been configured.SSL_get_selected_srtp_profile()returns a pointer to anSRTP_PROTECTION_PROFILEobject if one has been negotiated, orNULLotherwise.
π SEE ALSO π
π COPYRIGHT π
Copyright 2017-2023 The OpenSSL Project Authors. All Rights Reserved.
Licensed under the Apache License 2.0 (the "License"). You may not use this file except in compliance with the License. You can obtain a copy in the file LICENSE in the source distribution or at <https://www.openssl.org/source/license.html>.
and that's the whole page, bestie π«Ά this was OpenSSL 3.5.6, dated 2026-04-07 β go forth and negotiate those protection profiles responsibly, mwah πβ¨
π¦ 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