Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

logcli: Remove port from TLS server name when provided in --addr #5477

Merged
merged 1 commit into from
Mar 29, 2022

Conversation

atomic77
Copy link
Contributor

What this PR does / why we need it:

If connecting to a TLS secured endpoint with an explicit port with logcli, certificate validation fails:

logcli --ca-cert=$TLS_CA --cert=$TLS_CERT --key=$TLS_KEY --addr=https://<host>:<port> labels
error sending request Get "https://<host>:<port>/loki/api/v1/labels?end=1645559631967253910&start=1645556031967253910": x509: certificate is valid for <host>, <SAN>, not <host>:<port>
Error doing request: Run out of attempts while querying the server

The problem can be (insecurely) avoided by adding a --tls-skip-verify option.

This PR ensures that the ServerName field of the TLSConfig struct contains only the host if a port is provided to avoid
the failure.

Which issue(s) this PR fixes:

Per Contribution guide, didn't open an issue since this is a one-liner... but I can create one if needed.

Special notes for your reviewer:

Checklist

  • Documentation added
  • Tests updated
  • Add an entry in the CHANGELOG.md about the changes.

If connecting to a TLS secured endpoint with an explicit port,
ensure that ServerName contains only the host and not the port to avoid
a cert validation failure
@atomic77 atomic77 requested a review from a team as a code owner February 25, 2022 15:42
@CLAassistant
Copy link

CLAassistant commented Feb 25, 2022

CLA assistant check
All committers have signed the CLA.

Copy link
Contributor

@cyriltovena cyriltovena left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@cyriltovena cyriltovena merged commit 3bf2efa into grafana:main Mar 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants