語言

CertificateRequest.CreateSelfSigned(DateTimeOffset, DateTimeOffset) 方法

定義

使用已建立的主體、金鑰及可選擴充功能,建立自簽憑證。

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

參數

notBefore
DateTimeOffset

此證明被視為有效的最早日期與時間。 通常, UtcNow正負幾秒鐘。

notAfter
DateTimeOffset

該證明不再被視為有效的日期與時間。

傳回

一個 X509Certificate2 具有指定值的物件。 返回的物件將斷言 HasPrivateKey。

例外狀況

notAfter 代表發生在 notBefore之前的日期和時間。

目前的物件是用一個不接受簽名金鑰的建構函式建立的。

憑證建立過程中發生錯誤。

HashAlgorithm房產價值沒有被支持。

備註

此方法不支援使用 MD5 或 SHA-1 作為憑證簽章的雜湊演算法。 如果你需要基於 MD5 或 SHA-1 的憑證簽章,你需要實作自訂 X509SignatureGenerator 並呼叫 Create(X500DistinguishedName, X509SignatureGenerator, DateTimeOffset, DateTimeOffset, Byte[])。

適用於