Skip to content

Commit

Permalink
support ssl
Browse files Browse the repository at this point in the history
  • Loading branch information
aiwantaozi committed Jul 17, 2018
1 parent b53d005 commit 73a4613
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
9 changes: 6 additions & 3 deletions lib/remote_syslog_sender/tcp_sender.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ def initialize(remote_hostname, remote_port, options = {})
@ssl_method = options[:ssl_method] || 'TLSv1_2'
@ca_file = options[:ca_file]
@verify_mode = options[:verify_mode]
@client_cert = options[:client_cert]
@client_cert_key = options[:client_cert_key]
@client_cert_key_pass = options[:client_cert_key_pass]
@timeout = options[:timeout] || 600
@timeout_exception = !!options[:timeout_exception]
@exponential_backoff = !!options[:exponential_backoff]
Expand Down Expand Up @@ -64,13 +67,13 @@ def connect
if @tls
require 'openssl'
context = OpenSSL::SSL::SSLContext.new(@ssl_method)
context.ca_file = @ca_file if @ca_file
context.verify_mode = @verify_mode if @verify_mode

context.cert = OpenSSL::X509::Certificate.new(File.open(@client_cert) { |f| f.read }) if @client_cert
context.key = OpenSSL::PKey::RSA.new(File.open(@client_cert_key) { |f| f.read }, @client_cert_key_pass) if @client_cert_key
context.ca_file = @ca_file if @ca_file
@socket = OpenSSL::SSL::SSLSocket.new(@tcp_socket, context)
@socket.connect
@socket.post_connection_check(@remote_hostname)
raise "verification error" if @socket.verify_result != OpenSSL::X509::V_OK
else
@socket = @tcp_socket
end
Expand Down
2 changes: 1 addition & 1 deletion remote_syslog_sender.gemspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Gem::Specification.new do |s|
s.name = 'remote_syslog_sender'
s.version = '1.2.1'
s.version = '1.2.2'
s.summary = "Message sender that sends directly to a remote syslog endpoint"
s.description = "Message sender that sends directly to a remote syslog endpoint (Support UDP, TCP, TCP+TLS)"

Expand Down

0 comments on commit 73a4613

Please sign in to comment.