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

Add server TLS certificate verification #2171

Merged
merged 7 commits into from
Jun 16, 2020
Merged
Show file tree
Hide file tree
Changes from 6 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
2 changes: 1 addition & 1 deletion cmd/fluentd/fluent-plugin-grafana-loki.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ $LOAD_PATH.push File.expand_path('lib', __dir__)

Gem::Specification.new do |spec|
spec.name = 'fluent-plugin-grafana-loki'
spec.version = '1.2.12'
spec.version = '1.2.13'
spec.authors = %w[woodsaj briangann cyriltovena]
spec.email = ['[email protected]', '[email protected]', '[email protected]']

Expand Down
13 changes: 12 additions & 1 deletion cmd/fluentd/lib/fluent/plugin/out_loki.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ class LogPostError < StandardError; end
desc 'TLS'
config_param :ca_cert, :string, default: nil

desc 'Disable server certificate verification'
config_param :insecure_tls, :bool, default: false

desc 'Loki tenant id'
config_param :tenant, :string, default: nil

Expand Down Expand Up @@ -153,14 +156,22 @@ def ssl_opts(uri)
use_ssl: uri.scheme == 'https'
}

# Disable server TLS certificate verification
if @insecure_tls
opts = opts.merge(
verify_mode: OpenSSL::SSL::VERIFY_NONE
)
end

# Verify client TLS certificate
if [email protected]? && [email protected]?
opts = opts.merge(
verify_mode: OpenSSL::SSL::VERIFY_PEER,
cert: @cert,
key: @key
)
end

# Specify custom certificate authority
unless @ca_cert.nil?
opts = opts.merge(
ca_file: @ca_cert
Expand Down
2 changes: 2 additions & 0 deletions cmd/fluentd/spec/gems/fluent/plugin/loki_output_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
line_format key_value
drop_single_key true
remove_keys a, b
insecure_tls true
<label>
job
instance instance
Expand All @@ -39,6 +40,7 @@
expect(driver.instance.record_accessors.keys).to eq %w[job instance]
expect(driver.instance.remove_keys).to eq %w[a b]
expect(driver.instance.drop_single_key).to eq true
expect(driver.instance.insecure_tls).to eq true
end

it 'converts syslog output to loki output' do
Expand Down
15 changes: 15 additions & 0 deletions docs/clients/fluentd/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,21 @@ Specify a pair of client certificate and private key with `cert` and `key` if a
</match>
```

### server certificate verification
cyriltovena marked this conversation as resolved.
Show resolved Hide resolved
A flag to disable a server certificate verification. By default the `insecure_tls` is set to false.

```
<match **>
@type loki

url "https://loki"

insecure_tls true

...
</match>
```

### output format
Loki is intended to index and group log streams using only a small set of labels. It is not intended for full-text indexing. When sending logs to Loki the majority of log message will be sent as a single log "line".

Expand Down