次の方法で共有


X509Certificate.CreateFromCertFile メソッド

指定した証明書ファイルから X.509v3 証明書を作成します。

Public Shared Function CreateFromCertFile( _
   ByVal filename As String _) As X509Certificate
[C#]
public static X509Certificate CreateFromCertFile(stringfilename);
[C++]
public: static X509Certificate* CreateFromCertFile(String* filename);
[JScript]
public static function CreateFromCertFile(
   filename : String) : X509Certificate;

パラメータ

  • filename
    X.509 証明書の作成元の証明書ファイルのパス。

戻り値

新しく作成された X.509 証明書。

例外

例外の種類 条件
ArgumentException filename パラメータで指定されたファイルが見つかりません。

解説

ASN.1 DER は、このクラスでサポートされている唯一の証明書の形式です。

使用例

 
Imports System
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 


[C#] 

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);
  
    }

}

[C++] 

#using <mscorlib.dll>
using namespace System;
using namespace System::Security::Cryptography::X509Certificates;

int main()
{

    // The path to the certificate.
    String* Certificate =  S"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);

}

[JScript] JScript のサンプルはありません。Visual Basic、C#、および C++ のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン 言語のフィルタ をクリックします。

必要条件

プラットフォーム: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 ファミリ

参照

X509Certificate クラス | X509Certificate メンバ | System.Security.Cryptography.X509Certificates 名前空間