Skip to content

Fix opensearch https failing with ENOENT when client cert env vars are unset - #1702

Open
lbarrosby wants to merge 1 commit into
fluent:masterfrom
lbarrosby:fix-opensearch-empty-tls-auth
Open

lbarrosby wants to merge 1 commit into
fluent:masterfrom
lbarrosby:fix-opensearch-empty-tls-auth

Conversation

@lbarrosby

Copy link
Copy Markdown
Contributor

The opensearch <match> block passes ca_file, user, password, client_cert, client_key and client_key_pass without a fallback, so when the env var is not set the plugin gets "" instead of nil. With FLUENT_OPENSEARCH_SCHEME=https and no client certificate (the usual case, for example AWS OpenSearch), excon tries to read the client certificate from "" and every request fails:

Could not communicate to OpenSearch ... No such file or directory @ rb_sysopen -  (Errno::ENOENT)

This was reported in #1419 and fluent/fluent-plugin-opensearch#99, where the workaround was to override fluent.conf and remove these lines.

This uses use_default, the same as #1698 did for kafka/kinesis, so an unset env var keeps the plugin default. A set env var works as before. Template and the v1.20 debian-opensearch fluent.conf (amd64 and arm64) are regenerated with erb; only these 6 lines change.

Test

Configured out_opensearch (fluent-plugin-opensearch 1.1.8, excon 1.10.0, Fluentd 1.20.1, same as the image Gemfile.lock) with the <match> block of the generated debian-opensearch fluent.conf, pointed at a local TLS server answering GET / like OpenSearch, and called client.info:

env before after
SCHEME=https, SSL_VERIFY=false Errno::ENOENT ok
+ USER/PASSWORD Errno::ENOENT ok, Basic auth header sent
SCHEME=https, CA_PATH set, verify on Errno::ENOENT ok
SCHEME=https, verify on, no CA, self-signed server Errno::ENOENT certificate verify failed (expected)
+ CLIENT_CERT/CLIENT_KEY set ok ok

ca_file, user, password, client_cert, client_key and client_key_pass
had no fallback, so an unset env var gave the plugin "" instead of nil.
With scheme https, excon then tries to read the client certificate
from "" and every request fails with Errno::ENOENT. Use use_default,
like the other settings, so the plugin defaults apply.

Signed-off-by: Lucas Barros <lucasbarros.kam@gmail.com>
@lbarrosby

Copy link
Copy Markdown
Contributor Author

Hi, friendly ping on this one. Happy to adjust anything if needed. The same goes for #1703, also from me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant