fix(net-tcp-server): give the generated TLS cert a relative expiry - #4091
Open
Github-Samuel wants to merge 1 commit into
Open
fix(net-tcp-server): give the generated TLS cert a relative expiry#4091Github-Samuel wants to merge 1 commit into
Github-Samuel wants to merge 1 commit into
Conversation
The self-signed certificate the server generates when no certificate is present had its notAfter pinned to the literal 20260101000000Z. That date has passed, so every certificate generated from now on is already expired the moment it is written out. Pass the lifetime to X509_Cert_Options instead, which takes it as an offset from the current clock, so the certificate is valid from when it is actually generated. Signed-off-by: Samuel Nicol <99494967+Github-Samuel@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Goal of this PR
Stop the auto-generated server certificate from being expired the moment it is created.
TLSServergenerates a self-signed certificate when there is no certificate on disk, and pins its notAfter to a fixed date:That date is in the past now, so a certificate generated today is written out already expired.
How is this PR achieving the goal
X509_Cert_Optionsalready takes a lifetime relative to the current clock, described inx509self.has "the expiration time (from the current clock in seconds)":so the fixed date can just be handed to the constructor as a duration and the
not_aftercall dropped:Ten years keeps the same "generate it once and forget about it" behaviour the fixed date was going for. Dropping the
not_aftercall on its own would also work and would leave the constructor default of one year, but since nothing regenerates the certificate later that would just move the problem a year out.What this does not change
Two things worth being clear about, since this looks more alarming than it is:
CURLOPT_SSL_VERIFYPEER/VERIFYHOSTto 0, so nothing on the client side was checking this certificate's validity in the first place, and joins were not failing because of it. This is about the certificate being well-formed, not about it being trusted.server-tls.crton disk keeps loading it, expired or not, because the load path takes the file whenever it exists. I deliberately did not add "regenerate when expired" here, since the same two paths are what an operator would use to supply their own certificate and silently overwriting that seemed worse than leaving it alone. Happy to add it if you would rather, it just felt like a separate decision.This PR applies to the following area(s)
FXServer
Successfully tested on
Game builds: n/a, server-side only
Platforms: Windows, Linux
Checklist
I could not do a full server build locally so I left the first box unchecked. I did check the call against the real
X509_Cert_Optionssignature from the vendored Botan header, and that10 * 365 * 24 * 60 * 60is 315360000, well inside bothintanduint32_t.