LocalCertificateSelectionCallback デリゲートとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > LocalCertificateSelectionCallback デリゲートの意味・解説 

LocalCertificateSelectionCallback デリゲート

メモ : このデリゲートは、.NET Framework version 2.0 で新しく追加されたものです。

認証に使用するローカルの SSL (Secure Sockets Layer) 証明書を選択します。

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

Public Delegate Function
 LocalCertificateSelectionCallback ( _
    sender As Object, _
    targetHost As String, _
    localCertificates As X509CertificateCollection, _
    remoteCertificate As X509Certificate, _
    acceptableIssuers As String() _
) As X509Certificate
Dim instance As New LocalCertificateSelectionCallback(AddressOf
 HandlerMethod)
public delegate X509Certificate LocalCertificateSelectionCallback
 (
    Object sender,
    string targetHost,
    X509CertificateCollection localCertificates,
    X509Certificate remoteCertificate,
    string[] acceptableIssuers
)
public delegate X509Certificate^ LocalCertificateSelectionCallback
 (
    Object^ sender, 
    String^ targetHost, 
    X509CertificateCollection^ localCertificates, 
    X509Certificate^ remoteCertificate, 
    array<String^>^ acceptableIssuers
)
/** @delegate */
public delegate X509Certificate LocalCertificateSelectionCallback
 (
    Object sender, 
    String targetHost, 
    X509CertificateCollection localCertificates, 
    X509Certificate remoteCertificate, 
    String[] acceptableIssuers
)
JScript では、デリゲートは使用できますが、新規に宣言することはできません。

パラメータ

sender

この検証のステータス情報を格納するオブジェクト。

targetHost

クライアントが指定したホスト サーバー。

localCertificates

ローカルの証明書を格納している X509CertificateCollection。

remoteCertificate

リモート側の認証に使用される証明書。

acceptableIssuers

リモート側が受け入れることのできる証明書発行者の String 配列。

戻り値
SSL 接続の確立に使用する X509Certificate。

解説解説
使用例使用例

このデリゲートにメソッドを実装するコード例を次に示します。

public static X509Certificate SelectLocalCertificate(
    object sender,
    string targetHost, 
    X509CertificateCollection localCertificates, 
    X509Certificate remoteCertificate, 
    string[] acceptableIssuers)
{    
    Console.WriteLine("Client is selecting a local certificate.");
    if (acceptableIssuers != null &&
 
        acceptableIssuers.Length > 0 &&
        localCertificates != null &&
        localCertificates.Count > 0)
    {
        // Use the first certificate that is from an acceptable issuer.
        foreach (X509Certificate certificate in
 localCertificates)
        {
            string issuer = certificate.Issuer;
            if (Array.IndexOf(acceptableIssuers, issuer) != -1)
                return certificate;
        }
    }
    if (localCertificates != null &&
        localCertificates.Count > 0)
        return localCertificates[0];
        
    return null;
}

このデリゲートのインスタンスを作成するコード例を次に示します。

// Server name must match the host name and the name on the host's certificate.
 
serverName = args[0];
// Create a TCP/IP client socket.
TcpClient client = new TcpClient(serverName,80);
Console.WriteLine("Client connected.");
// Create an SSL stream that will close the client's stream.
SslStream sslStream = new SslStream(
    client.GetStream(), 
    false, 
    new RemoteCertificateValidationCallback (ValidateServerCertificate),
 
    new LocalCertificateSelectionCallback(SelectLocalCertificate)
    );
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
System.Net.Security 名前空間
RemoteCertificateValidationCallback



英和和英テキスト翻訳

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

辞書ショートカット

すべての辞書の索引

「LocalCertificateSelectionCallback デリゲート」の関連用語

LocalCertificateSelectionCallback デリゲートのお隣キーワード
検索ランキング

   

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



LocalCertificateSelectionCallback デリゲートのページの著作権

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

©2026 GRAS Group, Inc.RSS