SSL_CTX_SET_TLSEXT_USE_SRTP(3SSL)

🌸 SSL_CTX_SET_TLSEXT_USE_SRTP(3SSL) β€” the OpenSSL manual, but make it make sense πŸŽ€

okay bestie, sit down, grab a strawberry drink πŸ“, because 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 β€” aka the ✨ configure and query SRTP support ✨ squad. this is the OpenSSL manual page, so you know it's giving serious business, but I'm gonna walk you through it like we're texting. πŸ’…


πŸ’– 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. that's it, that's the whole job, and they ate. πŸ‘‘


✨ 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);

four functions, two setters, two getters, we love a balanced little ecosystem 🫢


🌈 DESCRIPTION 🌈

so, SRTP = the Secure Real-Time Transport Protocol. πŸ’– OpenSSL implements support for the "use_srtp" DTLS extension defined in RFC5764. what does that do for you? it gives you a whole mechanism for establishing SRTP keying material, algorithms and parameters using DTLS. iconique. ✨

this capability may be used as part of an implementation that conforms to RFC5763. but bestie, listen carefully: OpenSSL does not implement SRTP itself or RFC5763. it's the setup girlie, not the whole party. 😭

also, note that OpenSSL does not support the use of SRTP Master Key Identifiers (MKIs).
and another note: this extension is only supported in DTLS. any SRTP configuration will be ignored if a TLS connection is attempted. not a suggestion, that's just the rules. πŸ’€

An OpenSSL client wishing to send the "use_srtp" extension should call SSL_CTX_set_tlsext_use_srtp() β€” that sets it for all SSL objects subsequently created from an SSL_CTX. or, if you want it just for one individual SSL object, a client may call SSL_set_tlsext_use_srtp() instead. the profiles parameter should point to a NUL-terminated, colon delimited list of SRTP protection profile names. πŸŽ€

🌸 the currently supported protection profile names 🌸

  • SRTP_AES128_CM_SHA1_80 β€” this corresponds to SRTP_AES128_CM_HMAC_SHA1_80 defined in RFC5764.
  • SRTP_AES128_CM_SHA1_32 β€” this corresponds to SRTP_AES128_CM_HMAC_SHA1_32 defined 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. (yes the name is long, she's dramatic, we respect it πŸ’…)
  • 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, she will simply say no.

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() β€” that's how it tells you which protection profiles it's 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.

⚠️ the memory pointed to in the return value of this function should not be freed by the caller. hands off, bestie. πŸ™ˆ

after a handshake has been completed, the negotiated SRTP protection profile (if any β€” no pressure) 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. and again: the memory returned from this function should not be freed by the caller. πŸŽ€

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" and a NULL context value (use_context is 0). 🌟

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. that gives you, in this exact order:

  1. the client write master key
  2. the server write master key
  3. the client write master salt
  4. the server write master salt

order matters, do not shuffle her. πŸ‘‘

πŸ¦‹ QUIC situation πŸ¦‹

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.

periodt. πŸ’…


πŸ’œ RETURN VALUES πŸ’œ

  • SSL_CTX_set_tlsext_use_srtp() and SSL_set_tlsext_use_srtp() return 0 on success or 1 on error. yes, that's the way round it is, don't come for me, I'm just the messenger 😭
  • SSL_get_srtp_profiles() returns a stack of SRTP_PROTECTION_PROFILE objects on success, or NULL on error or if no protection profiles have been configured.
  • SSL_get_selected_srtp_profile() returns a pointer to an SRTP_PROTECTION_PROFILE object if one has been negotiated, or NULL otherwise.

πŸ”₯ SEE ALSO πŸ”₯


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 4.0.3, dated 2026-09-29, from the SSL_CTX_SET_TLSEXT_USE_SRTP(3SSL) manual β€” go forth and negotiate your protection profiles responsibly, ily, mwah πŸ«ΆπŸŽ€πŸ¦‹

πŸ“¦ where this page comes from