Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ CreateSelfSigned()

X509Certificate2 System.Security.Cryptography.X509Certificates.CertificateRequest.CreateSelfSigned ( DateTimeOffset notBefore,
DateTimeOffset notAfter )
inline

Definition at line 167 of file CertificateRequest.cs.

168 {
169 if (notAfter < notBefore)
170 {
172 }
173 if (_key == null)
174 {
176 }
177 Span<byte> span = stackalloc byte[8];
178 RandomNumberGenerator.Fill(span);
179 using (X509Certificate2 certificate = Create(SubjectName, _generator, notBefore, notAfter, span))
180 {
181 if (_key is RSA privateKey)
182 {
183 return certificate.CopyWithPrivateKey(privateKey);
184 }
185 if (_key is ECDsa privateKey2)
186 {
187 return certificate.CopyWithPrivateKey(privateKey2);
188 }
189 }
190 throw new CryptographicException();
191 }
static string Cryptography_CertReq_NoKeyProvided
Definition SR.cs:60
static string Cryptography_CertReq_DatesReversed
Definition SR.cs:46
Definition SR.cs:7
X509Certificate2 Create(X509Certificate2 issuerCertificate, DateTimeOffset notBefore, DateTimeOffset notAfter, byte[] serialNumber)

References System.Security.Cryptography.X509Certificates.CertificateRequest._generator, System.Security.Cryptography.X509Certificates.CertificateRequest._key, System.Security.Cryptography.X509Certificates.CertificateRequest.Create(), System.SR.Cryptography_CertReq_DatesReversed, System.SR.Cryptography_CertReq_NoKeyProvided, System.Security.Cryptography.RandomNumberGenerator.Fill(), and System.Security.Cryptography.X509Certificates.CertificateRequest.SubjectName.