Improve trusted_ca_fingerprint warnings and fix tests #285
+75
−12
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What does this PR do?
This PR updates the warnings that are printed in various edge cases using
ca_trusted_fingerprint
. I also add tests that assert the right warnings are printed in each edge case.There were issues with the existing tests as well that I resolved.
unknown_authority
but incorrectly marks the certificate as not being a CA certificate.With this PR, the warning printed if the user provides the wrong fingerprint would be:
The provided 'ca_trusted_fingerprint': 'blah' does not match the fingerprint of any Certificate Authority present in the server's certificate chain. Found the following CA fingerprints instead: [8e700dc7381856dd16665b9d08286057e743bdb8fdb3dd9bb68ea19887481a48]
And when the Elasticsearch Server is missing its certificate chain it would print:
The remote server's certificate is presented without its certificate chain. Using 'ca_trusted_fingerprint' requires that the server presents a certificate chain that includes the certificates issuing certificate authority.
Today, in both of these cases it just prints:
no CA certificate matching the fingerprint
Why is it important?
Users frequently try to use
ca_trusted_fingerprint
without realizing how significantly different the behavior of it is from providing a normal certificate.This value is often provided via Fleet and when it doesn't work it is very hard to understand what to do next.
Checklist
Related issues
elastic/beats#42970