Cherry-pick #16019 to 7.x: [Agent] Allow CA cert pinning on the Elasticsearch output or any code that user tlscommon.TLSConfig builder. #16675
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.
Cherry-pick of PR #16019 to 7.x branch. Original message:
What does this PR do?
When multiples CA are presents on the system we cannot ensure that a
specific one was used to validate the chain exposed by the server.
This PRs adds a
ca_sha256
option to thetlscommon.TLSConfig
that is used by allthe code that has to create a TCP client with TLS support.
When the option is set, it will hook a new callback in the validation
chains that will inspect the verified and validated chains by Go to
ensure that a certificate in the chains matches the provided pin.
A usage example for the Elasticsearch output.
You can generate the pin using the openssl binary with the
following command:
OpenSSL's documentation
You will need to start Elasticsearch with the following options
This pull request also includes a new service in the docker-compose.yml
that will start a new Elasticsearch server with TLS and security
configured.
Checklist
Author's Checklist
How to test this PR locally
There are multiple ways to tests this, you can use the elasticsearch_ssl service defined in the docker-compose file that will start a configured Elasticsearch with TLS and the right CA/Certificate configured.
Or you can generate a CA and a server certificate using the elasticsearch-certutil, make sure to export them in the PEM format.
In both case you can use the following openssl command to generate the pin from the CA.
And use the following output configuration:
Related issues