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

Set HTTP hostname based on TLS server name #350

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

fpetkovski
Copy link

The net/http library uses the Host field from the Request object in
order to determine the value of the Host header [1]. In order for the
Prometheus client to support SNI, it needs to set this field to the
value provided in the TLS server name.

[1] golang/go#29865

Signed-off-by: fpetkovski filip.petkovsky@gmail.com

Fixes prometheus/prometheus#9403

@roidelapluie
Copy link
Member

Hello,

Thank you for your contribution.
I am surprised that SNI does not work out of the box.

I am not willing to have this repository depend on client_golang. We have an exception for an interface in version, and the tests in sigv4, but that's it.

The net/http library uses the Host field from the Request object in
order to determine the value of the Host header [1]. In order for the
Prometheus client to support SNI, it needs to set this field to the
value provided in the TLS server name.

[1] golang/go#29865

Signed-off-by: fpetkovski <filip.petkovsky@gmail.com>
@fpetkovski
Copy link
Author

Thanks for the feedback. Could you point me to where the dependency to client_golang is introduced in this PR? Do you mean because we are referencing the TLS config?

Copy link
Member

@bwplotka bwplotka left a comment

Choose a reason for hiding this comment

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

Hm, I don't see any client_golang dep @roidelapluie 🤔

Looks good to me, but let's wait for @roidelapluie voice, maybe I am missing something.

CertFile: ClientCertificatePath,
KeyFile: ClientKeyNoPassPath,
ServerName: "test-domain.com",
InsecureSkipVerify: true},
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
InsecureSkipVerify: true},
InsecureSkipVerify: true,
},

@roidelapluie
Copy link
Member

The initial commit introduced a dependency. Then it was force pushed.

I can not merge this as is, I need to check that 1. SNI works even with our connection pooling and 2. This does not break blackbox exporter, which has similar logic.

@fpetkovski
Copy link
Author

@roidelapluie
Copy link
Member

after thinking twice, the TLS servername should come from the header, not the other way around.

@fpetkovski
Copy link
Author

What do you mean by this? Isn't the TLS server name a user provided config?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Scrape fail when target cert contains multiple 'Subject Alternative Name'
3 participants