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

傳回

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 傳回字串,其中顯示以簡短日期模式格式化的日期,後面接著以長時間模式格式化的時間。 日期和時間會使用目前的文化特性和時區來格式化。

適用於