以下を作成するために makecert ツールを使用しました。
- 自己署名証明書
- 自己署名証明書を使用したサーバー証明書
- 自己署名証明書を使用したクライアント証明書
次に、自己署名証明書を mmc の Trusted Certificate Authorities セクションにインストールしました。
サーバー証明書とクライアント証明書は、mmc の Personal セクションにインストールされています。
次に、サーバー証明書を使用して HTTP として IIS に Web サービスをデプロイしました。
次に、Web サービスを利用する別のアプリケーションがあります。以下に示すように、Web サービス要求とともにクライアント証明書を送信します。
public static void Main(string[] args)
        {
            X509Store store = new X509Store(StoreName.My, StoreLocation.LocalMachine);
            store.Open(OpenFlags.ReadOnly);
            X509Certificate2Collection col = store.Certificates.Find(X509FindType.FindBySubjectName, "client.com", true);
            if (col.Count == 1)
            {
                ServicePointManager.Expect100Continue = true;
                ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3 | SecurityProtocolType.Tls;
                ClientServices web_service = new ClientServices();
                web_service.ClientCertificates.Add(col[0]);
                try
                {
                    string check = web_service.CheckCertificate();
                    Console.WriteLine(check);
                }
                catch (WebException e)
                {
                    Console.WriteLine(e.Message.ToString());
                }
            }
            else
            {
                Console.WriteLine("The certificate was not found!");
            }
            Console.ReadKey();
        }
サーバー側では、次のようにクライアント証明書を確認しています。
[WebMethod]
        public string CheckCertificate()
        {
            string message;
            try
            {
                X509Certificate2 cert = new X509Certificate2(Context.Request.ClientCertificate.Certificate);                
                if (cert != null)
                {
                    message = cert.SerialNumber.ToString();
                }
                else
                {
                    message = "Error: No certificate was found!";
                }
            }
            catch (Exception e)
            {
                message = e.Message.ToString();
            }
            return message;
        }
クライアント アプリを実行するたびに、次のエラー メッセージが表示されます。
リクエストは中止されました。SSL/TLS セキュア チャネルを作成できませんでした。
どうすればこの問題を解決できますか?