X509Certificate コンストラクタ (Byte[])
X.509v3 証明書を表すバイトのシーケンスから定義された X509Certificate クラスの新しいインスタンスを初期化します。
名前空間: System.Security.Cryptography.X509Certificates
アセンブリ: mscorlib (mscorlib.dll 内)
構文
'宣言
Public Sub New ( _
data As Byte() _
)
'使用
Dim data As Byte()
Dim instance As New X509Certificate(data)
public X509Certificate (
byte[] data
)
public:
X509Certificate (
array<unsigned char>^ data
)
public X509Certificate (
byte[] data
)
public function X509Certificate (
data : byte[]
)
適用できません。
パラメータ
- data
X.509 証明書のデータを格納しているバイト配列。
例外
例外の種類 | 条件 |
---|---|
証明書でエラーが発生しました。次に例を示します。
|
|
rawData パラメータが null 参照 (Visual Basic では Nothing) です。 または rawData パラメータの長さが 0 です。 |
解説
ASN.1 DER は、このクラスでサポートされている唯一の証明書の形式です。
PKCS7 で署名されたファイル ストアを data に指定して X509Certificate 証明書を作成した場合は、ストア内の証明書ではなく、ストアを署名した証明書に X509Certificate が作成されます。
使用例
X.509 証明書ファイルを X509Certificate オブジェクトに読み込み、証明書をバイト配列としてエクスポートして、そのバイト配列を別の X509Certificate オブジェクトにインポートする例を次に示します。
Imports System
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
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);
}
}
using namespace System;
using namespace System::Security::Cryptography::X509Certificates;
int main()
{
// The path to the certificate.
String^ Certificate = L"test.pfx";
// Load the certificate into an X509Certificate object.
X509Certificate^ cert = gcnew X509Certificate( Certificate );
array<Byte>^certData = cert->Export( X509ContentType::Cert );
X509Certificate^ newCert = gcnew 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 );
}
PKCS7 で署名されたファイル ストアを rawData に指定して X509Certificate 証明書を作成した場合は、ストア内の証明書ではなく、ストアを署名した証明書に X509Certificate が作成されます。
.NET Framework のセキュリティ
- KeyContainerPermission (キー コンテナを作成するために必要なアクセス許可)。Create (関連する列挙体)。Demand (セキュリティ アクション)。
プラットフォーム
Windows 98,Windows Server 2000 SP4,Windows CE,Windows Millennium Edition,Windows Mobile for Pocket PC,Windows Mobile for Smartphone,Windows Server 2003,Windows XP Media Center Edition,Windows XP Professional x64 Edition,Windows XP SP2,Windows XP Starter Edition
Microsoft .NET Framework 3.0 は Windows Vista,Microsoft Windows XP SP2,および Windows Server 2003 SP1 でサポートされています。
バージョン情報
.NET Framework
サポート対象 : 3.0,2.0,1.1,1.0
.NET Compact Framework
サポート対象 : 2.0,1.0
参照
関連項目
X509Certificate クラス
X509Certificate メンバ
System.Security.Cryptography.X509Certificates 名前空間