Use the provided CA cert when verifying the license server - #82
Merged
Merged
Conversation
NewClient never assigned the caCert argument to the Client struct, so the guard around the cert pool read an always-empty field and RootCAs was left nil. A custom transport was still installed, so clients passing a custom CA silently fell back to the system roots and failed with "certificate signed by unknown authority" against a privately-signed license server. Assign the field and fail fast when the PEM contains no usable certificate, instead of dropping it silently. Signed-off-by: Arnob Kumar Saha <arnob@appscode.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Problem
NewClientaccepts acaCert []bytebut never assigns it to theClientstruct. The cert-pool guard then reads the always-emptyc.caCertfield, sotlsConfig.RootCAsis never set:The outer condition still swaps in a custom transport, so a caller that passes a CA gets a client with
RootCAs == nil— silently falling back to the system root pool. Against a privately-signed license server every request fails withx509: certificate signed by unknown authority.--insecure-skip-tls-verifywas the only working path.Present since #35 (Sep 2024), so
--ca-filehas been a no-op in every release that shipped it, including the currentv0.15.0.Real-world impact:
license-proxyserver(v0.1.1 and v0.1.2, both pinned to license-verifier v0.15.0) is started with a correct--ca-filemounted fromlicense-proxyserver-platform-auth, and still cannot reach a self-hosted ACE platform. KubeDB operators surface this aslicense status unknown, reason: failed to read license from proxyand crashloop.Fix
Assign
caCertto the struct, read the field consistently, and return an error when the PEM yields no usable certificate rather than dropping it silently — the silent drop is what hid this for over a year.Verification
Against a self-hosted ACE platform (
https://10.2.1.82, cert issued by a privateO=ace, CN=ca), callingAcquireLicensewith that CA and a dummy token:Post "https://10.2.1.82/api/v1/license/issue": tls: failed to verify certificate: x509: "ace-nats" certificate is not trustedthe server has asked for the client to provide credentials— TLS verifies, only the dummy token is rejectedcurl --cacertwith the same CA from inside the cluster also returns 401, confirming the CA was always sufficient.Notes for reviewers
Behavior change: a caller passing a malformed/non-PEM
caCertnow gets an error fromNewClientinstead of a client that fails later at request time.