X509Certificate.CreateFromCertFile(String) Methode
Definitie
Belangrijk
Bepaalde informatie heeft betrekking op een voorlopige productversie die aanzienlijk kan worden gewijzigd voordat deze wordt uitgebracht. Microsoft biedt geen enkele expliciete of impliciete garanties met betrekking tot de informatie die hier wordt verstrekt.
Let op
Loading certificate data through the constructor or Import is obsolete. Use X509CertificateLoader instead to load certificates.
Hiermee maakt u een X.509v3-certificaat op basis van het opgegeven pkCS7-ondertekende bestand.
public:
static System::Security::Cryptography::X509Certificates::X509Certificate ^ CreateFromCertFile(System::String ^ filename);
[System.Obsolete("Loading certificate data through the constructor or Import is obsolete. Use X509CertificateLoader instead to load certificates.", DiagnosticId="SYSLIB0057", UrlFormat="https://aka.ms/dotnet-warnings/{0}")]
[System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
public static System.Security.Cryptography.X509Certificates.X509Certificate CreateFromCertFile(string filename);
public static System.Security.Cryptography.X509Certificates.X509Certificate CreateFromCertFile(string filename);
[System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
public static System.Security.Cryptography.X509Certificates.X509Certificate CreateFromCertFile(string filename);
[<System.Obsolete("Loading certificate data through the constructor or Import is obsolete. Use X509CertificateLoader instead to load certificates.", DiagnosticId="SYSLIB0057", UrlFormat="https://aka.ms/dotnet-warnings/{0}")>]
[<System.Runtime.Versioning.UnsupportedOSPlatform("browser")>]
static member CreateFromCertFile : string -> System.Security.Cryptography.X509Certificates.X509Certificate
static member CreateFromCertFile : string -> System.Security.Cryptography.X509Certificates.X509Certificate
[<System.Runtime.Versioning.UnsupportedOSPlatform("browser")>]
static member CreateFromCertFile : string -> System.Security.Cryptography.X509Certificates.X509Certificate
Public Shared Function CreateFromCertFile (filename As String) As X509Certificate
Parameters
- filename
- String
Het pad van het PKCS7-ondertekende bestand waaruit het X.509-certificaat moet worden gemaakt.
Retouren
Het zojuist gemaakte X.509-certificaat.
- Kenmerken
Uitzonderingen
De filename parameter is null.
Voorbeelden
In het volgende voorbeeld wordt een X509Certificate van een opgegeven certificeringsbestand gemaakt.
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 resultsTrue = cert.ToString(true);
// Display the value to the console.
Console.WriteLine(resultsTrue);
// Get the value.
string resultsFalse = cert.ToString(false);
// Display the value to the console.
Console.WriteLine(resultsFalse);
}
}
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 resultsTrue As String = cert.ToString(True)
' Display the value to the console.
Console.WriteLine(resultsTrue)
' Get the value.
Dim resultsFalse As String = cert.ToString(False)
' Display the value to the console.
Console.WriteLine(resultsFalse)
End Sub
End Class
Opmerkingen
ASN.1 DER is de enige certificaatindeling die door deze klasse wordt ondersteund.
Note
Het certificaatbestand is niet beperkt tot .cer bestanden. Elk pkCS7-ondertekend bestand kan worden gebruikt, inclusief een Authenticode-ondertekend PFX-bestand.