Add improved handling for TLS certificates for static builds. #17605
+57
−10
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.
Summary
Our current static builds include a bundled copy of the CA certificates available in the build environment, and will automatically fall back to using those if they can’t find a usable set of CA certificates on the target system.
This works in a majority of cases, but it has a couple of issues:
This PR works to remedy those issues. It adds additional logic to the installation code embedded in the static builds that handles the TLS certificates, adding support both for checking the usability of the selected certificates and for skipping the system certificates and just using the bundled ones. This functionality is controlled by two new options and associated environment variables:
--certificates
andNETDATA_CERT_MODE
allow specifying the certificate handling mode.auto
andsystem
have the current behavior.check
expands the current behavior by testing the detected system certificate store for usability by connecting to a well-known URL.bundled
ignores any system certificates and unconditionally uses the bundled certificates. Defaults toauto
if unspecified (thus preserving the existing behavior).--certificate-test-url
andNETDATA_CERT_TEST_URL
allow overriding the URL used bycheck
mode for testing whether the system certificates are usable. Defaults tohttps://app.netdata.cloud
if unspecified.The options override any value specified by the environment variables.
Additionally, the kickstart script is updated to pass the claiming URL as the certificate test URL when performing a static build, and to make the certificate handling mode default to
check
for installs other than offline installs andauto
mode for offline installs. The values passed by the kickstart script can still be overridden by using the--static-install-options
option to add the--certificates
or--certificate-test-url
options as needed.Test Plan
Testing requires manually installing static builds produced from this PR on a variety of systems with various values for the
--certificates
and--certificate-test-url
options and observing how the symlink at/opt/netdata/etc/ssl
is updated.