none
Windowsの証明書を使ってSOAP接続 RRS feed

  • 質問

  • VisualStudio2005のVBを使ったアプリケーションを開発しています。

    サーバ証明書、ルート証明書を使って、セキュリティ対策をしようとしていますが、やり方がわからず困っています。

    Windowsの証明書を自動的にチェックして、証明書があれば接続し、なければエラーにしようとしています。

    (1)ServiceRefrenceに以下を「CERTIFICATE」と名づけて設定しました。
    https://www.xxx.com/remote.wsdl

    (2)App.configを以下の部分を追加しました。
        <system.serviceModel>
          <bindings>
            <basicHttpBinding>
              <binding name="RemoteBinding1" closeTimeout="00:01:00" openTimeout="00:01:00"
                receiveTimeout="00:10:00" sendTimeout="00:01:00" allowCookies="false"
                bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
                maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
                messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
                useDefaultWebProxy="true">
                <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
                  maxBytesPerRead="4096" maxNameTableCharCount="16384" />
                <security mode="Transport">
                  <transport clientCredentialType="Certificate" />
                </security>
              </binding>
            </basicHttpBinding>
          </bindings>
          <client>
            <endpoint address="https://www.xxx.com" binding="basicHttpBinding"
              bindingConfiguration="RemoteBinding1" contract="CERTIFICATE.RemotePortType"
              name="RemotePort1" />
          </client>
        </system.serviceModel>

    (3)ソースにエラーチェック部分を入れました。
            '証明書チェック
            Dim tmpstr As String
            Try
                Dim wsCertChk As New CERTIFICATE.RemotePortTypeClient
                tmpstr = wsCertChk.serverTime()
            Catch ex As Exception
                MessageBox.Show(ex.Message)
                log1.add("証明書チェックエラー")
                End
            End Try

    (4)VBがエラーが返してくれるようにはなりました。
    エラーのメッセージ:「クライアントの証明書が提供されていません。クライアントの証明書を ClientCredentials で指定してください。」

    (5)しかし、ここからがわかりません。
    VBにWindowsOSへインポート済の証明書を参照させ、証明書が提供されていればOKとさせたいのです。

    方法をGoogle検索などで調べ、色々試していますが、まるで実現できません。
    すでにご存知のかたがいらっしゃいましたら、教えていただけましたら幸いです・・・。

    2016年11月4日 5:03

回答