[asterisk-dev] [Code Review] Wrap OpenSSL library initialization to make it safe for loaded modules to also use OpenSSL.

Tilghman Lesher reviewboard at asterisk.org
Thu Jan 19 12:47:11 CST 2012


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviewboard.asterisk.org/r/1006/#review5220
-----------------------------------------------------------


This changeset fails to compile on Snow Leopard.  The problem is due to the prototypes not matching:

   [CCi] ssl.i -> ssl.o
ssl.c:159: error: conflicting types for 'SSL_CTX_new'
/usr/include/openssl/ssl.h:1313: error: previous declaration of 'SSL_CTX_new' was here
ssl.c:271: error: conflicting types for 'SSLv23_client_method'
/usr/include/openssl/ssl.h:1484: error: previous declaration of 'SSLv23_client_method' was here
ssl.c:278: error: conflicting types for 'SSLv23_server_method'
/usr/include/openssl/ssl.h:1483: error: previous declaration of 'SSLv23_server_method' was here
ssl.c:285: error: conflicting types for 'SSLv3_client_method'
/usr/include/openssl/ssl.h:1480: error: previous declaration of 'SSLv3_client_method' was here
ssl.c:292: error: conflicting types for 'TLSv1_client_method'
/usr/include/openssl/ssl.h:1488: error: previous declaration of 'TLSv1_client_method' was here
make[2]: *** [ssl.o] Error 1
make[1]: *** [main] Error 2
make: *** [_cleantest_all] Error 2

- Tilghman


On Jan. 18, 2012, 3:03 p.m., Kevin Fleming wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviewboard.asterisk.org/r/1006/
> -----------------------------------------------------------
> 
> (Updated Jan. 18, 2012, 3:03 p.m.)
> 
> 
> Review request for Asterisk Developers.
> 
> 
> Summary
> -------
> 
> During the devcon after AstriCon 2010, we got a report that using PostgreSQL from within Asterisk, when the PostgreSQL connections are configured to use SSL/TLS to connect to the database server, can cause random crashes and other bizarre behavior. The reporter said this was known to be an issue with some other packages as well (notably Kamailio), and had to do with both Asterisk and the PostgreSQL libraries assuming they "owned" the OpenSSL libraries in the process' memory space, and thus calling initialization code twice (or worse).
> 
> This patch addresses this problem by using dynamic linker functionality to *wrap* the real OpenSSL initialization functions (and some other dangerous ones) with versions that don't actually do anything, and then calling the real ones only *one* time during Asterisk startup. To make this work, the SSL functionality that is normally built into the main Asterisk binary now must be built into a dynamic library (libasteriskssl.so), which is installed into the standard dynamic library location on the system (this is *not* an Asterisk loadable module, just a regular dynamic library).
> 
> As part of this patch, the usage of ASTLIBDIR throughout the build system to refer to the directory where Asterisk loadable modules are installed was changed to ASTMODDIR (which matches how it is referred to in the source code and in asterisk.conf), and a new definition of ASTLIBDIR was created to point to the system's dynamic library directory.
> 
> 
> Diffs
> -----
> 
>   /trunk/Makefile.moddir_rules 351448 
>   /trunk/build_tools/make_defaults_h 351448 
>   /trunk/build_tools/mkpkgconfig 351448 
>   /trunk/configure UNKNOWN 
>   /trunk/configure.ac 351448 
>   /trunk/include/asterisk.h 351448 
>   /trunk/include/asterisk/optional_api.h 351448 
>   /trunk/main/Makefile 351448 
>   /trunk/main/ssl.c 351409 
>   /trunk/main/ssl.c 351448 
>   /trunk/makeopts.in 351448 
>   /trunk/Makefile 351448 
> 
> Diff: https://reviewboard.asterisk.org/r/1006/diff
> 
> 
> Testing
> -------
> 
> Compiles and runs on Linux x86-64 with no apparent change in behavior. The Makefile bits to install libasteriskssl.so in the right place will probably have to be checked by Solaris, Darwin and *BSD users to get them right.
> 
> 
> Thanks,
> 
> Kevin
> 
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-dev/attachments/20120119/d135fc5b/attachment.htm>


More information about the asterisk-dev mailing list