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 發生的日期和時間。

目前的物件是使用不接受簽署金鑰的建構函式所建立。

憑證建立程序期間發生錯誤。

備註

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

適用於