Changeset 5957


Ignore:
Timestamp:
Mar 25, 2019 1:33:12 AM (5 years ago)
Author:
ming
Message:

Fixed #2185: Darwin (Mac OS & iOS) native SSL backend

Location:
pjproject/trunk
Files:
3 added
4 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/aconfigure

    r5924 r5957  
    15431543  --with-ipp-arch=ARCH    Specify the Intel IPP ARCH suffix, e.g. "64" or 
    15441544                          "em64t. Default is blank for IA32" 
    1545   --with-ssl=DIR          Specify alternate SSL library prefix. This option 
     1545  --with-ssl=SSL_BACKEND/DIR 
     1546                          Specify alternate SSL library prefix or SSL 
     1547                          native-backend. You can specify "darwin" as the 
     1548                          native iOS/MacOS backend using Security framework, 
     1549                          or you can specify an alternate SSL library prefix 
     1550                          directory. If a directory is specified, this option 
    15461551                          will try to find OpenSSL first, then if not found, 
    15471552                          GnuTLS. To skip OpenSSL finding, use --with-gnutls 
     
    79527957else 
    79537958 
    7954                 if test "x$with_ssl" != "xno" -a "x$with_ssl" != "x"; then 
     7959                if test "x$with_ssl" = "xdarwin"; then 
     7960                    SAVED_LIBS="$LIBS" 
     7961                    LIBS="-framework Security" 
     7962                    cat confdefs.h - <<_ACEOF >conftest.$ac_ext 
     7963/* end confdefs.h.  */ 
     7964 
     7965int 
     7966main () 
     7967{ 
     7968 
     7969  ; 
     7970  return 0; 
     7971} 
     7972_ACEOF 
     7973if ac_fn_c_try_link "$LINENO"; then : 
     7974  ac_ssl_backend=darwin 
     7975fi 
     7976rm -f core conftest.err conftest.$ac_objext \ 
     7977    conftest$ac_exeext conftest.$ac_ext 
     7978                    LIBS="$SAVED_LIBS" 
     7979                    if test "x$ac_ssl_backend" = "xdarwin"; then 
     7980                        $as_echo "#define PJ_HAS_SSL_SOCK 1" >>confdefs.h 
     7981 
     7982                        $as_echo "#define PJ_SSL_SOCK_IMP PJ_SSL_SOCK_IMP_DARWIN" >>confdefs.h 
     7983 
     7984                        LIBS="$LIBS -framework Security" 
     7985                        ac_ssl_backend="darwin" 
     7986                        { $as_echo "$as_me:${as_lineno-$LINENO}: result: Checking if Security framework for Darwin SSL is available... yes" >&5 
     7987$as_echo "Checking if Security framework for Darwin SSL is available... yes" >&6; } 
     7988                    else 
     7989                        { $as_echo "$as_me:${as_lineno-$LINENO}: result: Checking if Security framework for Darwin SSL is available... no" >&5 
     7990$as_echo "Checking if Security framework for Darwin SSL is available... no" >&6; } 
     7991                    fi 
     7992                fi 
     7993 
     7994                if test "x$ac_ssl_backend" = "x" -a "x$with_ssl" != "xno" -a "x$with_ssl" != "x"; then 
    79557995                    CFLAGS="$CFLAGS -I$with_ssl/include" 
    79567996                    CPPFLAGS="$CPPFLAGS -I$with_ssl/include" 
     
    79608000                fi 
    79618001 
    7962                 if test "x$with_gnutls" = "xno"; then 
     8002                if test "x$ac_ssl_backend" = "x" -a "x$with_gnutls" = "xno"; then 
    79638003 
    79648004                    { $as_echo "$as_me:${as_lineno-$LINENO}: result: checking for OpenSSL installations.." >&5 
  • pjproject/trunk/aconfigure.ac

    r5924 r5957  
    15421542dnl # SSL alt prefix 
    15431543AC_ARG_WITH(ssl, 
    1544     AS_HELP_STRING([--with-ssl=DIR], 
    1545                    [Specify alternate SSL library prefix. This option will try 
    1546                     to find OpenSSL first, then if not found, GnuTLS. To skip 
    1547                     OpenSSL finding, use --with-gnutls option instead.]), 
     1544    AS_HELP_STRING([--with-ssl=SSL_BACKEND/DIR], 
     1545                   [Specify alternate SSL library prefix or SSL native-backend. 
     1546                    You can specify "darwin" as the native iOS/MacOS backend 
     1547                    using Security framework, or you can specify an alternate 
     1548                    SSL library prefix directory. If a directory 
     1549                    is specified, this option will try to find OpenSSL first, 
     1550                    then if not found, GnuTLS. To skip OpenSSL finding, use 
     1551                    --with-gnutls option instead.]), 
    15481552    [], 
    15491553    [with_ssl=no] 
     
    15781582              ], 
    15791583              [ 
    1580                 if test "x$with_ssl" != "xno" -a "x$with_ssl" != "x"; then 
     1584                if test "x$with_ssl" = "xdarwin"; then 
     1585                    SAVED_LIBS="$LIBS" 
     1586                    LIBS="-framework Security" 
     1587                    AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [])], 
     1588                                   [ac_ssl_backend=darwin],) 
     1589                    LIBS="$SAVED_LIBS" 
     1590                    if test "x$ac_ssl_backend" = "xdarwin"; then 
     1591                        AC_DEFINE(PJ_HAS_SSL_SOCK, 1) 
     1592                        AC_DEFINE(PJ_SSL_SOCK_IMP, PJ_SSL_SOCK_IMP_DARWIN) 
     1593                        LIBS="$LIBS -framework Security" 
     1594                        ac_ssl_backend="darwin" 
     1595                        AC_MSG_RESULT([Checking if Security framework for Darwin SSL is available... yes]) 
     1596                    else 
     1597                        AC_MSG_RESULT([Checking if Security framework for Darwin SSL is available... no]) 
     1598                    fi 
     1599                fi 
     1600                 
     1601                if test "x$ac_ssl_backend" = "x" -a "x$with_ssl" != "xno" -a "x$with_ssl" != "x"; then 
    15811602                    CFLAGS="$CFLAGS -I$with_ssl/include" 
    15821603                    CPPFLAGS="$CPPFLAGS -I$with_ssl/include" 
     
    15851606                fi 
    15861607 
    1587                 if test "x$with_gnutls" = "xno"; then 
     1608                if test "x$ac_ssl_backend" = "x" -a "x$with_gnutls" = "xno"; then 
    15881609 
    15891610                    AC_MSG_RESULT([checking for OpenSSL installations..]) 
  • pjproject/trunk/pjlib/build/Makefile

    r5761 r5957  
    3737        rbtree.o sock_common.o sock_qos_common.o \ 
    3838        ssl_sock_common.o ssl_sock_ossl.o ssl_sock_gtls.o ssl_sock_dump.o \ 
    39         string.o timer.o types.o 
     39        ssl_sock_darwin.o string.o timer.o types.o 
    4040export PJLIB_CFLAGS += $(_CFLAGS) 
    4141export PJLIB_CXXFLAGS += $(_CXXFLAGS) 
  • pjproject/trunk/pjlib/src/pjlib-test/ssl_sock.c

    r5950 r5957  
    2323 
    2424#define CERT_DIR                    "../build/" 
    25 #define CERT_CA_FILE                CERT_DIR "cacert.pem" 
     25#if (PJ_SSL_SOCK_IMP == PJ_SSL_SOCK_IMP_DARWIN) 
     26/* If we use Darwin SSL, use the cert in DER format. */ 
     27#   define CERT_CA_FILE             CERT_DIR "cacert.der" 
     28#else 
     29#   define CERT_CA_FILE             CERT_DIR "cacert.pem" 
     30#endif 
    2631#define CERT_FILE                   CERT_DIR "cacert.pem" 
    2732#define CERT_PRIVKEY_FILE           CERT_DIR "privkey.pem" 
     
    888893        pj_str_t privkey_pass = pj_str(CERT_PRIVKEY_PASS); 
    889894 
     895#if (PJ_SSL_SOCK_IMP == PJ_SSL_SOCK_IMP_DARWIN) 
     896        PJ_LOG(3, ("", "Darwin SSL requires the private key to be " 
     897                       "inside the Keychain. So double click on " 
     898                       "the file pjlib/build/privkey.p12 to " 
     899                       "place it in the Keychain. " 
     900                       "The password is \"pjsip\".")); 
     901#endif 
     902 
    890903#if (defined(TEST_LOAD_FROM_FILES) && TEST_LOAD_FROM_FILES==1) 
    891904        status = pj_ssl_cert_load_from_files(pool, &ca_file, &cert_file,  
Note: See TracChangeset for help on using the changeset viewer.