Skip to content

Add support for client certificates in amtool#2391

Closed
Hsn723 wants to merge 3 commits intoprometheus:mainfrom
Hsn723:master
Closed

Add support for client certificates in amtool#2391
Hsn723 wants to merge 3 commits intoprometheus:mainfrom
Hsn723:master

Conversation

@Hsn723
Copy link

@Hsn723 Hsn723 commented Oct 11, 2020

I'd like to propose the ability to provide a client certificate in amtool to support use cases where an instance of alertmanager is behind and Ingress that expects a client certificate.

Signed-off-by: Hsn723 <me@atelierhsn.com>
cli/root.go Outdated
if caFile != "" {
tc.CAFile = caFile
}
tlsConfig, err := commoncfg.NewTLSConfig(&tc)
Copy link
Member

Choose a reason for hiding this comment

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

I would call commoncfg.NewRoundTripperFromConfig() instead and pass the returned value to cr.Transport.

cli/root.go Outdated
cr.DefaultAuthentication = clientruntime.BasicAuth(amURL.User.Username(), password)
}

if certFile != "" && keyFile != "" {
Copy link
Member

Choose a reason for hiding this comment

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

It should be ok to always create and pass a custom Transport, even if TLS flags are empty.

app.Flag("tls_config.ca_file", "Path to CA file").ExistingFileVar(&caFile)
app.Flag("tls_config.cert_file", "Path to client certificate").ExistingFileVar(&certFile)
app.Flag("tls_config.key_file", "Path to client certificate key").ExistingFileVar(&keyFile)
app.Flag("tls_config.server_name", "Server name for TLS config").StringVar(&serverName)
Copy link
Member

Choose a reason for hiding this comment

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

I would add tls_config.insecure_skip_verify too.

Signed-off-by: Hsn723 <me@atelierhsn.com>
Signed-off-by: Hsn723 <me@atelierhsn.com>
@Hsn723
Copy link
Author

Hsn723 commented Nov 7, 2020

@simonpasquier
Thank you for the feedback. I have implemented your suggestions.

It also seems I'm failing some CI tests unrelated to amtool. Should I rebase?

@roidelapluie
Copy link
Member

I suggested that we base the effort on Prometheus' protool and maybe provide a config file so we can support basic auth passwords too.

@roidelapluie
Copy link
Member

cc @brian-brazil

@roidelapluie
Copy link
Member

In both ways, file or not, we should add the necessary helpers in common to support this use case

@stale stale bot added the stale label Jan 7, 2021
@TheMeier
Copy link
Contributor

TheMeier commented Nov 3, 2025

Sounds like it could be useful. Maybe it is time to revive that PR

@TheMeier
Copy link
Contributor

TheMeier commented Nov 3, 2025

Hm although there is
http.config.file
HTTP client configuration file for amtool to connect to Alertmanager.
The format is https://prometheus.io/docs/alerting/latest/configuration/#http_config.

which allows to configure TLS, so is that actually needed?

@TheMeier
Copy link
Contributor

TheMeier commented Nov 3, 2025

I guess this is obsoleted by #2764

@SoloJacobs
Copy link
Contributor

Hi @Hsn723 ,

it looks like this PR is out of date and has some overlap with other changes, that have been merged in the mean time. So, I'll close this. We appreciate the time you put into this. If feel like opening an up-to-date PR, that I'll make sure to review it in a timely manor.

Kind regards, Solomon Jacobs

@SoloJacobs SoloJacobs closed this Nov 14, 2025
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.

5 participants