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

◆ Create() [4/4]

X509Certificate2 System.Security.Cryptography.X509Certificates.CertificateRequest.Create ( X509Certificate2 issuerCertificate,
DateTimeOffset notBefore,
DateTimeOffset notAfter,
ReadOnlySpan< byte > serialNumber )
inline

Definition at line 198 of file CertificateRequest.cs.

199 {
200 if (issuerCertificate == null)
201 {
202 throw new ArgumentNullException("issuerCertificate");
203 }
204 if (!issuerCertificate.HasPrivateKey)
205 {
207 }
208 if (notAfter < notBefore)
209 {
211 }
212 if (serialNumber.IsEmpty)
213 {
214 throw new ArgumentException(System.SR.Arg_EmptyOrNullArray, "serialNumber");
215 }
216 if (issuerCertificate.PublicKey.Oid.Value != PublicKey.Oid.Value)
217 {
219 }
220 DateTime localDateTime = notBefore.LocalDateTime;
221 if (localDateTime < issuerCertificate.NotBefore)
222 {
224 }
225 DateTime localDateTime2 = notAfter.LocalDateTime;
226 long ticks = localDateTime2.Ticks;
227 long num = ticks % 10000000;
228 ticks -= num;
229 localDateTime2 = new DateTime(ticks, localDateTime2.Kind);
230 if (localDateTime2 > issuerCertificate.NotAfter)
231 {
233 }
234 X509BasicConstraintsExtension x509BasicConstraintsExtension = (X509BasicConstraintsExtension)issuerCertificate.Extensions["2.5.29.19"];
235 X509KeyUsageExtension x509KeyUsageExtension = (X509KeyUsageExtension)issuerCertificate.Extensions["2.5.29.15"];
237 {
239 }
240 if (!x509BasicConstraintsExtension.CertificateAuthority)
241 {
243 }
244 if (x509KeyUsageExtension != null && (x509KeyUsageExtension.KeyUsages & X509KeyUsageFlags.KeyCertSign) == 0)
245 {
247 }
248 AsymmetricAlgorithm asymmetricAlgorithm = null;
249 string keyAlgorithm = issuerCertificate.GetKeyAlgorithm();
250 try
251 {
252 X509SignatureGenerator generator;
253 if (!(keyAlgorithm == "1.2.840.113549.1.1.1"))
254 {
255 if (!(keyAlgorithm == "1.2.840.10045.2.1"))
256 {
258 }
259 ECDsa eCDsaPrivateKey = issuerCertificate.GetECDsaPrivateKey();
261 generator = X509SignatureGenerator.CreateForECDsa(eCDsaPrivateKey);
262 }
263 else
264 {
265 if (_rsaPadding == null)
266 {
268 }
269 RSA rSAPrivateKey = issuerCertificate.GetRSAPrivateKey();
271 generator = X509SignatureGenerator.CreateForRSA(rSAPrivateKey, _rsaPadding);
272 }
274 }
275 finally
276 {
277 asymmetricAlgorithm?.Dispose();
278 }
279 }
static string Cryptography_CertReq_BasicConstraintsRequired
Definition SR.cs:44
static string Cryptography_CertReq_NotBeforeNotNested
Definition SR.cs:58
static string Format(string resourceFormat, object p1)
Definition SR.cs:118
static string Cryptography_CertReq_AlgorithmMustMatch
Definition SR.cs:42
static string Cryptography_CertReq_IssuerBasicConstraintsInvalid
Definition SR.cs:50
static string Cryptography_CertReq_IssuerKeyUsageInvalid
Definition SR.cs:52
static string Cryptography_UnknownKeyAlgorithm
Definition SR.cs:90
static string Cryptography_CertReq_RSAPaddingRequired
Definition SR.cs:62
static string Cryptography_CertReq_DatesReversed
Definition SR.cs:46
static string Cryptography_CertReq_NotAfterNotNested
Definition SR.cs:56
static string Cryptography_CertReq_IssuerRequiresPrivateKey
Definition SR.cs:54
static string Arg_EmptyOrNullArray
Definition SR.cs:14
Definition SR.cs:7
X509Certificate2 Create(X509Certificate2 issuerCertificate, DateTimeOffset notBefore, DateTimeOffset notAfter, byte[] serialNumber)

References System.Security.Cryptography.X509Certificates.CertificateRequest._rsaPadding, System.SR.Arg_EmptyOrNullArray, System.Security.Cryptography.X509Certificates.CertificateRequest.Create(), System.Security.Cryptography.X509Certificates.X509SignatureGenerator.CreateForECDsa(), System.Security.Cryptography.X509Certificates.X509SignatureGenerator.CreateForRSA(), System.SR.Cryptography_CertReq_AlgorithmMustMatch, System.SR.Cryptography_CertReq_BasicConstraintsRequired, System.SR.Cryptography_CertReq_DatesReversed, System.SR.Cryptography_CertReq_IssuerBasicConstraintsInvalid, System.SR.Cryptography_CertReq_IssuerKeyUsageInvalid, System.SR.Cryptography_CertReq_IssuerRequiresPrivateKey, System.SR.Cryptography_CertReq_NotAfterNotNested, System.SR.Cryptography_CertReq_NotBeforeNotNested, System.SR.Cryptography_CertReq_RSAPaddingRequired, System.SR.Cryptography_UnknownKeyAlgorithm, System.DateTime, System.SR.Format(), System.Security.Cryptography.X509Certificates.PublicKey.Oid, and System.Security.Cryptography.Oid.Value.