mirror of
https://github.com/signalwire/freeswitch.git
synced 2026-11-12 12:37:05 +00:00
Merge remote-tracking branch 'origin/master' into moy/tport-log-fix
This commit is contained in:
commit
461f94870f
1341 files changed
+122466
-28348
No files matched your search
@@ -2142,6 +2142,7 @@ int nta_agent_add_tport(nta_agent_t *self,
|
||||
char const * const * tports = tports_sip;
|
||||
int error;
|
||||
ta_list ta;
|
||||
char *tps[9] = {0};
|
||||
|
||||
if (self == NULL) {
|
||||
su_seterrno(EINVAL);
|
||||
@@ -2187,7 +2188,7 @@ int nta_agent_add_tport(nta_agent_t *self,
|
||||
if (url->url_params) {
|
||||
if (url_param(url->url_params, "transport", tp, sizeof(tp)) > 0) {
|
||||
if (strchr(tp, ',')) {
|
||||
int i; char *t, *tps[9] = {0};
|
||||
int i; char *t;
|
||||
|
||||
/* Split tp into transports */
|
||||
for (i = 0, t = tp; t && i < 8; i++) {
|
||||
|
||||
@@ -270,8 +270,10 @@ void nua_session_usage_remove(nua_handle_t *nh,
|
||||
ss->ss_reporting = 0;
|
||||
}
|
||||
|
||||
if (cr == du->du_cr && cr->cr_orq)
|
||||
if (cr == du->du_cr && cr->cr_orq) {
|
||||
nua_client_request_unref(cr);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (cr->cr_status < 200) {
|
||||
nua_stack_event(nh->nh_nua, nh,
|
||||
|
||||
@@ -1808,8 +1808,10 @@ static int parse_ul(sdp_parser_t *p, char **r,
|
||||
}
|
||||
|
||||
#if !HAVE_STRTOULL
|
||||
#if !((defined(WIN32) || defined(_WIN32)) && (_MSC_VER >= 1800))
|
||||
unsigned long long strtoull(char const *string, char **return_end, int base);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/*
|
||||
* parse_ull: parse an unsigned long long
|
||||
|
||||
@@ -311,7 +311,7 @@ issize_t sip_alert_info_e(char b[], isize_t bsiz, sip_header_t const *h, int f)
|
||||
* {
|
||||
* sip_common_t rplyto_common[1]; // Common fragment info
|
||||
|
||||
* sip_error_t *rplyto_next; // Dummy link to next header
|
||||
* sip_reply_to_t *rplyto_next; // Dummy link to next header
|
||||
* char const *rplyto_display; // Display name
|
||||
* url_t rplyto_url[1]; // Return URI
|
||||
* msg_param_t const *rplyto_params; // List of optional parameters
|
||||
|
||||
@@ -87,7 +87,7 @@ typedef struct sip_reply_to_s sip_reply_to_t;
|
||||
struct sip_reply_to_s
|
||||
{
|
||||
sip_common_t rplyto_common[1]; /**< Common fragment info */
|
||||
sip_error_t *rplyto_next; /**< Dummy link to next header */
|
||||
sip_reply_to_t *rplyto_next; /**< Dummy link to next header */
|
||||
char const *rplyto_display; /**< Display name */
|
||||
url_t rplyto_url[1]; /**< Return URI */
|
||||
msg_param_t const *rplyto_params; /**< List of optional parameters */
|
||||
|
||||
@@ -68,7 +68,7 @@ SU_DLL void *su_home_new(isize_t size)
|
||||
#if (defined(HAVE_MEMLEAK_LOG) && (HAVE_MEMLEAK_LOG != 1))
|
||||
|
||||
int _su_home_mutex_lock(su_home_t *home, const char *file, unsigned int line, const char *function);
|
||||
int _su_home_mutex_lock(su_home_t *home, const char *file, unsigned int line, const char *function);
|
||||
int _su_home_mutex_unlock(su_home_t *home, const char *file, unsigned int line, const char *function);
|
||||
|
||||
#define su_home_mutex_lock(home) \
|
||||
_su_home_mutex_lock((home), __FILE__, __LINE__, __func__)
|
||||
|
||||
@@ -73,7 +73,10 @@ static char cvtIn[] = {
|
||||
20, 21, 22, 23, 24, 25, 26, 27, 28, 29,
|
||||
30, 31, 32, 33, 34, 35};
|
||||
|
||||
|
||||
|
||||
|
||||
#if !((defined(WIN32) || defined(_WIN32)) && (_MSC_VER >= 1800))
|
||||
|
||||
/**Convert an ASCII string into an unsigned long long integer.
|
||||
*
|
||||
* @param[in] string String of ASCII digits, possibly preceded by white
|
||||
@@ -284,3 +287,5 @@ strtoull(const char *string, char **endPtr, int base)
|
||||
|
||||
return (unsigned longlong)-1;
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -238,7 +238,7 @@ enum {
|
||||
};
|
||||
|
||||
#define ALIGNMENT (8)
|
||||
#define ALIGN(n) (size_t)(((n) + (ALIGNMENT - 1)) & (size_t)~(ALIGNMENT - 1))
|
||||
#define __ALIGN(n) (size_t)(((n) + (ALIGNMENT - 1)) & (size_t)~(ALIGNMENT - 1))
|
||||
#define SIZEBITS (sizeof (unsigned) * 8 - 1)
|
||||
|
||||
typedef struct {
|
||||
@@ -478,7 +478,7 @@ void *sub_alloc(su_home_t *home,
|
||||
sub->sub_preload && size <= sub->sub_prsize) {
|
||||
/* Use preloaded memory */
|
||||
size_t prused = sub->sub_prused + size + MEMCHECK_EXTRA;
|
||||
prused = ALIGN(prused);
|
||||
prused = __ALIGN(prused);
|
||||
if (prused <= sub->sub_prsize) {
|
||||
preload = (char *)sub->sub_preload + sub->sub_prused;
|
||||
sub->sub_prused = (unsigned)prused;
|
||||
@@ -1313,7 +1313,7 @@ void su_home_preload(su_home_t *home, isize_t n, isize_t isize)
|
||||
size_t size;
|
||||
void *preload;
|
||||
|
||||
size = n * ALIGN(isize);
|
||||
size = n * __ALIGN(isize);
|
||||
if (size > 65535) /* We have 16 bits... */
|
||||
size = 65535 & (ALIGNMENT - 1);
|
||||
|
||||
@@ -1334,13 +1334,13 @@ su_home_t *su_home_auto(void *area, isize_t size)
|
||||
{
|
||||
su_home_t *home;
|
||||
su_block_t *sub;
|
||||
size_t homesize = ALIGN(sizeof *home);
|
||||
size_t subsize = ALIGN(offsetof(su_block_t, sub_nodes[SUB_N_AUTO]));
|
||||
size_t homesize = __ALIGN(sizeof *home);
|
||||
size_t subsize = __ALIGN(offsetof(su_block_t, sub_nodes[SUB_N_AUTO]));
|
||||
size_t prepsize;
|
||||
|
||||
char *p = area;
|
||||
|
||||
prepsize = homesize + subsize + (ALIGN((intptr_t)p) - (intptr_t)p);
|
||||
prepsize = homesize + subsize + (__ALIGN((intptr_t)p) - (intptr_t)p);
|
||||
|
||||
if (area == NULL || size < prepsize)
|
||||
return NULL;
|
||||
@@ -1443,11 +1443,11 @@ void *su_realloc(su_home_t *home, void *data, isize_t size)
|
||||
|
||||
p = (char *)data - home->suh_blocks->sub_preload;
|
||||
p += sua->sua_size + MEMCHECK_EXTRA;
|
||||
p = ALIGN(p);
|
||||
p = __ALIGN(p);
|
||||
|
||||
if (p == sub->sub_prused) {
|
||||
size_t p2 = (char *)data - sub->sub_preload + size + MEMCHECK_EXTRA;
|
||||
p2 = ALIGN(p2);
|
||||
p2 = __ALIGN(p2);
|
||||
if (p2 <= sub->sub_prsize) {
|
||||
/* Extend/reduce existing preload */
|
||||
if (sub->sub_stats) {
|
||||
@@ -1840,7 +1840,7 @@ void su_home_stats_alloc(su_block_t *sub, void *p, void *preload,
|
||||
{
|
||||
su_home_stat_t *hs = sub->sub_stats;
|
||||
|
||||
size_t rsize = ALIGN(size);
|
||||
size_t rsize = __ALIGN(size);
|
||||
|
||||
hs->hs_rehash += (sub->sub_n != hs->hs_blocksize);
|
||||
hs->hs_blocksize = sub->sub_n;
|
||||
@@ -1869,7 +1869,7 @@ void su_home_stats_free(su_block_t *sub, void *p, void *preload,
|
||||
{
|
||||
su_home_stat_t *hs = sub->sub_stats;
|
||||
|
||||
size_t rsize = ALIGN(size);
|
||||
size_t rsize = __ALIGN(size);
|
||||
|
||||
if (preload) {
|
||||
hs->hs_frees.hsf_preload++;
|
||||
|
||||
@@ -60,8 +60,10 @@
|
||||
#include <sofia-sip/su_string.h>
|
||||
|
||||
#ifndef HAVE_STRTOULL
|
||||
#if !((defined(WIN32) || defined(_WIN32)) && (_MSC_VER >= 1800))
|
||||
unsigned longlong strtoull(const char *, char **, int);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/**@defgroup su_tag Tag Item Lists
|
||||
*
|
||||
|
||||
@@ -110,7 +110,8 @@ static int initialized;
|
||||
static union state *
|
||||
get_state(void)
|
||||
{
|
||||
static union state *retval, state0[1];
|
||||
static union state state0[1];
|
||||
union state *retval;
|
||||
|
||||
#if SU_HAVE_PTHREADS
|
||||
|
||||
|
||||
@@ -142,6 +142,12 @@ TPORT_DLL extern tag_typedef_t tptag_timeout;
|
||||
TPORT_DLL extern tag_typedef_t tptag_timeout_ref;
|
||||
#define TPTAG_TIMEOUT_REF(x) tptag_timeout_ref, tag_uint_vr(&(x))
|
||||
|
||||
TPORT_DLL extern tag_typedef_t tptag_socket_keepalive;
|
||||
#define TPTAG_SOCKET_KEEPALIVE(x) tptag_socket_keepalive, tag_uint_v((x))
|
||||
|
||||
TPORT_DLL extern tag_typedef_t tptag_socket_keepalive_ref;
|
||||
#define TPTAG_SOCKET_KEEPALIVE_REF(x) tptag_socket_keepalive_ref, tag_uint_vr(&(x))
|
||||
|
||||
TPORT_DLL extern tag_typedef_t tptag_keepalive;
|
||||
#define TPTAG_KEEPALIVE(x) tptag_keepalive, tag_uint_v((x))
|
||||
|
||||
@@ -180,6 +186,20 @@ TPORT_DLL extern tag_typedef_t tptag_certificate;
|
||||
TPORT_DLL extern tag_typedef_t tptag_certificate_ref;
|
||||
#define TPTAG_CERTIFICATE_REF(x) tptag_certificate_ref, tag_str_vr(&(x))
|
||||
|
||||
TPORT_DLL extern tag_typedef_t tptag_tls_ciphers;
|
||||
#define TPTAG_TLS_CIPHERS(x) tptag_tls_ciphers, tag_str_v((x))
|
||||
|
||||
TPORT_DLL extern tag_typedef_t tptag_tls_ciphers_ref;
|
||||
#define TPTAG_TLS_CIPHERS_REF(x) tptag_tls_ciphers_ref, tag_str_vr(&(x))
|
||||
|
||||
enum tport_tls_version {
|
||||
TPTLS_VERSION_SSLv2 = (1 << 0),
|
||||
TPTLS_VERSION_SSLv3 = (1 << 1),
|
||||
TPTLS_VERSION_TLSv1 = (1 << 2),
|
||||
TPTLS_VERSION_TLSv1_1 = (1 << 3),
|
||||
TPTLS_VERSION_TLSv1_2 = (1 << 4),
|
||||
};
|
||||
|
||||
TPORT_DLL extern tag_typedef_t tptag_tls_version;
|
||||
#define TPTAG_TLS_VERSION(x) tptag_tls_version, tag_uint_v((x))
|
||||
|
||||
|
||||
@@ -520,6 +520,7 @@ tport_t *tport_tcreate(tp_stack_t *stack,
|
||||
tpp->tpp_idle = UINT_MAX;
|
||||
tpp->tpp_timeout = UINT_MAX;
|
||||
tpp->tpp_sigcomp_lifetime = UINT_MAX;
|
||||
tpp->tpp_socket_keepalive = 30;
|
||||
tpp->tpp_keepalive = 0;
|
||||
tpp->tpp_pingpong = 0;
|
||||
tpp->tpp_pong2ping = 0;
|
||||
@@ -1218,6 +1219,7 @@ int tport_get_params(tport_t const *self,
|
||||
TPTAG_QUEUESIZE(tpp->tpp_qsize),
|
||||
TPTAG_IDLE(tpp->tpp_idle),
|
||||
TPTAG_TIMEOUT(tpp->tpp_timeout),
|
||||
TPTAG_SOCKET_KEEPALIVE(tpp->tpp_socket_keepalive),
|
||||
TPTAG_KEEPALIVE(tpp->tpp_keepalive),
|
||||
TPTAG_PINGPONG(tpp->tpp_pingpong),
|
||||
TPTAG_PONG2PING(tpp->tpp_pong2ping),
|
||||
@@ -1283,6 +1285,7 @@ int tport_set_params(tport_t *self,
|
||||
TAG_IF(!self->tp_queue, TPTAG_QUEUESIZE_REF(tpp->tpp_qsize)),
|
||||
TPTAG_IDLE_REF(tpp->tpp_idle),
|
||||
TPTAG_TIMEOUT_REF(tpp->tpp_timeout),
|
||||
TPTAG_SOCKET_KEEPALIVE_REF(tpp->tpp_socket_keepalive),
|
||||
TPTAG_KEEPALIVE_REF(tpp->tpp_keepalive),
|
||||
TPTAG_PINGPONG_REF(tpp->tpp_pingpong),
|
||||
TPTAG_PONG2PING_REF(pong2ping),
|
||||
|
||||
@@ -106,6 +106,7 @@ typedef struct {
|
||||
unsigned tpp_mtu; /**< Maximum packet size */
|
||||
unsigned tpp_idle; /**< Allowed connection idle time. */
|
||||
unsigned tpp_timeout; /**< Allowed idle time for message. */
|
||||
unsigned tpp_socket_keepalive;/**< Socket keepalive interval */
|
||||
unsigned tpp_keepalive; /**< Keepalive PING interval */
|
||||
unsigned tpp_pingpong; /**< PONG-to-PING interval */
|
||||
|
||||
|
||||
@@ -179,6 +179,14 @@ tag_typedef_t tptag_idle = UINTTAG_TYPEDEF(idle);
|
||||
*/
|
||||
tag_typedef_t tptag_timeout = UINTTAG_TYPEDEF(timeout);
|
||||
|
||||
/**@def TPTAG_SOCKET_KEEPALIVE(x)
|
||||
*
|
||||
* Keepalive interval set on socket (where supported) in seconds.
|
||||
*
|
||||
* If 0 or UINT_MAX, do not use keepalives. Default value is 30.
|
||||
*/
|
||||
tag_typedef_t tptag_socket_keepalive = UINTTAG_TYPEDEF(socket_keepalive);
|
||||
|
||||
/**@def TPTAG_KEEPALIVE(x)
|
||||
*
|
||||
* Keepalive interval in milliseconds.
|
||||
@@ -270,6 +278,14 @@ tag_typedef_t tptag_certificate = STRTAG_TYPEDEF(certificate);
|
||||
*/
|
||||
tag_typedef_t tptag_compartment = PTRTAG_TYPEDEF(compartment);
|
||||
|
||||
/**@def TPTAG_TLS_CIPHERS(x)
|
||||
*
|
||||
* Sets the supported TLS cipher suites.
|
||||
*
|
||||
* Use with tport_tbind(), nua_create(), nta_agent_create(),
|
||||
* nta_agent_add_tport(), nth_engine_create(), or initial nth_site_create().
|
||||
*/
|
||||
tag_typedef_t tptag_tls_ciphers = STRTAG_TYPEDEF(tls_ciphers);
|
||||
|
||||
/**@def TPTAG_TLS_VERSION(x)
|
||||
*
|
||||
|
||||
@@ -202,7 +202,7 @@ void tls_set_default(tls_issues_t *i)
|
||||
i->key = i->key ? i->key : i->cert;
|
||||
i->randFile = i->randFile ? i->randFile : "tls_seed.dat";
|
||||
i->CAfile = i->CAfile ? i->CAfile : "cafile.pem";
|
||||
i->cipher = i->cipher ? i->cipher : "ALL:!ADH:!LOW:!EXP:!MD5:@STRENGTH";
|
||||
i->ciphers = i->ciphers ? i->ciphers : "ALL:!ADH:!LOW:!EXP:!MD5:@STRENGTH";
|
||||
/* Default SIP cipher */
|
||||
/* "RSA-WITH-AES-128-CBC-SHA"; */
|
||||
/* RFC-2543-compatibility ciphersuite */
|
||||
@@ -267,6 +267,27 @@ void tls_init(void) {
|
||||
ONCE_INIT(tls_init_once);
|
||||
}
|
||||
|
||||
static
|
||||
int tls_init_ecdh_curve(tls_t *tls)
|
||||
{
|
||||
int nid;
|
||||
EC_KEY *ecdh;
|
||||
if (!(nid = OBJ_sn2nid("prime256v1"))) {
|
||||
tls_log_errors(1, "Couldn't find specified curve", 0);
|
||||
errno = EIO;
|
||||
return -1;
|
||||
}
|
||||
if (!(ecdh = EC_KEY_new_by_curve_name(nid))) {
|
||||
tls_log_errors(1, "Couldn't create specified curve", 0);
|
||||
errno = EIO;
|
||||
return -1;
|
||||
}
|
||||
SSL_CTX_set_options(tls->ctx, SSL_OP_SINGLE_ECDH_USE);
|
||||
SSL_CTX_set_tmp_ecdh(tls->ctx, ecdh);
|
||||
EC_KEY_free(ecdh);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static
|
||||
int tls_init_context(tls_t *tls, tls_issues_t const *ti)
|
||||
{
|
||||
@@ -295,27 +316,23 @@ int tls_init_context(tls_t *tls, tls_issues_t const *ti)
|
||||
signal(SIGPIPE, SIG_IGN);
|
||||
#endif
|
||||
|
||||
if (tls->ctx == NULL) {
|
||||
const SSL_METHOD *meth;
|
||||
|
||||
/* meth = SSLv3_method(); */
|
||||
/* meth = SSLv23_method(); */
|
||||
|
||||
if (ti->version)
|
||||
meth = TLSv1_method();
|
||||
else
|
||||
meth = SSLv23_method();
|
||||
|
||||
tls->ctx = SSL_CTX_new((SSL_METHOD*)meth);
|
||||
SSL_CTX_sess_set_remove_cb(tls->ctx, NULL);
|
||||
}
|
||||
|
||||
if (tls->ctx == NULL) {
|
||||
tls_log_errors(1, "tls_init_context", 0);
|
||||
errno = EIO;
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (tls->ctx == NULL)
|
||||
if (!(tls->ctx = SSL_CTX_new((SSL_METHOD*)SSLv23_method()))) {
|
||||
tls_log_errors(1, "SSL_CTX_new() failed", 0);
|
||||
errno = EIO;
|
||||
return -1;
|
||||
}
|
||||
if (!(ti->version & TPTLS_VERSION_SSLv2))
|
||||
SSL_CTX_set_options(tls->ctx, SSL_OP_NO_SSLv2);
|
||||
if (!(ti->version & TPTLS_VERSION_SSLv3))
|
||||
SSL_CTX_set_options(tls->ctx, SSL_OP_NO_SSLv3);
|
||||
if (!(ti->version & TPTLS_VERSION_TLSv1))
|
||||
SSL_CTX_set_options(tls->ctx, SSL_OP_NO_TLSv1);
|
||||
if (!(ti->version & TPTLS_VERSION_TLSv1_1))
|
||||
SSL_CTX_set_options(tls->ctx, SSL_OP_NO_TLSv1_1);
|
||||
if (!(ti->version & TPTLS_VERSION_TLSv1_2))
|
||||
SSL_CTX_set_options(tls->ctx, SSL_OP_NO_TLSv1_2);
|
||||
SSL_CTX_sess_set_remove_cb(tls->ctx, NULL);
|
||||
SSL_CTX_set_timeout(tls->ctx, ti->timeout);
|
||||
|
||||
/* Set callback if we have a passphrase */
|
||||
@@ -389,7 +406,13 @@ int tls_init_context(tls_t *tls, tls_issues_t const *ti)
|
||||
SSL_CTX_set_verify_depth(tls->ctx, ti->verify_depth);
|
||||
SSL_CTX_set_verify(tls->ctx, verify, tls_verify_cb);
|
||||
|
||||
if (!SSL_CTX_set_cipher_list(tls->ctx, ti->cipher)) {
|
||||
if (tls_init_ecdh_curve(tls) == 0) {
|
||||
SU_DEBUG_3(("%s\n", "tls: initialized ECDH"));
|
||||
} else {
|
||||
SU_DEBUG_3(("%s\n", "tls: failed to initialize ECDH"));
|
||||
}
|
||||
|
||||
if (!SSL_CTX_set_cipher_list(tls->ctx, ti->ciphers)) {
|
||||
SU_DEBUG_1(("%s: error setting cipher list\n", "tls_init_context"));
|
||||
tls_log_errors(3, "tls_init_context", 0);
|
||||
errno = EIO;
|
||||
|
||||
@@ -60,7 +60,7 @@ typedef struct tls_issues_s {
|
||||
char *randFile; /* Seed file for the PRNG (default: tls_seed.dat) */
|
||||
char *CAfile; /* PEM file of CA's */
|
||||
char *CApath; /* PEM file path of CA's */
|
||||
char *cipher; /* Should be one of the above defined ciphers *
|
||||
char *ciphers; /* Should be one of the above defined ciphers *
|
||||
* or NULL (default: "ALL:!ADH:!LOW:!EXP:!MD5:@STRENGTH
|
||||
*/
|
||||
int version; /* For tls1, version is 1. When ssl3/ssl2 is
|
||||
|
||||
@@ -196,12 +196,18 @@ int tport_tcp_init_secondary(tport_t *self, int socket, int accepted,
|
||||
#if defined(SO_KEEPALIVE)
|
||||
setsockopt(socket, SOL_SOCKET, SO_KEEPALIVE, (void *)&val, sizeof val);
|
||||
#endif
|
||||
val = 30;
|
||||
val = (int)(self->tp_params->tpp_socket_keepalive);
|
||||
#if defined(TCP_KEEPIDLE)
|
||||
setsockopt(socket, SOL_TCP, TCP_KEEPIDLE, (void *)&val, sizeof val);
|
||||
if (val != 0 && val != UINT_MAX) {
|
||||
SU_DEBUG_3(("%s(%p): Setting TCP_KEEPIDLE to %d\n",
|
||||
__func__, (void *)self, val));
|
||||
setsockopt(socket, SOL_TCP, TCP_KEEPIDLE, (void *)&val, sizeof val);}
|
||||
#endif
|
||||
#if defined(TCP_KEEPINTVL)
|
||||
setsockopt(socket, SOL_TCP, TCP_KEEPINTVL, (void *)&val, sizeof val);
|
||||
if (val != 0 && val != UINT_MAX) {
|
||||
SU_DEBUG_3(("%s(%p): Setting TCP_KEEPINTVL to %d\n",
|
||||
__func__, (void *)self, val));
|
||||
setsockopt(socket, SOL_TCP, TCP_KEEPINTVL, (void *)&val, sizeof val);}
|
||||
#endif
|
||||
|
||||
if (!accepted)
|
||||
|
||||
@@ -180,6 +180,7 @@ static int tport_tls_init_master(tport_primary_t *pri,
|
||||
char *homedir;
|
||||
char *tbf = NULL;
|
||||
char const *path = NULL;
|
||||
char const *tls_ciphers = NULL;
|
||||
unsigned tls_version = 1;
|
||||
unsigned tls_timeout = 300;
|
||||
unsigned tls_verify = 0;
|
||||
@@ -198,6 +199,7 @@ static int tport_tls_init_master(tport_primary_t *pri,
|
||||
|
||||
tl_gets(tags,
|
||||
TPTAG_CERTIFICATE_REF(path),
|
||||
TPTAG_TLS_CIPHERS_REF(tls_ciphers),
|
||||
TPTAG_TLS_VERSION_REF(tls_version),
|
||||
TPTAG_TLS_TIMEOUT_REF(tls_timeout),
|
||||
TPTAG_TLS_VERIFY_PEER_REF(tls_verify),
|
||||
@@ -229,6 +231,7 @@ static int tport_tls_init_master(tport_primary_t *pri,
|
||||
ti.CAfile = su_sprintf(autohome, "%s/%s", path, "cafile.pem");
|
||||
if (access(ti.CAfile, R_OK) != 0) ti.CAfile = NULL;
|
||||
if (!ti.CAfile) ti.CAfile = su_sprintf(autohome, "%s/%s", path, "tls.pem");
|
||||
if (tls_ciphers) ti.ciphers = su_strdup(autohome, tls_ciphers);
|
||||
ti.version = tls_version;
|
||||
ti.timeout = tls_timeout;
|
||||
ti.CApath = su_strdup(autohome, path);
|
||||
|
||||
@@ -338,6 +338,7 @@ static int tport_ws_init_primary_secure(tport_primary_t *pri,
|
||||
tport_ws_primary_t *wspri = (tport_ws_primary_t *)pri;
|
||||
const char *cert = "/ssl.pem";
|
||||
const char *key = "/ssl.pem";
|
||||
const char *chain = NULL;
|
||||
char *homedir;
|
||||
char *tbf = NULL;
|
||||
su_home_t autohome[SU_HOME_AUTO_SIZE(1024)];
|
||||
@@ -361,11 +362,13 @@ static int tport_ws_init_primary_secure(tport_primary_t *pri,
|
||||
key = su_sprintf(autohome, "%s/%s", path, "wss.key");
|
||||
if (access(key, R_OK) != 0) key = NULL;
|
||||
cert = su_sprintf(autohome, "%s/%s", path, "wss.crt");
|
||||
chain = su_sprintf(autohome, "%s/%s", path, "ca-bundle.crt");
|
||||
if (access(cert, R_OK) != 0) cert = NULL;
|
||||
if ( !key ) key = su_sprintf(autohome, "%s/%s", path, "wss.pem");
|
||||
if ( !cert ) cert = su_sprintf(autohome, "%s/%s", path, "wss.pem");
|
||||
if (access(key, R_OK) != 0) key = NULL;
|
||||
if (access(cert, R_OK) != 0) cert = NULL;
|
||||
if (access(chain, R_OK) != 0) chain = NULL;
|
||||
}
|
||||
|
||||
init_ssl();
|
||||
@@ -379,6 +382,10 @@ static int tport_ws_init_primary_secure(tport_primary_t *pri,
|
||||
|
||||
if ( !wspri->ssl_ctx ) goto done;
|
||||
|
||||
if (chain) {
|
||||
SSL_CTX_use_certificate_chain_file(wspri->ssl_ctx, chain);
|
||||
}
|
||||
|
||||
/* set the local certificate from CertFile */
|
||||
SSL_CTX_use_certificate_file(wspri->ssl_ctx, cert, SSL_FILETYPE_PEM);
|
||||
/* set the private key from KeyFile */
|
||||
|
||||
@@ -290,7 +290,7 @@ int ws_handshake(wsh_t *wsh)
|
||||
|
||||
ws_raw_write(wsh, respond, strlen(respond));
|
||||
wsh->handshake = 1;
|
||||
|
||||
|
||||
return 0;
|
||||
|
||||
err:
|
||||
@@ -809,7 +809,7 @@ int xp_errno(void)
|
||||
|
||||
int xp_is_blocking(int errcode)
|
||||
{
|
||||
return errcode == EAGAIN || errcode == EWOULDBLOCK || errcode == EINPROGRESS || errcode == EINTR;
|
||||
return errcode == EAGAIN || errcode == EWOULDBLOCK || errcode == EINPROGRESS || errcode == EINTR || errcode == ETIMEDOUT;
|
||||
}
|
||||
|
||||
#endif
|
||||
Reference in new issue
Block a user