Skip to content

Commit 3cdd4b4

Browse files
authored
Merge pull request #164 from richm/issue-163
add support for ssl_partial_chain
2 parents 466db5a + 5030dd2 commit 3cdd4b4

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,9 @@ when true (default: `true`)
5454
* `orphaned_namespace_name` - The namespace to associate with records where the namespace can not be determined (default: `.orphaned`)
5555
* `orphaned_namespace_id` - The namespace id to associate with records where the namespace can not be determined (default: `orphaned`)
5656
* `lookup_from_k8s_field` - If the field `kubernetes` is present, lookup the metadata from the given subfields such as `kubernetes.namespace_name`, `kubernetes.pod_name`, etc. This allows you to avoid having to pass in metadata to lookup in an explicitly formatted tag name or in an explicitly formatted `CONTAINER_NAME` value. For example, set `kubernetes.namespace_name`, `kubernetes.pod_name`, `kubernetes.container_name`, and `docker.id` in the record, and the filter will fill in the rest. (default: `true`)
57+
* `ssl_partial_chain` - if `ca_file` is for an intermediate CA, or otherwise we do not have the root CA and want
58+
to trust the intermediate CA certs we do have, set this to `true` - this corresponds to
59+
the `openssl s_client -partial_chain` flag and `X509_V_FLAG_PARTIAL_CHAIN` (default: `false`)
5760

5861
**NOTE:** As of the release 2.1.x of this plugin, it no longer supports parsing the source message into JSON and attaching it to the
5962
payload. The following configuration options are removed:

lib/fluent/plugin/filter_kubernetes_metadata.rb

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,10 @@ class KubernetesMetadataFilter < Fluent::Plugin::Filter
7272
config_param :orphaned_namespace_name, :string, default: '.orphaned'
7373
config_param :orphaned_namespace_id, :string, default: 'orphaned'
7474
config_param :lookup_from_k8s_field, :bool, default: true
75+
# if `ca_file` is for an intermediate CA, or otherwise we do not have the root CA and want
76+
# to trust the intermediate CA certs we do have, set this to `true` - this corresponds to
77+
# the openssl s_client -partial_chain flag and X509_V_FLAG_PARTIAL_CHAIN
78+
config_param :ssl_partial_chain, :bool, default: false
7579

7680
def fetch_pod_metadata(namespace_name, pod_name)
7781
log.trace("fetching pod metadata: #{namespace_name}/#{pod_name}") if log.trace?
@@ -219,6 +223,21 @@ def log.trace?
219223
verify_ssl: @verify_ssl ? OpenSSL::SSL::VERIFY_PEER : OpenSSL::SSL::VERIFY_NONE
220224
}
221225

226+
if @ssl_partial_chain
227+
# taken from the ssl.rb OpenSSL::SSL::SSLContext code for DEFAULT_CERT_STORE
228+
require 'openssl'
229+
ssl_store = OpenSSL::X509::Store.new
230+
ssl_store.set_default_paths
231+
if defined? OpenSSL::X509::V_FLAG_PARTIAL_CHAIN
232+
flagval = OpenSSL::X509::V_FLAG_PARTIAL_CHAIN
233+
else
234+
# this version of ruby does not define OpenSSL::X509::V_FLAG_PARTIAL_CHAIN
235+
flagval = 0x80000
236+
end
237+
ssl_store.flags = OpenSSL::X509::V_FLAG_CRL_CHECK_ALL | flagval
238+
ssl_options[:cert_store] = ssl_store
239+
end
240+
222241
auth_options = {}
223242

224243
if @bearer_token_file.present?

0 commit comments

Comments
 (0)