Index: /pjproject/trunk/aconfigure
===================================================================
--- /pjproject/trunk/aconfigure	(revision 5482)
+++ /pjproject/trunk/aconfigure	(revision 5483)
@@ -642,7 +642,11 @@
 ac_no_opencore_amrwb
 ac_no_opencore_amrnb
+ec_curve_present
+set_curve_present
 libcrypto_present
 libssl_present
 openssl_h_present
+ac_ssl_has_sigalg
+ac_ssl_has_ec
 ac_ssl_has_aes_gcm
 ac_no_ssl
@@ -5415,4 +5419,5 @@
 
 
+
 ac_fn_c_check_func "$LINENO" "localtime_r" "ac_cv_func_localtime_r"
 if test "x$ac_cv_func_localtime_r" = xyes; then :
@@ -5420,4 +5425,5 @@
 
 fi
+
 
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: Setting PJ_OS_NAME to $target" >&5
@@ -7784,4 +7790,8 @@
 ac_ssl_has_aes_gcm=0
 
+ac_ssl_has_ec=0
+
+ac_ssl_has_sigalg=0
+
 # Check whether --enable-ssl was given.
 if test "${enable_ssl+set}" = set; then :
@@ -7945,4 +7955,118 @@
 $as_echo "OpenSSL AES GCM support not found, SRTP will only support AES CM cryptos" >&6; }
 			fi
+
+			# Check if OpenSSL supports setting curve algorithm
+			# and has elliptic curve
+
+			{ $as_echo "$as_me:${as_lineno-$LINENO}: checking OpenSSL setting curve functions" >&5
+$as_echo_n "checking OpenSSL setting curve functions... " >&6; }
+			set_curve_present=0
+
+			ec_curve_present=0
+
+			cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <openssl/ssl.h>
+
+int
+main ()
+{
+ SSL_set1_curves(NULL, NULL, 0);
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+   set_curve_present=1
+		  		   { $as_echo "$as_me:${as_lineno-$LINENO}: result: ok" >&5
+$as_echo "ok" >&6; }
+
+else
+
+		  		   { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+
+			{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for EC_curve_nid2nist in -lssl" >&5
+$as_echo_n "checking for EC_curve_nid2nist in -lssl... " >&6; }
+if ${ac_cv_lib_ssl_EC_curve_nid2nist+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-lssl  $LIBS"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char EC_curve_nid2nist ();
+int
+main ()
+{
+return EC_curve_nid2nist ();
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+  ac_cv_lib_ssl_EC_curve_nid2nist=yes
+else
+  ac_cv_lib_ssl_EC_curve_nid2nist=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_ssl_EC_curve_nid2nist" >&5
+$as_echo "$ac_cv_lib_ssl_EC_curve_nid2nist" >&6; }
+if test "x$ac_cv_lib_ssl_EC_curve_nid2nist" = xyes; then :
+  ec_curve_present=1
+fi
+
+			if test "x$set_curve_present" = "x1" -a "x$ec_curve_present" = "x1"; then
+				ac_ssl_has_ec=1
+				{ $as_echo "$as_me:${as_lineno-$LINENO}: result: OpenSSL has elliptic curve support" >&5
+$as_echo "OpenSSL has elliptic curve support" >&6; }
+			else
+				{ $as_echo "$as_me:${as_lineno-$LINENO}: result: OpenSSL elliptic curve algorithm unsupported" >&5
+$as_echo "OpenSSL elliptic curve algorithm unsupported" >&6; }
+			fi
+
+			{ $as_echo "$as_me:${as_lineno-$LINENO}: checking OpenSSL setting sigalg" >&5
+$as_echo_n "checking OpenSSL setting sigalg... " >&6; }
+			cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <openssl/ssl.h>
+
+int
+main ()
+{
+SSL_set1_sigalgs_list(NULL, NULL);
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+   ac_ssl_has_sigalg=1
+		  		   { $as_echo "$as_me:${as_lineno-$LINENO}: result: ok" >&5
+$as_echo "ok" >&6; }
+
+else
+
+		  		   { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
 
 			# PJSIP_HAS_TLS_TRANSPORT setting follows PJ_HAS_SSL_SOCK
Index: /pjproject/trunk/aconfigure.ac
===================================================================
--- /pjproject/trunk/aconfigure.ac	(revision 5482)
+++ /pjproject/trunk/aconfigure.ac	(revision 5483)
@@ -1534,4 +1534,6 @@
 AC_SUBST(ac_no_ssl)
 AC_SUBST(ac_ssl_has_aes_gcm,0)
+AC_SUBST(ac_ssl_has_ec,0)
+AC_SUBST(ac_ssl_has_sigalg,0)
 AC_ARG_ENABLE(ssl,
 	      AS_HELP_STRING([--disable-ssl],
@@ -1568,4 +1570,41 @@
 				AC_MSG_RESULT([OpenSSL AES GCM support not found, SRTP will only support AES CM cryptos])
 			fi
+
+			# Check if OpenSSL supports setting curve algorithm
+			# and has elliptic curve
+			
+			AC_MSG_CHECKING([OpenSSL setting curve functions])
+			AC_SUBST(set_curve_present,0)
+			AC_SUBST(ec_curve_present,0)
+			AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <openssl/ssl.h>
+					          ]],
+					          [ SSL_set1_curves(NULL, NULL, 0);]
+					         )],
+		  		 [ set_curve_present=1
+		  		   AC_MSG_RESULT(ok)
+		  		  ],
+		  		 [
+		  		   AC_MSG_RESULT(no)
+		  		 ])
+
+			AC_CHECK_LIB(ssl,EC_curve_nid2nist,[ec_curve_present=1])
+			if test "x$set_curve_present" = "x1" -a "x$ec_curve_present" = "x1"; then
+				[ac_ssl_has_ec=1]
+				AC_MSG_RESULT([OpenSSL has elliptic curve support])
+			else
+				AC_MSG_RESULT([OpenSSL elliptic curve algorithm unsupported])
+			fi
+
+			AC_MSG_CHECKING([OpenSSL setting sigalg])
+			AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <openssl/ssl.h>
+					          ]],
+					          [SSL_set1_sigalgs_list(NULL, NULL);]
+					         )],
+		  		 [ ac_ssl_has_sigalg=1
+		  		   AC_MSG_RESULT(ok)
+		  		  ],
+		  		 [
+		  		   AC_MSG_RESULT(no)
+		  		 ])
 
 			# PJSIP_HAS_TLS_TRANSPORT setting follows PJ_HAS_SSL_SOCK
Index: /pjproject/trunk/pjlib/build/os-auto.mak.in
===================================================================
--- /pjproject/trunk/pjlib/build/os-auto.mak.in	(revision 5482)
+++ /pjproject/trunk/pjlib/build/os-auto.mak.in	(revision 5483)
@@ -34,3 +34,9 @@
 export TARGETS_EXE  =   $(TEST_EXE)
 
+ifeq (@ac_ssl_has_ec@,1)
+export PJLIB_CFLAGS += -DPJ_SSL_SOCK_OSSL_HAS_EC=1
+endif
 
+ifeq (@ac_ssl_has_sigalg@,1)
+export PJLIB_CFLAGS += -DPJ_SSL_SOCK_OSSL_HAS_SIGALG=1
+endif
Index: /pjproject/trunk/pjlib/src/pj/ssl_sock_ossl.c
===================================================================
--- /pjproject/trunk/pjlib/src/pj/ssl_sock_ossl.c	(revision 5482)
+++ /pjproject/trunk/pjlib/src/pj/ssl_sock_ossl.c	(revision 5483)
@@ -53,5 +53,5 @@
 #include <openssl/engine.h>
 
-#if !defined(OPENSSL_NO_EC)
+#if defined(PJ_SSL_SOCK_OSSL_HAS_EC) && PJ_SSL_SOCK_OSSL_HAS_EC==1
    extern int tls1_ec_nid2curve_id(int nid);
    extern int tls1_ec_curve_id2nid(int curve_id);
@@ -386,5 +386,5 @@
 	ssl->session = SSL_SESSION_new();
 
-#if !defined(OPENSSL_NO_EC)
+#if defined(PJ_SSL_SOCK_OSSL_HAS_EC) && PJ_SSL_SOCK_OSSL_HAS_EC==1
 	openssl_curves_num = SSL_get_shared_curve(ssl,-1);
 	if (openssl_curves_num > PJ_ARRAY_SIZE(openssl_curves))
@@ -1000,5 +1000,5 @@
 static pj_status_t set_curves_list(pj_ssl_sock_t *ssock)
 {
-#if !defined(OPENSSL_NO_EC)
+#if defined(PJ_SSL_SOCK_OSSL_HAS_EC) && PJ_SSL_SOCK_OSSL_HAS_EC==1
     int ret;
     int curves[PJ_SSL_SOCK_MAX_CURVES];
@@ -1023,13 +1023,12 @@
 	    return GET_SSL_STATUS(ssock);
     }
+#endif
 
     return PJ_SUCCESS;
-#else
-    return PJ_ENOTSUP;
-#endif
 }
 
 static pj_status_t set_sigalgs(pj_ssl_sock_t *ssock)
 {
+#if defined(PJ_SSL_SOCK_OSSL_HAS_SIGALG) && PJ_SSL_SOCK_OSSL_HAS_SIGALG==1
     int ret;
 
@@ -1046,4 +1045,5 @@
 	    return GET_SSL_STATUS(ssock);
     }
+#endif
 
     return PJ_SUCCESS;
@@ -2394,5 +2394,5 @@
 
     for (i = 0; i < *curve_num; ++i)
-    curves[i] = openssl_curves[i].id;
+	curves[i] = openssl_curves[i].id;
 
     return PJ_SUCCESS;
