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


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@413160 65c4cc65-6c06-0410-ace0-fbb531ad65f3
changes/97/197/1
Joshua Colp 12 years ago
parent 20750e261b
commit 45a7132480

@ -379,6 +379,30 @@ static int tls_method_to_str(const void *obj, const intptr_t *args, char **buf)
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,6 +413,9 @@ static int transport_tls_cipher_handler(const struct aco_option *opt, struct ast
return -1;
}
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);
@ -396,6 +423,7 @@ static int transport_tls_cipher_handler(const struct aco_option *opt, struct ast
} else {
cipher = atoi(var->value);
}
}
if (pj_ssl_cipher_is_supported(cipher)) {
transport->ciphers[transport->tls.ciphers_num++] = cipher;

Loading…
Cancel
Save