[asterisk-commits] file: trunk r413160 - in /trunk: ./ res/res_pjsip/config_transport.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu May 1 07:31:25 CDT 2014


Author: file
Date: Thu May  1 07:31:20 2014
New Revision: 413160

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=413160
Log:
res_pjsip: Add the ability to configure ciphers based on name.

Previously this code would only accept the OpenSSL identifier instead
of the documented name.

ASTERISK-23498 #close
ASTERISK-23498 #comment Reported by: Anthony Messina

Review: https://reviewboard.asterisk.org/r/3491/
........

Merged revisions 413159 from http://svn.asterisk.org/svn/asterisk/branches/12

Modified:
    trunk/   (props changed)
    trunk/res/res_pjsip/config_transport.c

Propchange: trunk/
------------------------------------------------------------------------------
Binary property 'branch-12-merged' - no diff available.

Modified: trunk/res/res_pjsip/config_transport.c
URL: http://svnview.digium.com/svn/asterisk/trunk/res/res_pjsip/config_transport.c?view=diff&rev=413160&r1=413159&r2=413160
==============================================================================
--- trunk/res/res_pjsip/config_transport.c (original)
+++ trunk/res/res_pjsip/config_transport.c Thu May  1 07:31:20 2014
@@ -379,6 +379,30 @@
 	return 0;
 }
 
+/*! \brief Helper function which turns a cipher name into an identifier */
+static pj_ssl_cipher cipher_name_to_id(const char *name)
+{
+	pj_ssl_cipher ciphers[100], id = 0;
+	unsigned int cipher_num = PJ_ARRAY_SIZE(ciphers);
+	int pos;
+
+	if (pj_ssl_cipher_get_availables(ciphers, &cipher_num)) {
+		return 0;
+	}
+
+	for (pos = 0; pos < cipher_num; ++pos) {
+		if (!pj_ssl_cipher_name(ciphers[pos]) ||
+			strcmp(pj_ssl_cipher_name(ciphers[pos]), name)) {
+			continue;
+		}
+
+		id = ciphers[pos];
+		break;
+	}
+
+	return id;
+}
+
 /*! \brief Custom handler for TLS cipher setting */
 static int transport_tls_cipher_handler(const struct aco_option *opt, struct ast_variable *var, void *obj)
 {
@@ -389,12 +413,16 @@
 		return -1;
 	}
 
-	/* TODO: Check this over/tweak - it's taken from pjsua for now */
-	if (!strnicmp(var->value, "0x", 2)) {
-		pj_str_t cipher_st = pj_str((char*)var->value + 2);
-		cipher = pj_strtoul2(&cipher_st, NULL, 16);
-	} else {
-		cipher = atoi(var->value);
+	cipher = cipher_name_to_id(var->value);
+
+	if (!cipher) {
+		/* TODO: Check this over/tweak - it's taken from pjsua for now */
+		if (!strnicmp(var->value, "0x", 2)) {
+			pj_str_t cipher_st = pj_str((char*)var->value + 2);
+			cipher = pj_strtoul2(&cipher_st, NULL, 16);
+		} else {
+			cipher = atoi(var->value);
+		}
 	}
 
 	if (pj_ssl_cipher_is_supported(cipher)) {




More information about the asterisk-commits mailing list