]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
FS-11207: [core] Fix msrp_init_ssl and msrp_deinit_ssl functions, check globals.ssl_r...
authorHunyadvári Péter <peter.hunyadvari@vcc.live>
Fri, 12 Oct 2018 09:06:04 +0000 (11:06 +0200)
committerHunyadvári Péter <peter.hunyadvari@vcc.live>
Fri, 12 Oct 2018 09:06:04 +0000 (11:06 +0200)
src/switch_msrp.c

index 5c48a77781c1286b5005d6e84404d1ddddd4b1ab..c4d430194b9b0a23df26f9955d4997fc56d692a1 100644 (file)
@@ -103,13 +103,14 @@ static switch_bool_t msrp_check_success_report(switch_msrp_msg_t *msrp_msg)
 
 static void msrp_deinit_ssl()
 {
+       globals.ssl_ready = 0;
        if (globals.ssl_ctx) {
                SSL_CTX_free(globals.ssl_ctx);
                globals.ssl_ctx = NULL;
        }
 }
 
-static int msrp_init_ssl()
+static void msrp_init_ssl()
 {
        const char *err = "";
 
@@ -175,15 +176,11 @@ static int msrp_init_ssl()
 
        SSL_CTX_set_cipher_list(globals.ssl_ctx, "HIGH:!DSS:!aNULL@STRENGTH");
 
-       return 1;
+       return;
 
  fail:
        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "SSL ERR: %s\n", err);
-
-       globals.ssl_ready = 0;
        msrp_deinit_ssl();
-
-       return 0;
 }
 
 SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_ip, globals.ip);
@@ -316,10 +313,7 @@ SWITCH_DECLARE(switch_status_t) switch_msrp_init()
                globals.msock.thread = thread;
        }
 
-       if (msrp_init_ssl() == 0) {
-               switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "MSRP ssl init failed\n");
-               return SWITCH_STATUS_FALSE;
-       }
+       msrp_init_ssl();
        status = msock_init(globals.ip, globals.msock_ssl.port, &globals.msock_ssl.sock, pool);
 
        if (status == SWITCH_STATUS_SUCCESS) {
@@ -1145,6 +1139,10 @@ static void *SWITCH_THREAD_FUNC msrp_worker(switch_thread_t *thread, void *obj)
                // switch_socket_opt_set(csock->sock, SWITCH_SO_NONBLOCK, TRUE);
 
                if (csock->secure) { // tls?
+                       if (globals.ssl_ready != 1) {
+                               switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "SSL not ready\n");
+                               goto end;
+                       }
                        int secure_established = 0;
                        int sanity = 10;
                        switch_os_socket_t sockdes = SWITCH_SOCK_INVALID;