ReliableSessionOverHttps 샘플은 Reliable Sessions에서 SSL 전송 보안을 사용하는 방법을 보여 줍니다. 신뢰할 수 있는 세션은 WS-Reliable 메시징 프로토콜을 구현합니다. Reliable Sessions을 통해 WS-Security를 작성하여 안전하고 신뢰할 수 있는 세션을 확보할 수 있습니다. 그러나 SSL에서 HTTP 전송 보안을 대신 사용하도록 선택할 수 있는 경우도 있습니다.
샘플 세부 정보
SSL은 패킷 자체가 보호되도록 합니다. 이는 WS-Secure Conversation를 사용하여 신뢰할 수 있는 세션을 보호하는 것과는 다릅니다.
HTTPS를 통해 신뢰할 수 있는 세션을 사용하려면 사용자 지정 바인딩을 만들어야 합니다. 이 샘플은 계산기 서비스를 구현하는 시작 서비스를 기반으로 합니다. 사용자 지정 바인딩은 신뢰할 수 있는 세션 바인딩 요소 및 httpsTransport<를> 사용하여 만들어집니다. 다음 구성은 사용자 지정 바인딩입니다.
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<services>
<service
name="Microsoft.ServiceModel.Samples.CalculatorService"
behaviorConfiguration="CalculatorServiceBehavior">
<!-- use base address provided by host -->
<endpoint address=""
binding="customBinding"
bindingConfiguration="reliableSessionOverHttps"
contract="Microsoft.ServiceModel.Samples.ICalculator" />
<!-- the mex endpoint is exposed as http://localhost/servicemodelsamples/service.svc/mex-->
<endpoint address="mex"
binding="mexHttpBinding"
contract="IMetadataExchange"/>
</service>
</services>
<bindings>
<customBinding>
<binding name="reliableSessionOverHttps">
<reliableSession />
<httpsTransport />
</binding>
</customBinding>
</bindings>
<!--For debugging purposes set the includeExceptionDetailInFaults attribute to true-->
<behaviors>
<serviceBehaviors>
<behavior name="CalculatorServiceBehavior">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="False" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
샘플의 프로그램 코드는 시작 서비스의 코드와 동일합니다. 샘플을 빌드하고 실행하기 전에 웹 서버 인증서 마법사를 사용하여 인증서를 만들고 할당해야 합니다. 구성 파일 설정의 엔드포인트 정의 및 바인딩 정의를 사용하면 클라이언트에 대한 다음 샘플 구성에 표시된 대로 사용자 지정 바인딩을 사용할 수 있습니다.
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<client>
<!-- this endpoint has an https: address -->
<endpoint name=""
address="https://localhost/servicemodelsamples/service.svc"
binding="customBinding"
bindingConfiguration="reliableSessionOverHttps"
contract="Microsoft.ServiceModel.Samples.ICalculator" />
</client>
<bindings>
<customBinding>
<binding name="reliableSessionOverHttps">
<reliableSession />
<httpsTransport />
</binding>
</customBinding>
</bindings>
</system.serviceModel>
</configuration>
지정된 주소는 스키마를 https://
사용합니다.
이 샘플에서 사용되는 인증서는 Makecert.exe사용하여 만든 테스트 인증서이므로 브라우저에서 https: 주소(예: https://localhost/servicemodelsamples/service.svc
주소)에 액세스하려고 하면 보안 경고가 나타납니다. WCF(Windows Communication Foundation) 클라이언트가 테스트 인증서를 사용할 수 있도록 보안 경고를 표시하지 않는 일부 추가 코드가 클라이언트에 추가되었습니다. 프로덕션 인증서를 사용할 때는 이 코드와 함께 제공되는 클래스가 필요하지 않습니다.
// This code is required only for test certificates like those created by Makecert.exe.
PermissiveCertificatePolicy.Enact("CN=ServiceModelSamples-HTTPS-Server");
샘플을 실행하면 작업 요청 및 응답이 클라이언트 콘솔 창에 표시됩니다. 클라이언트 창에서 Enter 키를 눌러 클라이언트를 종료합니다.
Add(100,15.99) = 115.99
Subtract(145,76.54) = 68.46
Multiply(9,81.25) = 731.25
Divide(22,7) = 3.14285714285714
Press <ENTER> to terminate client.
샘플을 설정, 빌드 및 실행하려면
다음 명령을 사용하여 ASP.NET 4.0을 설치합니다.
%windir%\Microsoft.NET\Framework\v4.0.XXXXX\aspnet_regiis.exe /i /enable
Windows Communication Foundation 샘플 에 대한One-Time 설정 절차를 수행했는지 확인합니다.
IIS(인터넷 정보 서비스) 서버 인증서 설치 지침을 수행했는지 확인합니다.
솔루션의 C# 또는 Visual Basic .NET 버전을 빌드하려면 Windows Communication Foundation 샘플빌드의 지침을 따릅니다.
단일 또는 컴퓨터 간 구성에서 샘플을 실행하려면 Windows Communication Foundation 샘플실행의 지침을 따릅니다.