From 9476f23aa60acd7c3509123360d9d8b6e5694cd8 Mon Sep 17 00:00:00 2001 From: Erwan Miran Date: Fri, 2 Feb 2024 16:23:11 +0100 Subject: [PATCH] Ability to use ssl_min_version and/or ssl_max_version instead of ssl_method --- lib/remote_syslog_sender/tcp_sender.rb | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/remote_syslog_sender/tcp_sender.rb b/lib/remote_syslog_sender/tcp_sender.rb index fb1a258..0fb6ae1 100644 --- a/lib/remote_syslog_sender/tcp_sender.rb +++ b/lib/remote_syslog_sender/tcp_sender.rb @@ -14,6 +14,8 @@ def initialize(remote_hostname, remote_port, options = {}) @remote_hostname = remote_hostname @remote_port = remote_port @ssl_method = options[:ssl_method] || 'TLSv1_2' + @ssl_min_version = options[:ssl_min_version] + @ssl_max_version = options[:ssl_max_version] @ca_file = options[:ca_file] @verify_mode = options[:verify_mode] @timeout = options[:timeout] || 600 @@ -63,7 +65,13 @@ def connect end if @tls require 'openssl' - context = OpenSSL::SSL::SSLContext.new(@ssl_method) + context = OpenSSL::SSL::SSLContext.new() + if not (@ssl_min_version || @ssl_max_version) + context.min_version = @ssl_min_version + context.max_version = @ssl_max_version + else + context.ssl_version = @ssl_method + end context.ca_file = @ca_file if @ca_file context.verify_mode = @verify_mode if @verify_mode