Επεξεργασία

Κοινή χρήση μέσω


CertificateRequest.CreateSelfSigned(DateTimeOffset, DateTimeOffset) Method

Definition

Creates a self-signed certificate using the established subject, key, and optional extensions.

public:
 System::Security::Cryptography::X509Certificates::X509Certificate2 ^ CreateSelfSigned(DateTimeOffset notBefore, DateTimeOffset notAfter);
public System.Security.Cryptography.X509Certificates.X509Certificate2 CreateSelfSigned (DateTimeOffset notBefore, DateTimeOffset notAfter);
member this.CreateSelfSigned : DateTimeOffset * DateTimeOffset -> System.Security.Cryptography.X509Certificates.X509Certificate2
Public Function CreateSelfSigned (notBefore As DateTimeOffset, notAfter As DateTimeOffset) As X509Certificate2

Parameters

notBefore
DateTimeOffset

The oldest date and time when this certificate is considered valid. Typically UtcNow, plus or minus a few seconds.

notAfter
DateTimeOffset

The date and time when this certificate is no longer considered valid.

Returns

An X509Certificate2 object with the specified values. The returned object will assert HasPrivateKey.

Exceptions

notAfter represents a date and time that happens earlier than notBefore.

The current object was created using a constructor that doesn't accept a signing key.

An error occurs during the certificate creation process.

The HashAlgorithm property value is not supported.

Remarks

This method does not support using MD5 or SHA-1 as the hash algorithm for the certificate signature. If you need an MD5 or SHA-1 based certificate signature, you need to implement a custom X509SignatureGenerator and call Create(X500DistinguishedName, X509SignatureGenerator, DateTimeOffset, DateTimeOffset, Byte[]).

Applies to