WCF의 basicHttpBinding에서 https를 사용하려고합니다. 서비스가 잘 실행되는 것 같지만 클라이언트를 실행하려고 할 때 서비스의 메소드 중 하나를 호출하면 다음 예외가 발생합니다.WCF의 basicHttpBinding을 통한 https
SSL/TLS 보안에 대한 신뢰 관계를 설정할 수 없습니다. 권위있는 'sfs-111 : 20023'채널.
아래 코드와 설정 파일을 포함 시켰습니다. 누군가가 도울 수 있다면, 나는 매우 감사 할 것입니다.
WCF를 처음 사용합니다.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ServiceModel;
using System.ServiceModel.Description;
namespace Alpha.Services.DeltaService
{
public class DeltaService : IDeltaService
{
public int timesTwo(int n)
{
return n * 2;
}
}
[ServiceContract]
interface IDeltaService
{
[OperationContract]
int timesTwo(int n);
}
public class App
{
public static void Main(string[] args)
{
//DeltaService service = new DeltaService();
ServiceHost serviceHost = new ServiceHost(typeof(DeltaService));
serviceHost.Open();
Console.WriteLine("Press any key to exit");
Console.ReadKey();
serviceHost.Close();
}
}
}
가 여기 내 클라이언트 코드 'S :
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.diagnostics>
<sources>
<source name="System.ServiceModel" switchValue="Information, ActivityTracing" propagateActivity="true">
<listeners>
<add name="traceListener" type="System.Diagnostics.XmlWriterTraceListener" initializeData="c:\tahseen\dd\WCFClient.svclog" />
</listeners>
</source>
</sources>
</system.diagnostics>
<system.serviceModel>
<!-- DEFINE SECURE BEHAVIOR -->
<behaviors>
<endpointBehaviors>
<behavior name="ClientBehavior">
<clientCredentials>
<clientCertificate findValue="sfs-Client" x509FindType="FindBySubjectName" storeLocation="LocalMachine" storeName="My" />
<serviceCertificate>
<authentication certificateValidationMode="PeerTrust"/>
</serviceCertificate>
</clientCredentials>
</behavior>
</endpointBehaviors>
</behaviors>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IDeltaService" 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" realm="" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="https://sfs-111:20023/DeltaService" binding="basicHttpBinding" behaviorConfiguration ="ClientBehavior"
bindingConfiguration="BasicHttpBinding_IDeltaService" contract="DeltaService.IDeltaService"
name="BasicHttpBinding_IDeltaService">
<identity>
<dns value="sfs-Test" />
</identity>
</endpoint>
</client>
</system.serviceModel>
</configuration>
가 여기 내 서비스 코드 'S :
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<!-- DEBUG - TURN ON TRACING -->
<system.diagnostics>
<sources>
<source name="System.ServiceModel" switchValue="Information, ActivityTracing" propagateActivity="true">
<listeners>
<add name="traceListener"
type="System.Diagnostics.XmlWriterTraceListener"
initializeData= "c:\tahseen\dd\WCFServer.svclog" />
</listeners>
</source>
</sources>
</system.diagnostics>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<!-- BEHAVIOR FOR META DATA -->
<behavior name="DeltaServiceBehavior">
<serviceMetadata httpGetEnabled="true" />
<serviceCredentials>
<windowsAuthentication includeWindowsGroups="false" allowAnonymousLogons="false" />
</serviceCredentials>
<dataContractSerializer maxItemsInObjectGraph="100000000" />
</behavior>
<!-- BEHAVIOR FOR TRANSPORT SECURITY -->
<behavior name="SecureBehavior">
<serviceMetadata httpGetEnabled="true"/>
<serviceCredentials>
<clientCertificate>
<authentication certificateValidationMode="PeerTrust" />
</clientCertificate>
<serviceCertificate findValue="sfs-Test" x509FindType="FindBySubjectName" storeLocation="LocalMachine" storeName="My" />
</serviceCredentials>
<dataContractSerializer maxItemsInObjectGraph="100000000" />
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<!-- DEFINE BINDING -->
<basicHttpBinding>
<binding name="HttpBinding_AlphaSystem">
<security mode="Transport">
<transport clientCredentialType="Certificate" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<services>
<!-- DEFINE SERVICE -->
<service behaviorConfiguration="SecureBehavior" name="Alpha.Services.DeltaService.DeltaService">
<!-- ENDPOINT FOR METADATA -->
<endpoint address="mex" binding="basicHttpBinding" bindingConfiguration="" contract="IMetadataExchange" />
<!-- ENDPOINT FOR DATA -->
<endpoint address="" binding="basicHttpBinding" bindingConfiguration="HttpBinding_AlphaSystem" contract="Alpha.Services.DeltaService.IDeltaService"/>
<!-- BASE ADDRESSES FOR SERVICE-->
<host>
<baseAddresses>
<add baseAddress="http://SFS-111:20022/DeltaService" />
<add baseAddress="https://SFS-111:20023/DeltaService" />
</baseAddresses>
</host>
</service>
</services>
</system.serviceModel>
</configuration>
가 여기 내 고객의 app.config있다 :
는 여기 MY 서비스의 app.config 'S
,210
가 동일한 시스템에서 실행되는 테스트 있습니까? Windows 인증서 저장소에 올바르게 구성된 인증서가 있습니까? HTTPS가 Windows 운영 체제에서 직접 처리되기 때문에 이러한 PeerTrust 설정은 HTTPS에서 작동하지 않습니다. –
인증서가 올바르게 구성되었는지 어떻게 확인합니까? 또한 PeerTrust가 작동하지 않는다면 어떻게 변경해야합니까? WCF와 인증서를 처음 접했으니 제 무지를 용서하십시오. – user1229458
해당 인증서에 자체 서명되어 있습니까? –