Skip to content

Commit

Permalink
Implemented CA path selection
Browse files Browse the repository at this point in the history
  • Loading branch information
andreycizov committed Nov 24, 2017
1 parent 2812eb9 commit 1576056
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions lib/gelf/transport/tcp_tls.rb
Expand Up @@ -6,10 +6,13 @@ module Transport
class TCPTLS < TCP
# Supported tls_options:
# 'no_default_ca' [Boolean] prevents OpenSSL from using the systems CA store.
# 'ca' [String] the path to a custom CA store
# 'tls_version' [Symbol] any of :TLSv1, :TLSv1_1, :TLSv1_2 (default)
# 'cert' [String, IO] the client certificate file
# 'key' [String, IO] the key for the client certificate
# 'all_ciphers' [Boolean] allows any ciphers to be used, may be insecure
# 'no_verify' [Boolean] disable peer verification

def initialize(addresses, tls_options={})
@tls_options = tls_options
super(addresses)
Expand Down Expand Up @@ -103,8 +106,18 @@ def tls_version

def ssl_cert_store
OpenSSL::X509::Store.new.tap do |store|
# TODO: allow passing in expected server certificate and disabling system CAs
store.set_default_paths
if @tls_options.key?('no_default_ca') && @tls_options.key?('no_default_ca')
@tls_options['no_default_ca']
else
@tls_options['no_default_ca'] = false
end
if !@tls_options['no_default_ca']
store.set_default_paths
end

if @tls_options.key?('ca')
store.add_path(@tls_options['ca'])
end
end
end
end
Expand Down

0 comments on commit 1576056

Please sign in to comment.