Visual Basic (Usage) | ![]() |
---|---|
Dim storeType As String Dim storePath As String Dim password As String Dim applicationUri As String Dim applicationName As String Dim subjectName As String Dim domainNames As IList(Of String) Dim keySize As UShort Dim startTime As Date Dim lifetimeInMonths As UShort Dim hashSizeInBits As UShort Dim isCA As Boolean Dim usePEMFormat As Boolean Dim issuerKeyFilePath As String Dim issuerKeyFilePassword As String Dim algorithm As UShort Dim value As X509Certificate2 value = CertificateFactory.CreateCertificate(storeType, storePath, password, applicationUri, applicationName, subjectName, domainNames, keySize, startTime, lifetimeInMonths, hashSizeInBits, isCA, usePEMFormat, issuerKeyFilePath, issuerKeyFilePassword, algorithm) |
C# | |
---|---|
public static X509Certificate2 CreateCertificate( string storeType, string storePath, string password, string applicationUri, string applicationName, string subjectName, IList<string> domainNames, ushort keySize, DateTime startTime, ushort lifetimeInMonths, ushort hashSizeInBits, bool isCA, bool usePEMFormat, string issuerKeyFilePath, string issuerKeyFilePassword, ushort algorithm ) |
Parameters
- storeType
- Type of certificate store (Windows or Directory) CertificateStoreType.
- storePath
- The store path (syntax depends on storeType).
- password
- The password to use to protect the certificate.
- applicationUri
- The application uri (created if not specified).
- applicationName
- Name of the application (optional if subjectName is specified).
- subjectName
- The subject used to create the certificate (optional if applicationName is specified).
- domainNames
- The domain names that can be used to access the server machine (defaults to local computer name if not specified).
- keySize
- Size of the key (1024, 2048 or 4096).
- startTime
- The start time.
- lifetimeInMonths
- The lifetime of the key in months.
- hashSizeInBits
- The hash size in bits.
- isCA
- if set to
true
the a CA certificate is created. - usePEMFormat
- if set to
true
the private ket is store in the PEM format. - issuerKeyFilePath
- The path to the PFX file containing the CA private key.
- issuerKeyFilePassword
- The password for the PFX file containing the CA private key.
- algorithm
- Signature algorithm (0 = SHA1; 1 = SHA256) This settings applies only to Windows storeType option.
Return Value
The certificate with a private key.Target Platforms: Windows 7/8/10, Windows Server 2003/2008/2012/2015, .NET4.x