X509Certificate2.SubjectName プロパティとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > X509Certificate2.SubjectName プロパティの意味・解説 

X509Certificate2.SubjectName プロパティ

メモ : このプロパティは、.NET Framework version 2.0新しく追加されたものです。

証明書からサブジェクト識別名を取得します

名前空間: System.Security.Cryptography.X509Certificates
アセンブリ: System (system.dll 内)
構文構文

Public ReadOnly Property
 SubjectName As X500DistinguishedName
Dim instance As X509Certificate2
Dim value As X500DistinguishedName

value = instance.SubjectName
public X500DistinguishedName SubjectName { get;
 }
public:
property X500DistinguishedName^ SubjectName {
    X500DistinguishedName^ get ();
}
/** @property */
public X500DistinguishedName get_SubjectName ()
public function get SubjectName
 () : X500DistinguishedName

プロパティ
証明書サブジェクトの名前を表す X500DistinguishedName オブジェクト

解説解説

サブジェクト識別名は、証明書ユーザーの名前です。証明書識別名は、証明書サブジェクトまたは発行者テキスト表現です。この表現は、"CN=MyName, OU=MyOrgUnit, C=US" のように名前の属性構成されます。

使用例使用例

証明書ファイル引数として受け取り、その証明書の各種プロパティコンソール出力するコマンド ライン形式実行可能ファイル作成するコード例次に示します

#using <System.dll>

using namespace System;
using namespace System::Security::Cryptography;
using namespace System::Security::Permissions;
using namespace System::IO;
using namespace System::Security::Cryptography::X509Certificates;

//Reads a file.
array<Byte>^ ReadFile( String^ fileName )
{
   FileStream^ f = gcnew FileStream( fileName,FileMode::Open,FileAccess::Read );
   int size = (int)f->Length;
   array<Byte>^data = gcnew array<Byte>(size);
   size = f->Read( data, 0, size );
   f->Close();
   return data;
}

int main()
{
   array<String^>^args = Environment::GetCommandLineArgs();
   
   //Test for correct number of arguments.
   if ( args->Length < 2 )
   {
      Console::WriteLine( "Usage: CertInfo <filename>" );
      return  -1;
   }

   try
   {
      System::Security::Cryptography::X509Certificates::X509Certificate2 ^ x509 =
 
            gcnew System::Security::Cryptography::X509Certificates::X509Certificate2;
      
      //Create X509Certificate2 object from .cer file.
      array<Byte>^rawData = ReadFile( args[ 1 ] );
      x509->Import(rawData);
      
      //Print to console information contained in the certificate.
      Console::WriteLine( "{0}Subject: {1}{0}", Environment::NewLine, x509->Subject
 );
      Console::WriteLine( "{0}Issuer: {1}{0}", Environment::NewLine, x509->Issuer
 );
      Console::WriteLine( "{0}Version: {1}{0}", Environment::NewLine, x509->Version
 );
      Console::WriteLine( "{0}Valid Date: {1}{0}", Environment::NewLine,
 x509->NotBefore );
      Console::WriteLine( "{0}Expiry Date: {1}{0}", Environment::NewLine,
 x509->NotAfter );
      Console::WriteLine( "{0}Thumbprint: {1}{0}", Environment::NewLine,
 x509->Thumbprint );
      Console::WriteLine( "{0}Serial Number: {1}{0}", Environment::NewLine,
 x509->SerialNumber );
      Console::WriteLine( "{0}Friendly Name: {1}{0}", Environment::NewLine,
 x509->PublicKey->Oid->FriendlyName );
      Console::WriteLine( "{0}Public Key Format: {1}{0}", Environment::NewLine,
 x509->PublicKey->EncodedKeyValue->Format(true) );
      Console::WriteLine( "{0}Raw Data Length: {1}{0}", Environment::NewLine,
 x509->RawData->Length );
      Console::WriteLine( "{0}Certificate to string: {1}{0}",
 Environment::NewLine, x509->ToString( true ) );
      Console::WriteLine( "{0}Certificate to XML String: {1}{0}", Environment::NewLine,
 x509->PublicKey->Key->ToXmlString( false ) );
      
      //Add the certificate to a X509Store.
      X509Store ^ store = gcnew X509Store;
      store->Open( OpenFlags::MaxAllowed );
      store->Add( x509 );
      store->Close();
   }
   catch ( DirectoryNotFoundException^ ) 
   {
      Console::WriteLine( "Error: The directory specified could not be found."
 );
   }
   catch ( IOException^ ) 
   {
      Console::WriteLine( "Error: A file in the directory
 could not be accessed." );
   }
   catch ( NullReferenceException^ ) 
   {
      Console::WriteLine( "File must be a .cer file. Program does not have access
 to that type of file." );
   }

}

プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
X509Certificate2 クラス
X509Certificate2 メンバ
System.Security.Cryptography.X509Certificates 名前空間



英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

X509Certificate2.SubjectName プロパティのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



X509Certificate2.SubjectName プロパティのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2024 Microsoft.All rights reserved.

©2024 GRAS Group, Inc.RSS