Asterisk: Compile SRTP Module without recompiling Asterisk

I recently installed Asterisk 1.8.3 (the Asterisk team now provides pre-built Debian packages at
Unfortunately, that package came without the res_srtp SRTP module. (UPDATE: Starting in 1.8.4, it does come with it.) Because I didn’t feel like re-compiling the entire package, I just took the corresponding version of res_srtp.c from the SVN, added the following lines to the beginning of it:

#ifndef AST_MODULE
#define AST_MODULE "res_srtp"

and compiled and installed it using

gcc -shared res_srtp.c -o -lsrtp
sudo cp /usr/lib/asterisk/modules/

You’ll need to have libsrtp0-dev and asterisk-dev installed, otherwise the compile will fail.
Then, you can do sudo asterisk -r and load the module using module load res_srtp (or just restart Asterisk).

I’m still working on getting SRTP working flawlessly both incoming and outgoing and with stuff like transfers. Asterisk Secure Calling Specifics are a good starting point, but I’m also planning to write another post about this in the near future.

6 thoughts on “Asterisk: Compile SRTP Module without recompiling Asterisk

  1. Stephane B.

    It seems they did it again with version for ubuntu/debian.

    I had to redo your trick

    (This time res_srtp.c is in the code, but is not compiled or included in packages from digium… WTF ?)

  2. Michael Kuron Post author still contains it, seems like this is a regression bug. You should file this as a bug against “AsteriskNOW and Packages” at Bugs ANOW-137 and ASTERISK-18738 look like they’re related, but I have not been able to identify the specific change. The Squeeze package is still at and contains res_srtp, but the Lucid package is already at the version you mentioned.

  3. Stewart

    You don’t need to edit res_srtp.c, just add -DAST_MODULE=\”res_srtp\”. Also, for 64bit OSes, you might also need -fPIC.

  4. Erwen

    I followed your instructions with source and it gave me the following error:

    etang@optware:~/slug/optware/ddwrt/builds/asterisk18/res$ gcc -shared res_srtp19.1.c -o -lsrtp -DAST_MODULE=\”res_srtp\”
    res_srtp19.1.c:90:2: error: unknown field ‘replace’ specified in initializer
    res_srtp19.1.c:90:2: warning: initialization from incompatible pointer type [enabled by default]
    res_srtp19.1.c:90:2: warning: (near initialization for ‘srtp_res.destroy’) [enabled by default]

    It looks like they added an additional function in revision 356604.

    Any idea how to get around this error? BTW, I’m cross compiling for mipsel.

  5. Andrew

    Thanks for this worked beautifully I have a 64bit OS so needed -fPIC at the end
    then went to asterisk and did module load as instructed.
    worked great thanks!!!

  6. Slauta


    solved the problem so installed all that is possible in “libgmime” and

    gcc-shared res / res_http_post.c-o res / `pkg-config – cflags – libs gmime-2.6`

Leave a Reply

Your email address will not be published. Required fields are marked *