2017-04-24 56 views
1

このトピックに関してはほとんど同じような質問がありましたが、本当に解決できないようです。要求が中止されました:SSL/TLSセキュアなチャネルを作成できませんでした - IllegalMessage

私は証明書認証で顧客のWebサービスに連絡する必要があります。プロンプトが表示されたら、適切な証明書を選択した後、SoapUIとChromeを使用して正常に動作します。しかし、私はIE、WCFクライアント、私自身でもWcfTestClientでもサービスを受けることができません。 OSはWindows server 2012 R2、プロトコルTLS 1.2

私はイベント、tracelogsを調査していますが、wiresharkのキャプチャを分析するとかなりの時間を費やしていますが、私は立ち往生しています。

致命的なアラートが生成され、リモートエンドポイントに送信されました:これは私が

イベントログを持っているものです。これにより、接続が切断されることがあります。 TLSプロトコルの定義された致命的なエラー・コードは10. WindowsのSChannelのエラー状態が12

トレースログである:

私は非興味深い部分を省略してのみ関連するものが表示されます。

System.Net Information: 0 : [12208] Connection#11144211 - Created connection 
    from 192.168.3.13:53514 to 145.119.167.109:443. 
System.Net Information: 0 : [12208] TlsStream#3957675::.ctor(host=aaa.bbb.eu, #certs=1) 
System.Net Information: 0 : [12208] Associating HttpWebRequest#37368736 with ConnectStream#35619075 
. 
. 
. 
System.Net Information: 0 : [12208] 
SecureChannel#52136226::.ctor(hostname=aaa.bbb.eu, #clientCertificates=1, encryptionPolicy=RequireEncryption) 
System.Net Information: 0 : [12208] Enumerating security packages: 
System.Net Information: 0 : [12208]  Negotiate 
System.Net Information: 0 : [12208]  NegoExtender 
System.Net Information: 0 : [12208]  Kerberos 
System.Net Information: 0 : [12208]  NTLM 
System.Net Information: 0 : [12208]  TSSSP 
System.Net Information: 0 : [12208]  pku2u 
System.Net Information: 0 : [12208]  WDigest 
System.Net Information: 0 : [12208]  Schannel 
System.Net Information: 0 : [12208]  Microsoft Unified Security Protocol Provider 
System.Net Information: 0 : [12208]  CREDSSP 
System.Net Information: 0 : [12208] SecureChannel#52136226 - Attempting to restart the session using the user-provided certificate: [HERE GOES DATA ABOUT CERTIFICATE] 
. 
. 
. 
System.Net Information: 0 : [12208] SecureChannel#52136226 - Left with 1 client certificates to choose from. 
System.Net Information: 0 : [12208] SecureChannel#52136226 - Trying to find a matching certificate in the certificate store. 
System.Net Information: 0 : [12208] SecureChannel#52136226 - Locating the private key for the certificate: [HERE GOES DATA ABOUT CERTIFICATE] 
. 
. 
. 
System.Net Information: 0 : [12208] SecureChannel#52136226 - Certificate is of type X509Certificate2 and contains the private key. 
System.Net Information: 0 : [12208] AcquireCredentialsHandle(package = Microsoft Unified Security Protocol Provider, intent = Outbound, scc  = System.Net.SecureCredential) 
System.Net Information: 0 : [12208] InitializeSecurityContext(credential = System.Net.SafeFreeCredential_SECURITY, context = (null), targetName = aaa.bbb.eu, inFlags = ReplayDetect, SequenceDetect, Confidentiality, AllocateMemory, InitManualCredValidation) 
System.Net Information: 0 : [12208] InitializeSecurityContext(In-Buffer length=0, Out-Buffer length=161, returned code=ContinueNeeded). 

の間で

System.Net.Sockets Verbose: 0 : [12208] Exiting Socket#33189039::Receive() -> Int32#2516 
System.Net Information: 0 : [12208] InitializeSecurityContext(credential = System.Net.SafeFreeCredential_SECURITY, context = cb00f8:7980678, targetName = aaa.bbb.eu, inFlags = ReplayDetect, SequenceDetect, Confidentiality, AllocateMemory, InitManualCredValidation) 
System.Net Information: 0 : [12208] InitializeSecurityContext(In-Buffers count=2, Out-Buffer length=0, returned code=ContinueNeeded). 
System.Net.Sockets Verbose: 0 : [12208] Socket#33189039::Receive() 
System.Net.Sockets Verbose: 0 : [12208] Data from Socket#33189039::Receive 

とその後いくつかの受信メッセージ、。そして最後に、問題。だから、

System.Net.Sockets Verbose: 0 : [12208] Exiting Socket#33189039::Receive() -> Int32#2839 
System.Net Information: 0 : [12208] InitializeSecurityContext(credential = System.Net.SafeFreeCredential_SECURITY, context = cb00f8:7980678, targetName = aaa.bbb.eu, inFlags = ReplayDetect, SequenceDetect, Confidentiality, AllocateMemory, InitManualCredValidation) 
System.Net Information: 0 : [12208] InitializeSecurityContext(In-Buffers count=2, Out-Buffer length=0, returned code=IllegalMessage). 
System.Net.Sockets Verbose: 0 : [12208] Socket#33189039::Dispose() 
System.Net Error: 0 : [12208] Exception in HttpWebRequest#37368736:: - The request was aborted: Could not create SSL/TLS secure channel.. 
System.Net Error: 0 : [12208] Exception in HttpWebRequest#37368736::GetResponse - The request was aborted: Could not create SSL/TLS secure channel.. 

、明らかに、私は正常に(ChromeとSOAPUIのためだけで結構です)提供されるクライアント証明書を読み、使用するのに十分な権利を持っています。 Wiresharkでネットワークのフローをチェックすると、クライアントのHelloとServer Helloが存在し、その後に証明書とサーバーの鍵交換メッセージが続きます。それから、クライアントからのACK RSTパケットと最終的には、サーバからのデコードされないパケットの多くが(おそらく、暗号化ハンドシェイクメッセージとしてWiresharkでマークされたコンテンツから)

これを引き起こす可能性のあるアイデアは非常に高く評価されます。

編集:追加のクライアントコードと構成

クライアントコード:

ServicePointManager.SetTcpKeepAlive(true, 10000, 1000); 
ServicePointManager.Expect100Continue = true; 
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; 

try 
{ 
    client = new IncidentBrokerPortTypeClient("gms_endpoint"); 
    client.EchoRequest(new EchoRequest());    
} 
catch (Exception ex) 
{ 
    MessageBox.Show(ex.Message + Environment.NewLine + ex.InnerException); 
} 

構成:

<?xml version="1.0" encoding="utf-8" ?> 
<configuration> 
<startup> 
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" /> 
</startup> 
<system.serviceModel> 
    <bindings> 
    <basicHttpsBinding> 
    <binding name="HttpsBasicBinding"> 
     <security mode="Transport" > 
     <transport clientCredentialType="Certificate"/> 
     </security> 
    </binding> 
</basicHttpsBinding> 
</bindings> 
<client> 
    <endpoint 
    name ="gms_endpoint" 
    address="https://aaa.bbb.eu/" 
    binding="basicHttpsBinding" 
    bindingConfiguration="HttpsBasicBinding" 
    contract="SomeNamespace.IncidentBrokerPortType" 
    behaviorConfiguration="GmsBehavior" 
     /> 
</client> 
<behaviors> 
    <endpointBehaviors> 
     <behavior name="GmsBehavior">    
      <clientCredentials> 
       <clientCertificate x509FindType="FindByThumbprint" 
findValue="5c1dd5c93d1854cb2d698451e1d2a78a3d94dcb0" 
storeLocation="LocalMachine"/> 
      </clientCredentials>     
     </behavior> 
    </endpointBehaviors> 
    </behaviors> 
</system.serviceModel> 
</configuration> 
+0

クロムブラウザとは異なり、WCFTestClientには、ユーザーにクライアント証明書の添付を促す機能はありません。また、明示的にコード化されない限り、カスタムクライアントにはその機能はありません。私はなぜIEがクライアント証明書を添付するよう促していないのだろうと思うが、 –

+0

WcfTestClientと私のカスタムテストクライアントの両方が与えられた証明書を使用するように構成されており、少なくともトレースログに基づいてそれを使ったカスタムのクライアントがあります。 –

+0

soapuiとchromeで期待どおりに動作するということは、サービスに間違いがないことです。その場合、カスタムクライアントコードを調べる必要があります。あなたはそれを投稿できますか? –

答えて

0

多分クライアントの設定に診断を追加すると、以下のようなものが役立ちます。

<?xml version="1.0" encoding="utf-8" ?> 
<configuration> 
    <startup> 
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" /> 
    </startup> 
    <!--diagnostics traces will be found in Web_messages.svclog file and Web_tracelog.svclog file--> 
    <system.diagnostics> 
    <sources> 
     <source name="System.ServiceModel.MessageLogging" switchValue="Warning, ActivityTracing"> 
     <listeners> 
      <add type="System.Diagnostics.DefaultTraceListener" name="Default"> 
      <filter type="" /> 
      </add> 
      <add name="ServiceModelMessageLoggingListener"> 
      <filter type="" /> 
      </add> 
     </listeners> 
     </source> 
     <source name="System.ServiceModel" switchValue="Warning,ActivityTracing" 
     propagateActivity="true"> 
     <listeners> 
      <add type="System.Diagnostics.DefaultTraceListener" name="Default"> 
      <filter type="" /> 
      </add> 
      <add name="ServiceModelTraceListener"> 
      <filter type="" /> 
      </add> 
     </listeners> 
     </source> 
    </sources> 
    <sharedListeners> 
     <add initializeData="Web_messages.svclog" type="System.Diagnostics.XmlWriterTraceListener, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" 
     name="ServiceModelMessageLoggingListener" traceOutputOptions="Timestamp"> 
     <filter type="" /> 
     </add> 
     <add initializeData="Web_tracelog.svclog" type="System.Diagnostics.XmlWriterTraceListener, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" 
     name="ServiceModelTraceListener" traceOutputOptions="Timestamp"> 
     <filter type="" /> 
     </add> 
    </sharedListeners> 
    <trace autoflush="true" /> 
    </system.diagnostics> 
    <system.serviceModel> 
    <!--Enable diagnostics to record wcf communication--> 
    <diagnostics wmiProviderEnabled="true"> 
     <messageLogging logEntireMessage="true" logMalformedMessages="true" logMessagesAtServiceLevel="true" logMessagesAtTransportLevel="true" /> 
    </diagnostics> 
    <bindings> 
     <basicHttpsBinding> 
     <binding name="HttpsBasicBinding"> 
      <security mode="Transport" > 
      <transport clientCredentialType="Certificate"/> 
      </security> 
     </binding> 
     </basicHttpsBinding> 
    </bindings> 
    <client> 
     <endpoint 
     name ="gms_endpoint" 
     address="https://aaa.bbb.eu/" 
     binding="basicHttpsBinding" 
     bindingConfiguration="HttpsBasicBinding" 
     contract="SomeNamespace.IncidentBrokerPortType" 
     behaviorConfiguration="GmsBehavior" 
     /> 
    </client> 
    <behaviors> 
     <endpointBehaviors> 
     <behavior name="GmsBehavior"> 
      <clientCredentials> 
      <clientCertificate x509FindType="FindByThumbprint" 
findValue="5c1dd5c93d1854cb2d698451e1d2a78a3d94dcb0" 
storeLocation="LocalMachine"/> 
      </clientCredentials> 
     </behavior> 
     </endpointBehaviors> 
    </behaviors> 
    </system.serviceModel> 
</configuration> 
+0

私はSystem.Net上で診断を行っていました( "Trace log"の部分の由来)。 Btw。私は前に.svclogsを使っていて、それはあまり記述的ではありませんでした –

関連する問題

 関連する問題