@@ -231,9 +231,9 @@ public static X509Certificate2 CreateSelfSignedCACertificate(string subjectName)
231231 caRequest . CertificateExtensions . Add (
232232 new X509SubjectKeyIdentifierExtension ( caRequest . PublicKey , false ) ) ;
233233
234- // Create the self-signed certificate. Validity is set from yesterday to 10 years in the future.
235- var rootCert = caRequest . CreateSelfSigned ( DateTimeOffset . UtcNow . AddDays ( - 1 ) ,
236- DateTimeOffset . UtcNow . AddYears ( 10 ) ) ;
234+ // Create the self-signed certificate. Validity is set from now to 100 years in the future.
235+ var rootCert = caRequest . CreateSelfSigned ( DateTimeOffset . UtcNow ,
236+ DateTimeOffset . UtcNow . AddYears ( 100 ) ) ;
237237
238238 // Export and re-import to mark the key as exportable (if needed for further signing).
239239#if NET9_0_OR_GREATER
@@ -289,9 +289,9 @@ public static X509Certificate2 IssueCertificate(string subjectName, X509Certific
289289 throw new InvalidOperationException ( "The provided CA certificate does not contain a private key." ) ;
290290 }
291291
292- // Create the certificate valid from yesterday until 2 years in the future.
293- var issuedCert = req . Create ( caCert , DateTimeOffset . UtcNow . AddDays ( - 1 ) ,
294- DateTimeOffset . UtcNow . AddYears ( 2 ) , serialNumber ) ;
292+ // Create the certificate valid from now until 20 years in the future.
293+ var issuedCert = req . Create ( caCert , DateTimeOffset . UtcNow ,
294+ DateTimeOffset . UtcNow . AddYears ( 20 ) , serialNumber ) ;
295295
296296 return issuedCert . CopyWithPrivateKey ( rsa ) ;
297297 }
0 commit comments