X509Certificate.Import メソッド

定義

X509Certificate オブジェクトを設定します。

オーバーロード

Import(String, String, X509KeyStorageFlags)
古い.
古い.

証明書ファイルの情報、パスワード、および X509Certificate 値を使用して、X509KeyStorageFlags オブジェクトを設定します。

Import(String, SecureString, X509KeyStorageFlags)
古い.
古い.

証明書ファイルの情報、パスワード、およびキー格納フラグを指定して、X509Certificate オブジェクトを設定します。

Import(Byte[], String, X509KeyStorageFlags)
古い.
古い.

バイト配列のデータ、パスワード、および秘密キーのインポート方法を決定するフラグを使用して、X509Certificate オブジェクトを設定します。

Import(Byte[])
古い.
古い.

バイト配列のデータを使用して、X509Certificate オブジェクトを設定します。

Import(String)
古い.
古い.

証明書ファイルからの情報を使用して、X509Certificate オブジェクトを設定します。

Import(Byte[], SecureString, X509KeyStorageFlags)
古い.
古い.

バイト配列のデータ、パスワード、およびキー格納フラグを使用して、X509Certificate オブジェクトを設定します。

Import(String, String, X509KeyStorageFlags)

ソース:
X509Certificate.cs
ソース:
X509Certificate.cs
ソース:
X509Certificate.cs

注意事項

X509Certificate and X509Certificate2 are immutable. Use the appropriate constructor to create a new certificate.

注意事項

X509Certificate and X509Certificate2 are immutable. Use X509CertificateLoader to create a new certificate.

証明書ファイルの情報、パスワード、および X509Certificate 値を使用して、X509KeyStorageFlags オブジェクトを設定します。

C#
public virtual void Import (string fileName, string? password, System.Security.Cryptography.X509Certificates.X509KeyStorageFlags keyStorageFlags);
C#
[System.Obsolete("X509Certificate and X509Certificate2 are immutable. Use the appropriate constructor to create a new certificate.", DiagnosticId="SYSLIB0026", UrlFormat="https://aka.ms/dotnet-warnings/{0}")]
public virtual void Import (string fileName, string? password, System.Security.Cryptography.X509Certificates.X509KeyStorageFlags keyStorageFlags);
C#
[System.Obsolete("X509Certificate and X509Certificate2 are immutable. Use X509CertificateLoader to create a new certificate.", DiagnosticId="SYSLIB0026", UrlFormat="https://aka.ms/dotnet-warnings/{0}")]
public virtual void Import (string fileName, string? password, System.Security.Cryptography.X509Certificates.X509KeyStorageFlags keyStorageFlags);
C#
public virtual void Import (string fileName, string password, System.Security.Cryptography.X509Certificates.X509KeyStorageFlags keyStorageFlags);
C#
[System.Runtime.InteropServices.ComVisible(false)]
public virtual void Import (string fileName, string password, System.Security.Cryptography.X509Certificates.X509KeyStorageFlags keyStorageFlags);
C#
[System.Runtime.InteropServices.ComVisible(false)]
[System.Security.SecurityCritical]
public virtual void Import (string fileName, string password, System.Security.Cryptography.X509Certificates.X509KeyStorageFlags keyStorageFlags);

パラメーター

fileName
String

文字列で表現される証明書ファイルの名前。

password
String

X.509 証明書データにアクセスするために必要なパスワード。

keyStorageFlags
X509KeyStorageFlags

証明書をインポートする場所と方法を制御する列挙値のビットごとの組み合わせ。

属性

例外

fileName パラメーターが null です。

.NET Core および .NET 5 以降のみ:すべての場合。

注釈

重要

ソース コード内でパスワードをハードコーディングしないでください。 ハードコーディングされたパスワードは、 Ildasm.exe (IL 逆アセンブラー)、16 進エディター、または単に Notepad.exe などのテキスト エディターでアセンブリを開くだけで、アセンブリから取得できます。

適用対象

.NET 9 およびその他のバージョン
製品 バージョン (廃止)
.NET Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5 (6, 7, 8, 9)
.NET Framework 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0, 2.1

Import(String, SecureString, X509KeyStorageFlags)

ソース:
X509Certificate.cs
ソース:
X509Certificate.cs
ソース:
X509Certificate.cs

注意事項

X509Certificate and X509Certificate2 are immutable. Use the appropriate constructor to create a new certificate.

注意事項

X509Certificate and X509Certificate2 are immutable. Use X509CertificateLoader to create a new certificate.

重要

この API は CLS 準拠ではありません。

証明書ファイルの情報、パスワード、およびキー格納フラグを指定して、X509Certificate オブジェクトを設定します。

C#
[System.CLSCompliant(false)]
public virtual void Import (string fileName, System.Security.SecureString? password, System.Security.Cryptography.X509Certificates.X509KeyStorageFlags keyStorageFlags);
C#
[System.CLSCompliant(false)]
[System.Obsolete("X509Certificate and X509Certificate2 are immutable. Use the appropriate constructor to create a new certificate.", DiagnosticId="SYSLIB0026", UrlFormat="https://aka.ms/dotnet-warnings/{0}")]
public virtual void Import (string fileName, System.Security.SecureString? password, System.Security.Cryptography.X509Certificates.X509KeyStorageFlags keyStorageFlags);
C#
[System.CLSCompliant(false)]
[System.Obsolete("X509Certificate and X509Certificate2 are immutable. Use X509CertificateLoader to create a new certificate.", DiagnosticId="SYSLIB0026", UrlFormat="https://aka.ms/dotnet-warnings/{0}")]
public virtual void Import (string fileName, System.Security.SecureString? password, System.Security.Cryptography.X509Certificates.X509KeyStorageFlags keyStorageFlags);
C#
[System.CLSCompliant(false)]
public virtual void Import (string fileName, System.Security.SecureString password, System.Security.Cryptography.X509Certificates.X509KeyStorageFlags keyStorageFlags);
C#
public virtual void Import (string fileName, System.Security.SecureString password, System.Security.Cryptography.X509Certificates.X509KeyStorageFlags keyStorageFlags);
C#
[System.Security.SecurityCritical]
public virtual void Import (string fileName, System.Security.SecureString password, System.Security.Cryptography.X509Certificates.X509KeyStorageFlags keyStorageFlags);

パラメーター

fileName
String

証明書ファイルの名前。

password
SecureString

X.509 証明書データにアクセスするために必要なパスワード。

keyStorageFlags
X509KeyStorageFlags

証明書をインポートする場所と方法を制御する列挙値のビットごとの組み合わせ。

属性

例外

fileName パラメーターが null です。

.NET Core および .NET 5 以降のみ:すべての場合。

注釈

重要

ソース コード内でパスワードをハードコードしないでください。 ハードコーディングされたパスワードは、 Ildasm.exe (IL 逆アセンブラー)、16 進エディター、または単に Notepad.exe などのテキスト エディターでアセンブリを開くだけで、アセンブリから取得できます。

適用対象

.NET 9 およびその他のバージョン
製品 バージョン (廃止)
.NET Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5 (6, 7, 8, 9)
.NET Framework 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0, 2.1

Import(Byte[], String, X509KeyStorageFlags)

ソース:
X509Certificate.cs
ソース:
X509Certificate.cs
ソース:
X509Certificate.cs

注意事項

X509Certificate and X509Certificate2 are immutable. Use the appropriate constructor to create a new certificate.

注意事項

X509Certificate and X509Certificate2 are immutable. Use X509CertificateLoader to create a new certificate.

バイト配列のデータ、パスワード、および秘密キーのインポート方法を決定するフラグを使用して、X509Certificate オブジェクトを設定します。

C#
public virtual void Import (byte[] rawData, string? password, System.Security.Cryptography.X509Certificates.X509KeyStorageFlags keyStorageFlags);
C#
[System.Obsolete("X509Certificate and X509Certificate2 are immutable. Use the appropriate constructor to create a new certificate.", DiagnosticId="SYSLIB0026", UrlFormat="https://aka.ms/dotnet-warnings/{0}")]
public virtual void Import (byte[] rawData, string? password, System.Security.Cryptography.X509Certificates.X509KeyStorageFlags keyStorageFlags);
C#
[System.Obsolete("X509Certificate and X509Certificate2 are immutable. Use X509CertificateLoader to create a new certificate.", DiagnosticId="SYSLIB0026", UrlFormat="https://aka.ms/dotnet-warnings/{0}")]
public virtual void Import (byte[] rawData, string? password, System.Security.Cryptography.X509Certificates.X509KeyStorageFlags keyStorageFlags);
C#
public virtual void Import (byte[] rawData, string password, System.Security.Cryptography.X509Certificates.X509KeyStorageFlags keyStorageFlags);
C#
[System.Runtime.InteropServices.ComVisible(false)]
public virtual void Import (byte[] rawData, string password, System.Security.Cryptography.X509Certificates.X509KeyStorageFlags keyStorageFlags);
C#
[System.Runtime.InteropServices.ComVisible(false)]
[System.Security.SecurityCritical]
public virtual void Import (byte[] rawData, string password, System.Security.Cryptography.X509Certificates.X509KeyStorageFlags keyStorageFlags);

パラメーター

rawData
Byte[]

X.509 証明書のデータを格納しているバイト配列。

password
String

X.509 証明書データにアクセスするために必要なパスワード。

keyStorageFlags
X509KeyStorageFlags

証明書をインポートする場所と方法を制御する列挙値のビットごとの組み合わせ。

属性

例外

rawData パラメーターが null です。

または

rawData パラメーターの長さが 0 です。

.NET Core および .NET 5 以降のみ:すべての場合。

注釈

このメソッドを使用すると、バイト配列で表される証明書のパスワードを使用してオブジェクトを設定 X509Certificate できます。 値を X509KeyStorageFlags 使用して、秘密キーをインポートする場所と方法を制御できます。

適用対象

.NET 9 およびその他のバージョン
製品 バージョン (廃止)
.NET Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5 (6, 7, 8, 9)
.NET Framework 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0, 2.1

Import(Byte[])

ソース:
X509Certificate.cs
ソース:
X509Certificate.cs
ソース:
X509Certificate.cs

注意事項

X509Certificate and X509Certificate2 are immutable. Use the appropriate constructor to create a new certificate.

注意事項

X509Certificate and X509Certificate2 are immutable. Use X509CertificateLoader to create a new certificate.

バイト配列のデータを使用して、X509Certificate オブジェクトを設定します。

C#
public virtual void Import (byte[] rawData);
C#
[System.Obsolete("X509Certificate and X509Certificate2 are immutable. Use the appropriate constructor to create a new certificate.", DiagnosticId="SYSLIB0026", UrlFormat="https://aka.ms/dotnet-warnings/{0}")]
public virtual void Import (byte[] rawData);
C#
[System.Obsolete("X509Certificate and X509Certificate2 are immutable. Use X509CertificateLoader to create a new certificate.", DiagnosticId="SYSLIB0026", UrlFormat="https://aka.ms/dotnet-warnings/{0}")]
public virtual void Import (byte[] rawData);
C#
[System.Runtime.InteropServices.ComVisible(false)]
public virtual void Import (byte[] rawData);
C#
[System.Runtime.InteropServices.ComVisible(false)]
[System.Security.SecurityCritical]
public virtual void Import (byte[] rawData);

パラメーター

rawData
Byte[]

X.509 証明書のデータを格納しているバイト配列。

属性

例外

rawData パラメーターが null です。

または

rawData パラメーターの長さが 0 です。

.NET Core および .NET 5 以降のみ:すべての場合。

注釈

このメソッドを使用すると、X.509 証明書の生のバイト配列を取得し、オブジェクトに関連する値を X509Certificate 設定できます。

適用対象

.NET 9 およびその他のバージョン
製品 バージョン (廃止)
.NET Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5 (6, 7, 8, 9)
.NET Framework 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0, 2.1

Import(String)

ソース:
X509Certificate.cs
ソース:
X509Certificate.cs
ソース:
X509Certificate.cs

注意事項

X509Certificate and X509Certificate2 are immutable. Use the appropriate constructor to create a new certificate.

注意事項

X509Certificate and X509Certificate2 are immutable. Use X509CertificateLoader to create a new certificate.

証明書ファイルからの情報を使用して、X509Certificate オブジェクトを設定します。

C#
public virtual void Import (string fileName);
C#
[System.Obsolete("X509Certificate and X509Certificate2 are immutable. Use the appropriate constructor to create a new certificate.", DiagnosticId="SYSLIB0026", UrlFormat="https://aka.ms/dotnet-warnings/{0}")]
public virtual void Import (string fileName);
C#
[System.Obsolete("X509Certificate and X509Certificate2 are immutable. Use X509CertificateLoader to create a new certificate.", DiagnosticId="SYSLIB0026", UrlFormat="https://aka.ms/dotnet-warnings/{0}")]
public virtual void Import (string fileName);
C#
[System.Runtime.InteropServices.ComVisible(false)]
public virtual void Import (string fileName);
C#
[System.Runtime.InteropServices.ComVisible(false)]
[System.Security.SecurityCritical]
public virtual void Import (string fileName);

パラメーター

fileName
String

文字列で表現される証明書ファイルの名前。

属性

例外

fileName パラメーターが null です。

.NET Core および .NET 5 以降のみ:すべての場合。

次の例では、ファイルから X.509 証明書を読み込み、 メソッドを ToString 呼び出して、結果をコンソールに表示します。

C#
using System;
using System.Security.Cryptography.X509Certificates;

class X509
{

    static void Main()
    {

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

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

        cert.Import(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);
    }
}

注釈

このメソッドは、X.509 証明書を表す証明書ファイル (拡張子が.cerのファイルなど) を使用し、ファイルに含まれる証明書をオブジェクトに設定 X509Certificate します。

適用対象

.NET 9 およびその他のバージョン
製品 バージョン (廃止)
.NET Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5 (6, 7, 8, 9)
.NET Framework 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0, 2.1

Import(Byte[], SecureString, X509KeyStorageFlags)

ソース:
X509Certificate.cs
ソース:
X509Certificate.cs
ソース:
X509Certificate.cs

注意事項

X509Certificate and X509Certificate2 are immutable. Use the appropriate constructor to create a new certificate.

注意事項

X509Certificate and X509Certificate2 are immutable. Use X509CertificateLoader to create a new certificate.

重要

この API は CLS 準拠ではありません。

バイト配列のデータ、パスワード、およびキー格納フラグを使用して、X509Certificate オブジェクトを設定します。

C#
[System.CLSCompliant(false)]
public virtual void Import (byte[] rawData, System.Security.SecureString? password, System.Security.Cryptography.X509Certificates.X509KeyStorageFlags keyStorageFlags);
C#
[System.CLSCompliant(false)]
[System.Obsolete("X509Certificate and X509Certificate2 are immutable. Use the appropriate constructor to create a new certificate.", DiagnosticId="SYSLIB0026", UrlFormat="https://aka.ms/dotnet-warnings/{0}")]
public virtual void Import (byte[] rawData, System.Security.SecureString? password, System.Security.Cryptography.X509Certificates.X509KeyStorageFlags keyStorageFlags);
C#
[System.CLSCompliant(false)]
[System.Obsolete("X509Certificate and X509Certificate2 are immutable. Use X509CertificateLoader to create a new certificate.", DiagnosticId="SYSLIB0026", UrlFormat="https://aka.ms/dotnet-warnings/{0}")]
public virtual void Import (byte[] rawData, System.Security.SecureString? password, System.Security.Cryptography.X509Certificates.X509KeyStorageFlags keyStorageFlags);
C#
[System.CLSCompliant(false)]
public virtual void Import (byte[] rawData, System.Security.SecureString password, System.Security.Cryptography.X509Certificates.X509KeyStorageFlags keyStorageFlags);
C#
public virtual void Import (byte[] rawData, System.Security.SecureString password, System.Security.Cryptography.X509Certificates.X509KeyStorageFlags keyStorageFlags);
C#
[System.Security.SecurityCritical]
public virtual void Import (byte[] rawData, System.Security.SecureString password, System.Security.Cryptography.X509Certificates.X509KeyStorageFlags keyStorageFlags);

パラメーター

rawData
Byte[]

X.509 証明書のデータを格納しているバイト配列。

password
SecureString

X.509 証明書データにアクセスするために必要なパスワード。

keyStorageFlags
X509KeyStorageFlags

証明書をインポートする場所と方法を制御する列挙値のビットごとの組み合わせ。

属性

例外

rawData パラメーターが null です。

または

rawData パラメーターの長さが 0 です。

.NET Core および .NET 5 以降のみ:すべての場合。

注釈

重要

ソース コード内でパスワードをハードコードしないでください。 ハードコーディングされたパスワードは、 Ildasm.exe (IL 逆アセンブラー)、16 進エディター、または単に Notepad.exe などのテキスト エディターでアセンブリを開くだけで、アセンブリから取得できます。

適用対象

.NET 9 およびその他のバージョン
製品 バージョン (廃止)
.NET Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5 (6, 7, 8, 9)
.NET Framework 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0, 2.1