Skip to content

Commit

Permalink
Add server TLS certificate verification (#2171)
Browse files Browse the repository at this point in the history
* Add server TLS certificate verification

* Generalize use of server TLS certificate verification

* Fix typo

* Bump fluent-plugin-grafana-loki gem version: 1.2.12 -> 1.2.13

* Replace option: verify_tls -> insecure_tls

* Update document

* Update docs/clients/fluentd/README.md

Co-authored-by: Cyril Tovena <cyril.tovena@gmail.com>
  • Loading branch information
takanabe and cyriltovena authored Jun 16, 2020
1 parent 0ecaa10 commit e2a7941
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 2 deletions.
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 = ['awoods@grafana.com', 'brian@grafana.com', 'cyril.tovena@grafana.com']

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 !@cert.nil? && !@key.nil?
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
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

0 comments on commit e2a7941

Please sign in to comment.