X509Certificate.Export メソッド
定義
重要
一部の情報は、リリース前に大きく変更される可能性があるプレリリースされた製品に関するものです。 Microsoft は、ここに記載されている情報について、明示または黙示を問わず、一切保証しません。
現在の X509Certificate オブジェクトをバイト配列にエクスポートします。
オーバーロード
| 名前 | 説明 |
|---|---|
| Export(X509ContentType) |
現在の X509Certificate オブジェクトを、 X509ContentType 値のいずれかで記述された形式でバイト配列にエクスポートします。 |
| Export(X509ContentType, SecureString) |
指定した形式とパスワードを使用して、現在の X509Certificate オブジェクトをバイト配列にエクスポートします。 |
| Export(X509ContentType, String) |
現在の X509Certificate オブジェクトを、指定したパスワードを使用して、 X509ContentType 値のいずれかで記述された形式でバイト配列にエクスポートします。 |
Export(X509ContentType)
現在の X509Certificate オブジェクトを、 X509ContentType 値のいずれかで記述された形式でバイト配列にエクスポートします。
public:
virtual cli::array <System::Byte> ^ Export(System::Security::Cryptography::X509Certificates::X509ContentType contentType);
public virtual byte[] Export(System.Security.Cryptography.X509Certificates.X509ContentType contentType);
[System.Runtime.InteropServices.ComVisible(false)]
public virtual byte[] Export(System.Security.Cryptography.X509Certificates.X509ContentType contentType);
abstract member Export : System.Security.Cryptography.X509Certificates.X509ContentType -> byte[]
override this.Export : System.Security.Cryptography.X509Certificates.X509ContentType -> byte[]
[<System.Runtime.InteropServices.ComVisible(false)>]
abstract member Export : System.Security.Cryptography.X509Certificates.X509ContentType -> byte[]
override this.Export : System.Security.Cryptography.X509Certificates.X509ContentType -> byte[]
Public Overridable Function Export (contentType As X509ContentType) As Byte()
パラメーター
- contentType
- X509ContentType
出力データの書式設定方法を説明する X509ContentType 値の 1 つ。
返品
現在の X509Certificate オブジェクトを表すバイト配列。
- 属性
例外
例
次の例では、X.509 証明書ファイルを X509Certificate オブジェクトに読み込み、証明書をバイト配列としてエクスポートしてから、バイト配列を別の X509Certificate オブジェクトにインポートします。
using System;
using System.Security.Cryptography.X509Certificates;
public class X509
{
public static void Main()
{
// The path to the certificate.
string Certificate = "test.pfx";
// Load the certificate into an X509Certificate object.
X509Certificate cert = new X509Certificate(Certificate);
byte[] certData = cert.Export(X509ContentType.Cert);
X509Certificate newCert = new X509Certificate(certData);
// Get the value.
string resultsTrue = newCert.ToString(true);
// Display the value to the console.
Console.WriteLine(resultsTrue);
// Get the value.
string resultsFalse = newCert.ToString(false);
// Display the value to the console.
Console.WriteLine(resultsFalse);
}
}
Imports System.Security.Cryptography.X509Certificates
Module X509
Sub Main()
' The path to the certificate.
Dim Certificate As String = "test.pfx"
' Load the certificate into an X509Certificate object.
Dim cert As New X509Certificate(Certificate)
Dim certData As Byte() = cert.Export(X509ContentType.Cert)
Dim newCert As New X509Certificate(certData)
' Get the value.
Dim resultsTrue As String = newCert.ToString(True)
' Display the value to the console.
Console.WriteLine(resultsTrue)
' Get the value.
Dim resultsFalse As String = newCert.ToString(False)
' Display the value to the console.
Console.WriteLine(resultsFalse)
End Sub
End Module
注釈
contentType パラメーターは、X509ContentType列挙体の値 (Cert、SerializedCert、Pkcs12) のみを受け取ります。 その他の値を渡すと、 CryptographicException がスローされます。
適用対象
Export(X509ContentType, SecureString)
重要
この API は CLS 準拠ではありません。
指定した形式とパスワードを使用して、現在の X509Certificate オブジェクトをバイト配列にエクスポートします。
public:
virtual cli::array <System::Byte> ^ Export(System::Security::Cryptography::X509Certificates::X509ContentType contentType, System::Security::SecureString ^ password);
[System.CLSCompliant(false)]
public virtual byte[] Export(System.Security.Cryptography.X509Certificates.X509ContentType contentType, System.Security.SecureString? password);
[System.CLSCompliant(false)]
public virtual byte[] Export(System.Security.Cryptography.X509Certificates.X509ContentType contentType, System.Security.SecureString password);
public virtual byte[] Export(System.Security.Cryptography.X509Certificates.X509ContentType contentType, System.Security.SecureString password);
[<System.CLSCompliant(false)>]
abstract member Export : System.Security.Cryptography.X509Certificates.X509ContentType * System.Security.SecureString -> byte[]
override this.Export : System.Security.Cryptography.X509Certificates.X509ContentType * System.Security.SecureString -> byte[]
abstract member Export : System.Security.Cryptography.X509Certificates.X509ContentType * System.Security.SecureString -> byte[]
override this.Export : System.Security.Cryptography.X509Certificates.X509ContentType * System.Security.SecureString -> byte[]
Public Overridable Function Export (contentType As X509ContentType, password As SecureString) As Byte()
パラメーター
- contentType
- X509ContentType
出力データの書式設定方法を説明する X509ContentType 値の 1 つ。
- password
- SecureString
X.509 証明書データにアクセスするために必要なパスワード。
返品
現在の X509Certificate オブジェクトを表すバイト配列。
- 属性
例外
注釈
contentType パラメーターは、X509ContentType列挙体の値 (Cert、SerializedCert、Pkcs12) のみを受け取ります。 その他の値を渡すと、 CryptographicException がスローされます。
Important
ソース コード内でパスワードをハード コーディングしないでください。 ハードコーディングされたパスワードは、 Ildasm.exe (IL 逆アセンブラー)、16 進エディター、または Notepad.exeなどのテキスト エディターでアセンブリを開くだけで、アセンブリから取得できます。
適用対象
Export(X509ContentType, String)
現在の X509Certificate オブジェクトを、指定したパスワードを使用して、 X509ContentType 値のいずれかで記述された形式でバイト配列にエクスポートします。
public:
virtual cli::array <System::Byte> ^ Export(System::Security::Cryptography::X509Certificates::X509ContentType contentType, System::String ^ password);
public virtual byte[] Export(System.Security.Cryptography.X509Certificates.X509ContentType contentType, string? password);
public virtual byte[] Export(System.Security.Cryptography.X509Certificates.X509ContentType contentType, string password);
[System.Runtime.InteropServices.ComVisible(false)]
public virtual byte[] Export(System.Security.Cryptography.X509Certificates.X509ContentType contentType, string password);
abstract member Export : System.Security.Cryptography.X509Certificates.X509ContentType * string -> byte[]
override this.Export : System.Security.Cryptography.X509Certificates.X509ContentType * string -> byte[]
[<System.Runtime.InteropServices.ComVisible(false)>]
abstract member Export : System.Security.Cryptography.X509Certificates.X509ContentType * string -> byte[]
override this.Export : System.Security.Cryptography.X509Certificates.X509ContentType * string -> byte[]
Public Overridable Function Export (contentType As X509ContentType, password As String) As Byte()
パラメーター
- contentType
- X509ContentType
出力データの書式設定方法を説明する X509ContentType 値の 1 つ。
- password
- String
X.509 証明書データにアクセスするために必要なパスワード。
返品
現在の X509Certificate オブジェクトを表すバイト配列。
- 属性
例外
注釈
contentType パラメーターは、X509ContentType列挙体の値 (Cert、SerializedCert、Pkcs12) のみを受け取ります。 その他の値を渡すと、 CryptographicException がスローされます。
Important
ソース コード内でパスワードをハード コーディングしないでください。 ハードコーディングされたパスワードは、 Ildasm.exe (IL 逆アセンブラー)、16 進エディター、または Notepad.exeなどのテキスト エディターでアセンブリを開くだけで、アセンブリから取得できます。