sdamm / asio_dtls

A DTLS implementation using the ASIO library
51 stars 11 forks source link

How to add DTLS extensions? #9

Open LubosD opened 4 years ago

LubosD commented 4 years ago

Is there any way to add DTLS extensions? I would need to add "use_srtp" (RFC5764) for WebRTC.

sdamm commented 4 years ago

There is no interface to enable it at the Moment.

But you can use the native handle like this:

#include <openssl/srtp.h>

asio::ssl::dtls::context ctx(asio::ssl::dtls::context::dtls_client);

int res = SSL_CTX_set_tlsext_use_srtp(ctx.native_handle(), "SRTP_AEAD_AES_256_GCM");
if(res != 0)
{
    asio::error_code ec = asio::error_code(
        static_cast<int>(::ERR_get_error()),
        asio::error::get_ssl_category());

    // Handle Error
}

// Create DTLS Socket, ...