Skip to content

feat: allow TLS connections with invalid certificate if the key is unchanged#8086

Merged
link2xt merged 1 commit intomainfrom
link2xt/custom-tls-verification
Apr 17, 2026
Merged

feat: allow TLS connections with invalid certificate if the key is unchanged#8086
link2xt merged 1 commit intomainfrom
link2xt/custom-tls-verification

Conversation

@link2xt
Copy link
Copy Markdown
Collaborator

@link2xt link2xt commented Apr 5, 2026

This change weakens TLS checks.
Every time we make a successful TLS connection,
we remember public key hash from the certificate
in relation to the hostname.
If later we connect to the same hostname and the public key does not change,
we skip checking certificate chain.
This way we will still connect successfully
even if certificate expires or becomes invalid for another reason,
but keeps the key.

We always check that certificate corresponds to the hostname.
We also do this for certificates starting with _
where we allow self-signed certificates,
so self-signed certificates with mismatching domains are not allowed.
Previously we did not check this for domains starting with _.

Closes #7996

Comment thread src/sql/migrations.rs Outdated
@link2xt link2xt force-pushed the link2xt/custom-tls-verification branch 3 times, most recently from dfce584 to 000bf71 Compare April 5, 2026 05:19
@link2xt link2xt force-pushed the link2xt/custom-tls-verification branch from 000bf71 to 900cb7f Compare April 16, 2026 16:56
@link2xt link2xt marked this pull request as ready for review April 16, 2026 19:32
@link2xt link2xt requested review from Hocuri and j-g00da April 16, 2026 19:32
Comment thread src/net/tls/danger.rs Outdated
Comment thread src/net/tls.rs
@link2xt link2xt force-pushed the link2xt/custom-tls-verification branch from 900d88c to e352efe Compare April 17, 2026 09:37
@link2xt link2xt requested a review from iequidoo April 17, 2026 09:45
@link2xt link2xt force-pushed the link2xt/custom-tls-verification branch from e352efe to a8947ec Compare April 17, 2026 09:56
Comment thread src/sql.rs Outdated
@link2xt link2xt force-pushed the link2xt/custom-tls-verification branch 2 times, most recently from f62aab7 to 3e05546 Compare April 17, 2026 12:47
@link2xt link2xt changed the title feat: custom TLS certificate verification feat: allow TLS connections with invalid certificate if the key is unchanged Apr 17, 2026
Comment thread src/net/tls/danger.rs
Comment thread src/sql/migrations.rs Outdated
Comment thread src/net/tls/spki.rs
@link2xt link2xt force-pushed the link2xt/custom-tls-verification branch from 3e05546 to 280d93d Compare April 17, 2026 15:04
Comment thread src/sql/migrations.rs Outdated
…changed

This change weakens TLS checks.
Every time we make a successful TLS connection,
we remember public key hash from the certificate
in relation to the hostname.
If later we connect to the same hostname and the public key does not change,
we skip checking certificate chain.
This way we will still connect successfully
even if certificate expires or becomes invalid for another reason,
but keeps the key.

We always check that certificate corresponds to the hostname.
We also do this for certificates starting with _
where we allow self-signed certificates,
so self-signed certificates with mismatching domains are not allowed.
Previously we did not check this for domains starting with _.
@link2xt link2xt force-pushed the link2xt/custom-tls-verification branch from 280d93d to 2a74f65 Compare April 17, 2026 16:03
@link2xt link2xt merged commit 8292495 into main Apr 17, 2026
56 of 57 checks passed
@link2xt link2xt deleted the link2xt/custom-tls-verification branch April 17, 2026 18:07
Comment thread src/net/tls/spki.rs
let now = time();
let removed_hosts = sql
.query_map_vec(
"DELETE FROM tls_spki WHERE ? > timestamp + ? RETURNING host",
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.

DELETE does not work from query_map_vec because it is executed on read connection.
I made a follow-up PR #8135

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.

Accept expired TLS certificate if the fingerprint does not change

3 participants