Skip to content

feat(tls): server certificate SAN can have a trailing dot - #1405

Open
levkk wants to merge 1 commit into
mainfrom
levkk-trailing-dot-san
Open

feat(tls): server certificate SAN can have a trailing dot#1405
levkk wants to merge 1 commit into
mainfrom
levkk-trailing-dot-san

Conversation

@levkk

@levkk levkk commented Aug 20, 2026

Copy link
Copy Markdown
Collaborator

No description provided.

@codecov

codecov Bot commented Aug 20, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 2.40964% with 81 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
pgdog/src/net/tls.rs 0.00% 80 Missing ⚠️
pgdog/src/backend/server.rs 66.66% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

Comment thread pgdog/src/net/tls.rs
webpki_verifier: Arc<dyn ServerCertVerifier>,
}

impl TrailingDotVerifier {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I'm not familiar with the rustls API but this seems like a lot of code for a trailing dot. (And it wouldn't surprise me at all that the TLS library API actually makes it this hard)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Yeah... I'm not sure if this is how this is supposed to be done. I'm waiting for a review from Ryan.

@rlittlefield

Copy link
Copy Markdown
Contributor

It looks like curl strips trailing dots automatically, but the default in go crypto/x509, python's ssl, and rustls-webpki all mismatch this, apparently by design. From what I can tell, its probably a malformed cert from google.

Here is the python GCP cloud sql issue:
GoogleCloudPlatform/cloud-sql-python-connector#1087

It looks like the GCP Go connector does the same thing this PR does, so that's a good sign: https://github.com/GoogleCloudPlatform/cloud-sql-go-connector/blob/main/internal/cloudsql/tls_verify.go#L112-L118

I guess I could see not wanting to fall back to custom code for strict verification, so if that's a concern I suppose it could be a configuration option to strip the dot?

Comment thread pgdog/src/net/tls.rs
if matches!(
&result,
Err(rustls::Error::InvalidCertificate(
rustls::CertificateError::NotValidForNameContext { .. }

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Would this make sense as

Err(rustls::Error::InvalidCertificate(
    rustls::CertificateError::NotValidForName
    | rustls::CertificateError::NotValidForNameContext { .. },
))

It sounds like rustls considers it okay to change enum variants, so this might help avoid a silent behavior change if I'm reading this right.

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