فهرست منبع

cdp: Disable TLS support for openssl versions older than 1.1.0

Morten Tryfoss 1 سال پیش
والد
کامیت
8d84c6210f
3فایلهای تغییر یافته به همراه17 افزوده شده و 0 حذف شده
  1. 7 0
      src/modules/cdp/cdp_mod.c
  2. 2 0
      src/modules/cdp/cdp_tls.c
  3. 8 0
      src/modules/cdp/receiver.c

+ 7 - 0
src/modules/cdp/cdp_mod.c

@@ -239,6 +239,7 @@ static int cdp_init(void)
 		return 1;
 	}
 
+	#if OPENSSL_VERSION_NUMBER >= 0x10100000L
 	if(enable_tls) {
 		init_ssl_methods();
 		method = tls_parse_method(&tls_method);
@@ -247,6 +248,12 @@ static int cdp_init(void)
 			return -1;
 		}
 	}
+	#else
+	if(enable_tls) {
+		LM_ERR("TLS requires openssl 1.1.0 or newer\n");
+		return -1;
+	}
+	#endif
 
 	register_procs(2 + config->workers + 2 * config->peers_cnt);
 	cfg_register_child(2 + config->workers + 2 * config->peers_cnt);

+ 2 - 0
src/modules/cdp/cdp_tls.c

@@ -1,3 +1,4 @@
+#if OPENSSL_VERSION_NUMBER >= 0x10100000L
 #include "cdp_tls.h"
 
 cfg_option_t methods[] = {{"TLSv1", .val = TLS_USE_TLSv1},
@@ -255,3 +256,4 @@ int to_ssl(SSL_CTX **tls_ctx_p, SSL **tls_conn_p, int tcp_sock, int method)
 	}
 	return 0;
 }
+#endif

+ 8 - 0
src/modules/cdp/receiver.c

@@ -813,10 +813,12 @@ int receive_loop(peer *original_peer)
 								p->R_sock = fd;
 							}
 
+							#if OPENSSL_VERSION_NUMBER >= 0x10100000L
 							if(enable_tls) {
 								to_ssl(&sp2->tls_ctx, &sp2->tls_conn,
 										sp->tcp_socket, method);
 							}
+							#endif
 						} else {
 							sp2 = add_serviced_peer(NULL);
 							if(!sp2) {
@@ -824,10 +826,12 @@ int receive_loop(peer *original_peer)
 								continue;
 							}
 							sp2->tcp_socket = fd;
+							#if OPENSSL_VERSION_NUMBER >= 0x10100000L
 							if(enable_tls) {
 								to_ssl(&sp2->tls_ctx, &sp2->tls_conn,
 										sp->tcp_socket, method);
 							}
+							#endif
 						}
 					}
 				}
@@ -879,7 +883,9 @@ int receive_loop(peer *original_peer)
 										sp->p ? sp->p->fqdn.s : "",
 										sp->tcp_socket, strerror(errno));
 								AAAFreeMessage(&msg);
+								#if OPENSSL_VERSION_NUMBER >= 0x10100000L
 								cleanup_ssl(sp->tls_ctx, sp->tls_conn);
+								#endif
 								close(sp->tcp_socket);
 								goto drop_peer;
 							}
@@ -892,7 +898,9 @@ int receive_loop(peer *original_peer)
 										sp->p ? sp->p->fqdn.s : "",
 										sp->tcp_socket, cnt, msg->buf.len);
 								AAAFreeMessage(&msg);
+								#if OPENSSL_VERSION_NUMBER >= 0x10100000L
 								cleanup_ssl(sp->tls_ctx, sp->tls_conn);
+								#endif
 								close(sp->tcp_socket);
 								goto drop_peer;
 							}