Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

server: Add cert_verifier parameter for TLS transport #2888

Merged
merged 3 commits into from
Mar 18, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion lib/fluent/plugin_helper/cert_option.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def cert_option_create_context(version, insecure, ciphers, conf)
end

if conf.client_cert_auth
ctx.verify_mode = OpenSSL::SSL::VERIFY_PEER | OpenSSL::SSL::VERIFY_FAIL_IF_NO_PEER_CERT
ganmacs marked this conversation as resolved.
Show resolved Hide resolved
ctx.verify_mode = OpenSSL::SSL::VERIFY_PEER | OpenSSL::SSL::VERIFY_FAIL_IF_NO_PEER_CERT
end

ctx.ca_file = conf.ca_path
Expand All @@ -45,6 +45,16 @@ def cert_option_create_context(version, insecure, ciphers, conf)
if extra && !extra.empty?
ctx.extra_chain_cert = extra
end
if conf.cert_verifier
sandbox = Class.new
ctx.verify_callback = if File.exist?(conf.cert_verifier)
verifier = File.read(conf.cert_verifier)
sandbox.instance_eval(verifier, File.basename(conf.cert_verifier))
else
sandbox.instance_eval(conf.cert_verifier)
end
end

Fluent::TLS.set_version_to_context(ctx, version, conf.min_version, conf.max_version)

ctx
Expand Down
4 changes: 3 additions & 1 deletion lib/fluent/plugin_helper/server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ def server_create_for_tls_connection(shared, bind, port, conf, backlog, socket_o
:protocol, :version, :min_version, :max_version, :ciphers, :insecure,
:ca_path, :cert_path, :private_key_path, :private_key_passphrase, :client_cert_auth,
:ca_cert_path, :ca_private_key_path, :ca_private_key_passphrase,
:generate_private_key_length,
:cert_verifier, :generate_private_key_length,
:generate_cert_country, :generate_cert_state, :generate_cert_state,
:generate_cert_locality, :generate_cert_common_name,
:generate_cert_expiration, :generate_cert_digest,
Expand Down Expand Up @@ -281,6 +281,8 @@ module ServerTransportParams
config_param :ca_private_key_path, :string, default: nil
config_param :ca_private_key_passphrase, :string, default: nil, secret: true

config_param :cert_verifier, :string, default: nil

# Options for generating certs by private CA certs or self-signed
config_param :generate_private_key_length, :integer, default: 2048
config_param :generate_cert_country, :string, default: 'US'
Expand Down