Skip to content

Conversation

@Westwooo
Copy link
Contributor

No description provided.

routingconn.go Outdated

if opts.RootCAs != nil || opts.InsecureSkipVerify {
creds := credentials.NewTLS(&tls.Config{InsecureSkipVerify: opts.InsecureSkipVerify, RootCAs: opts.RootCAs})
var certificates []tls.Certificate
Copy link
Collaborator

Choose a reason for hiding this comment

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

Does cert auth actually require TLS enabled? This seems like it should be below where the username and password check is. Should probably also error if certificate and username/password are both set. We're still at 0.x version so we could actually introduce an Authenticator type and remove username/password and certificate - which prevents both from being set.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Does cert auth actually require TLS enabled?
Yes because it's during the TLS handshake that the client and server exchange the certs.

Should probably also error if certificate and username/password are both set
When connecting to the cluster it's impossible to define a passwordAuthenticator and a certificateAuthenticator so unless there will be other users of gocbcoreps isn't another check for this redundant?

Copy link
Collaborator

Choose a reason for hiding this comment

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

When connecting to the cluster it's impossible to define a passwordAuthenticator and a certificateAuthenticator so unless there will be other users of gocbcoreps isn't another check for this redundant?

It's entirely possible that there will be in the future.

Copy link
Collaborator

Choose a reason for hiding this comment

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

At the moment if the user specifies a Certificate and no TLS options then they're possibly going to get some weird errors because we just won't set any authentication at all. That should probably also be an error case. We might also want to think about adding a invalid args error type so that callers can detect that.

I also wonder if we should simplify this by just not accepting Certificate, RootCAs and InsecureSkipVerify. Instead just accepting a tls.Config.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point, I've changed it so that the cert is always added to the TLS creds, so that a client cert being passed with no TLS options will work if the user has added their CA cert to their system pool.

@Westwooo Westwooo force-pushed the ING-662-client-cert-auth branch from 7325003 to 2717a06 Compare October 13, 2025 08:32
@Westwooo Westwooo requested a review from chvck October 13, 2025 10:00
@Westwooo Westwooo force-pushed the ING-662-client-cert-auth branch from 2717a06 to 03e4482 Compare October 13, 2025 11:35
ING-662: Simplify building of TLS credentials
@Westwooo Westwooo force-pushed the ING-662-client-cert-auth branch from 03e4482 to 36e1378 Compare October 13, 2025 13:12
@Westwooo Westwooo merged commit 8f7ff2e into master Oct 13, 2025
4 checks passed
@Westwooo Westwooo deleted the ING-662-client-cert-auth branch October 13, 2025 13:14
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.

3 participants