1
我是WCF的新手。我爲客戶端創建了一個自託管的WCF服務器,它是一個Java休息客戶端。客戶端與服務器之間的通信應通過兩端的SSL證書相互認證。因此,在通信期間,客戶端需要發送證書。客戶端證書需要在服務器上自定義驗證。 我認爲單向通信正常,但服務器無法驗證客戶端證書。實際上,自定義驗證程序代碼並未執行。WCF 2路ssl不工作
在服務器的痕跡,我看「配置評價方面沒有發現」了兩次,想有一個與配置文件中的一些問題
我的配置文件如下:
<configuration>
<system.diagnostics>
<sources>
<source name="System.ServiceModel"
switchValue="All, ActivityTracing"
propagateActivity="true">
<listeners>
<add name="xml" />
</listeners>
</source>
</sources>
<sharedListeners>
<add name="xml" type="System.Diagnostics.XmlWriterTraceListener" initializeData="C:\log\Traces.svclog" />
</sharedListeners>
<trace autoflush="true"/>
</system.diagnostics>
<system.serviceModel>
<bindings>
<customBinding>
<binding name="mybinding">
<transactionFlow />
<textMessageEncoding />
<httpsTransport requireClientCertificate="true" />
<security authenticationMode="MutualSslNegotiated"/>
</binding>
</customBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="behaviour">
<serviceMetadata httpsGetEnabled="True"/>
<serviceDebug includeExceptionDetailInFaults="true" />
<serviceCredentials>
<clientCertificate>
<authentication certificateValidationMode="Custom" customCertificateValidatorType="myproject.MyX509CertificateValidator,myproject"/>
</clientCertificate>
</serviceCredentials>
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service name="myHost" behaviorConfiguration="behaviour">
<endpoint address="" contract="IIWCFServer" binding="customBinding" bindingConfiguration="mybinding" />
<endpoint address="mex" contract="IMetadataExchange" binding="mexHttpsBinding"/>
</service>
</services>
<diagnostics>
<messageLogging logEntireMessage="true"
logMessagesAtServiceLevel="true"
logMessagesAtTransportLevel="true"
logMalformedMessages="true"
maxMessagesToLog="5000"
maxSizeOfMessageToLog="2000">
</messageLogging>
</diagnostics>
</system.serviceModel>
</configuration>
我已經經歷了100秒的文章,但無法獲得解決方案。任何建議都會有所幫助。
來自XML的異常的細節如下。如果我能從其他地方獲得錯誤信息,請告訴我。
<E2ETraceEvent xmlns="http://schemas.microsoft.com/2004/06/E2ETraceEvent">
<System xmlns="http://schemas.microsoft.com/2004/06/windows/eventlog/system">
<EventID>524312</EventID>
<Type>3</Type>
<SubType Name="Warning">0</SubType>
<Level>4</Level>
<TimeCreated SystemTime="2014-04-21T09:09:53.2168282Z" />
<Source Name="System.ServiceModel" />
<Correlation ActivityID="{28fb55cc-1d5f-4a5a-a76e-5939a733b8f1}" />
<Execution ProcessName="testServer.vshost" ProcessID="2368" ThreadID="9" />
<Channel />
<Computer>WGP-PRINT-145</Computer>
</System>
<ApplicationData>
<TraceData>
<DataItem>
<TraceRecord xmlns="http://schemas.microsoft.com/2004/10/E2ETraceEvent/TraceRecord" Severity="Warning">
<TraceIdentifier>http://msdn.microsoft.com/en-IN/library/System.ServiceModel.EvaluationContextNotFound.aspx</TraceIdentifier>
<Description>Configuration evaluation context not found.</Description>
<AppDomain>testServer.vshost.exe</AppDomain>
</TraceRecord>
</DataItem>
</TraceData>
</ApplicationData>
</E2ETraceEvent>
您可以包括異常的細節?請參閱[找不到配置評估上下文](http://stackoverflow.com/questions/3636341/configuration-evaluation-context-not-found-warning-on-wcf-trace)。您是否嘗試在配置中給出端點地址(因爲mex端點需要主機基地址)?任何使用authenticationMode =「MutualSslNegotiated」的原因,而不是authenticationMode =「MutualCertificate」? – dera
感謝您的答覆,其實,我不是很清楚authenticationMode =「MutualCertificate/MutualCertificateDuplex/MutualSslNegotiated」之間的區別。我嘗試使用其他選項,但得到了相同的結果。 – Utkarsh
您如何調用WCF服務?如何在客戶端添加證書?你能指定客戶端綁定,配置等嗎?您可以使用Fiddler或Soap UI等工具來實際查看對您服務的調用 – dera