X509Certificate.GetEffectiveDateString 方法

定义

返回此 X.509v3 证书的有效日期。

public:
 virtual System::String ^ GetEffectiveDateString();
public virtual string GetEffectiveDateString ();
abstract member GetEffectiveDateString : unit -> string
override this.GetEffectiveDateString : unit -> string
Public Overridable Function GetEffectiveDateString () As String

返回

此 X.509 证书的有效日期。

示例

以下示例使用 GetEffectiveDateString 方法获取证书的生效日期并将其显示在控制台中。

using namespace System;
using namespace System::Security::Cryptography::X509Certificates;
int main()
{
   
   // The path to the certificate.
   String^ Certificate = "Certificate.cer";
   
   // Load the certificate into an X509Certificate object.
   X509Certificate^ cert = X509Certificate::CreateFromCertFile( Certificate );
   
   // Get the value.
   String^ results = cert->GetEffectiveDateString();
   
   // Display the value to the console.
   Console::WriteLine( results );
}

using System;
using System.Security.Cryptography.X509Certificates;

public class X509
{

    public static void Main()
    {

        // The path to the certificate.
        string Certificate =  "Certificate.cer";

        // Load the certificate into an X509Certificate object.
        X509Certificate cert = X509Certificate.CreateFromCertFile(Certificate);

        // Get the value.
        string results = cert.GetEffectiveDateString();

        // Display the value to the console.
        Console.WriteLine(results);
    }
}
Imports System.Security.Cryptography.X509Certificates




Public Class X509
   
   
   Public Shared Sub Main()
      
      ' The path to the certificate.
      Dim Certificate As String = "Certificate.cer"
      
      ' Load the certificate into an X509Certificate object.
      Dim cert As X509Certificate = X509Certificate.CreateFromCertFile(Certificate)
      
      ' Get the value.
      Dim results As String = cert.GetEffectiveDateString()
      
      ' Display the value to the console.
      Console.WriteLine(results)
   End Sub
End Class

注解

生效日期是 X.509 证书被视为有效的日期。

方法 GetEffectiveDateString 返回一个字符串,该字符串显示采用短日期模式格式的日期,后跟在长时间模式中设置格式的时间。 日期和时间使用当前区域性和时区进行格式化。

适用于