| | | 1 | | using Org.BouncyCastle.Asn1.X509; |
| | | 2 | | using System.Security.Cryptography.X509Certificates; |
| | | 3 | | |
| | | 4 | | namespace Kestrun.Certificates; |
| | | 5 | | |
| | | 6 | | /// <summary> |
| | | 7 | | /// Options for creating a self-signed certificate. |
| | | 8 | | /// </summary> |
| | | 9 | | /// <param name="DnsNames">The DNS names to include in the certificate's Subject Alternative Name (SAN) extension. When |
| | | 10 | | /// <param name="KeyType">The type of cryptographic key to use (RSA or ECDSA).</param> |
| | | 11 | | /// <param name="KeyLength">The length of the cryptographic key in bits.</param> |
| | | 12 | | /// <param name="Purposes">The key purposes (Extended Key Usage) for the certificate.</param> |
| | | 13 | | /// <param name="KeyUsageFlags">The X.509 Key Usage flags to apply to the certificate. Null or <see cref="X509KeyUsageFl |
| | | 14 | | /// <param name="ValidDays">The number of days the certificate will be valid.</param> |
| | | 15 | | /// <param name="Ephemeral">If true, the certificate will not be stored in the Windows certificate store.</param> |
| | | 16 | | /// <param name="Exportable">If true, the private key can be exported from the certificate.</param> |
| | | 17 | | /// <param name="IsCertificateAuthority">If true, emits a CA certificate suitable for issuing child certificates.</param |
| | | 18 | | /// <param name="IssuerCertificate">Optional issuer certificate used to sign the generated certificate. The issuer must |
| | | 19 | | /// <param name="Development">If true, creates a development bundle consisting of a CA root certificate and an issued le |
| | | 20 | | /// <param name="RootCertificate">Optional development root certificate used to sign the generated development leaf cert |
| | | 21 | | /// <param name="RootName">The common name to use when creating a new development root certificate.</param> |
| | | 22 | | /// <param name="LeafValidDays">The number of days the generated development leaf certificate is valid.</param> |
| | | 23 | | /// <param name="RootValidDays">The number of days a generated development root certificate is valid.</param> |
| | | 24 | | /// <param name="TrustRoot">When true on Windows, adds the effective development root certificate to the CurrentUser Roo |
| | | 25 | | /// <remarks> |
| | | 26 | | /// This record is used to specify options for creating a self-signed certificate. |
| | | 27 | | /// </remarks> |
| | 31 | 28 | | public record SelfSignedOptions( |
| | 31 | 29 | | IEnumerable<string>? DnsNames, |
| | 54 | 30 | | KeyType KeyType = KeyType.Rsa, |
| | 33 | 31 | | int KeyLength = 2048, |
| | 30 | 32 | | IEnumerable<KeyPurposeID>? Purposes = null, |
| | 30 | 33 | | X509KeyUsageFlags? KeyUsageFlags = null, |
| | 28 | 34 | | int ValidDays = 365, |
| | 32 | 35 | | bool Ephemeral = false, |
| | 32 | 36 | | bool Exportable = false, |
| | 107 | 37 | | bool IsCertificateAuthority = false, |
| | 28 | 38 | | X509Certificate2? IssuerCertificate = null, |
| | 26 | 39 | | bool Development = false, |
| | 3 | 40 | | X509Certificate2? RootCertificate = null, |
| | 2 | 41 | | string RootName = "Kestrun Development Root CA", |
| | 6 | 42 | | int LeafValidDays = 30, |
| | 5 | 43 | | int RootValidDays = 3650, |
| | 3 | 44 | | bool TrustRoot = false |
| | 31 | 45 | | ); |