X509Certificate.GetExpirationDateString Método

Definição

Retorna a data de validade deste certificado X.509v3.Returns the expiration date of this X.509v3 certificate.

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

Retornos

A data de validade deste certificado X.509.The expiration date for this X.509 certificate.

Exemplos

O exemplo a seguir usa o método GetExpirationDateString para obter a data de validade de um certificado e o exibe para o console.The following example uses the GetExpirationDateString method to get the expiration date of a certificate and displays it to the console.

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->GetExpirationDateString();
   
   // 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.GetExpirationDateString();
       
        // 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.GetExpirationDateString()
      
      ' Display the value to the console.
      Console.WriteLine(results)
   End Sub  
End Class 

Comentários

A data de validade é a data após a qual o certificado X. 509 não é mais considerado válido.The expiration date is the date after which the X.509 certificate is no longer considered valid.

O método GetExpirationDateString retorna uma cadeia de caracteres que mostra a data formatada em um padrão de data abreviada seguido pelo horário formatado no padrão de hora completa.The GetExpirationDateString method returns a string that shows the date formatted in Short Date Pattern followed by the time formatted in Long Time Pattern. A data e hora são formatadas usando a cultura atual e o fuso horário.The date and time are formatted using the current culture and time zone.

Observação

Esse método pode retornar um formato de cadeia de caracteres diferente em computadores Macintosh, embora o objeto de DateTime subjacente represente o mesmo valor.This method may return a different string format on Macintosh computers, although the underlying DateTime object will represent the same value.

Aplica-se a