0

シンプルな Hello World を (SSL 経由で) 動作させようとしていますが、次のエラーが表示されます:検証手順に従ってリモート証明書が無効です。

サーバーの App.config は次のとおりです。

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <system.serviceModel>
        <behaviors>
            <serviceBehaviors>
                <behavior name="mexBehavior">
                    <serviceMetadata httpGetEnabled="true" />
                </behavior>
            </serviceBehaviors>
        </behaviors>
        <bindings>
            <wsHttpBinding>
                <binding name="SSLSecurity">
                    <security mode="Transport">
                        <transport clientCredentialType="None" />
                    </security>
                </binding>
            </wsHttpBinding>
        </bindings>
        <services>
            <service behaviorConfiguration="mexBehavior" name="HelloServiceLibrary.HelloService">
                <clear />
                <endpoint address="ws" binding="wsHttpBinding" name="wsEndpoint"
                    contract="HelloServiceLibrary.IHelloService">
                    <identity>
                        <dns value="localhost" />
                    </identity>
                </endpoint>

                <endpoint address="https://localhost:443/hellossl" binding="wsHttpBinding" name="wssslEndpoint"
                    bindingConfiguration="SSLSecurity" contract="HelloServiceLibrary.IHelloService">
                  <identity>
                    <certificateReference x509FindType="FindByThumbprint" findValue="‎82a39faaeb18bf9585b334ca83264add3d5b26ee" />
                    <dns value="localhost" />
                  </identity>
                </endpoint>

                <endpoint address="mex" binding="mexHttpBinding" name="mexEndpoint"
                    contract="IMetadataExchange">
                    <identity>
                        <dns value="localhost" />
                    </identity>
                </endpoint>
                <host>
                    <baseAddresses>
                        <add baseAddress="http://localhost:8989/hello" />
                    </baseAddresses>
                </host>
            </service>
        </services>
    </system.serviceModel>
</configuration>

私が間違っていることをアドバイスしてください。

更新: 証明書は、ローカル コンピューターの信頼されたルート証明機関に正常に展開されました。

4

3 に答える 3

1

これを WCF 構成に追加して、出力をお知らせください。

 <system.diagnostics>
    <trace autoflush="true" />
        <sources>
            <source name="System.Net" maxdatasize="1024">
                <listeners>
                    <add name="MyTraceFile"/>
                </listeners>
            </source>
          <source name="System.Net.Sockets" maxdatasize="1024">
                <listeners>
                    <add name="MyTraceFile"/>
                </listeners>
            </source>  
       </sources>

        <sharedListeners>
            <add
              name="MyTraceFile"
              type="System.Diagnostics.TextWriterTraceListener"
              initializeData="System.Net.trace.log"
            />
        </sharedListeners>
        <switches>
            <add name="System.Net" value="Verbose" />
          <add name="System.Net.Sockets" value="Verbose" /> 
        </switches>
</system.diagnostics>

これは暗闇の中での一突きです。

すべてのユーザーにインストールしたことを確認してください。

MMC を開く
スナップインの追加 (証明書)
- コンピューター アカウントの確認 (次へ)
- コンピューターの選択
完了

ここで、証明書を「信頼されたルート証明機関」に再インストールすると、すべてのユーザーに対して信頼されるようになります。

于 2010-08-31T13:02:38.363 に答える
0

安全なリンクのみが必要な場合 (つまり、暗号化のみでクライアント認証は必要ない場合)、クライアント資格情報を設定する必要はありません。1. SSL を使用するよう
に IIS を
構成する 2. サービスで HTTPS エンドポイントを
構成する 3. 上記のエンドポイントを使用するようにクライアントを構成する

それでおしまい。証明書が無効な場合は、MSDNで説明されているように、カスタム証明書の検証を行う必要がある場合があります。

幸運を!

于 2011-04-20T07:34:38.253 に答える
0

これが役立つかどうかはわかりませんが、証明書を使用していた数週間前に書いた単純な安全なサービス用に app.config をどのように設定したかを振り返りました。サービスの構成を適切に構成するために行う必要があるかもしれないいくつかの考慮事項を次に示します。

<bindings>
    <wsHttpBinding>
        ...
        <security>
            <transport clientCredentialType="Certificate"  />
        </security>
    </wsHttpBinding>
</bindings>

これで、クライアントが側の証明書に何を使用するかをサービスに伝えるメタデータを提供するエンドポイントの動作が定義されました。

    <behaviors>
        <endpointBehaviors>
            <behavior name="ClientBehavior">
                        <clientCredentials>
                            <clientCertificate findValue="WcfClient" storeLocation="LocalMachine" storeName="My"
                 x509FindType="FindBySubjectName"/>
                            <serviceCertificate>
                                <authentication certificateValidationMode="PeerTrust" />
                            </serviceCertificate>
                        </clientCredentials>
                    </behavior>
        </endpointBehaviors>
    </behaviors>
于 2010-08-31T13:47:02.797 に答える