SslStreamSecurityBindingElement 클래스

정의

SSL 스트림을 사용한 채널 보안을 지원하는 사용자 지정 바인딩 요소를 나타냅니다.

public ref class SslStreamSecurityBindingElement : System::ServiceModel::Channels::BindingElement
public ref class SslStreamSecurityBindingElement : System::ServiceModel::Channels::StreamUpgradeBindingElement
public ref class SslStreamSecurityBindingElement : System::ServiceModel::Channels::StreamUpgradeBindingElement, System::ServiceModel::Channels::ITransportTokenAssertionProvider, System::ServiceModel::Description::IPolicyExportExtension
public class SslStreamSecurityBindingElement : System.ServiceModel.Channels.BindingElement
public class SslStreamSecurityBindingElement : System.ServiceModel.Channels.StreamUpgradeBindingElement
public class SslStreamSecurityBindingElement : System.ServiceModel.Channels.StreamUpgradeBindingElement, System.ServiceModel.Channels.ITransportTokenAssertionProvider, System.ServiceModel.Description.IPolicyExportExtension
type SslStreamSecurityBindingElement = class
    inherit BindingElement
type SslStreamSecurityBindingElement = class
    inherit StreamUpgradeBindingElement
type SslStreamSecurityBindingElement = class
    inherit StreamUpgradeBindingElement
    interface ITransportTokenAssertionProvider
    interface IPolicyExportExtension
Public Class SslStreamSecurityBindingElement
Inherits BindingElement
Public Class SslStreamSecurityBindingElement
Inherits StreamUpgradeBindingElement
Public Class SslStreamSecurityBindingElement
Inherits StreamUpgradeBindingElement
Implements IPolicyExportExtension, ITransportTokenAssertionProvider
상속
SslStreamSecurityBindingElement
상속
SslStreamSecurityBindingElement
구현

설명

TCP 및 명명된 파이프와 같은 스트림 지향 프로토콜을 사용하는 전송은 스트림 기반 전송 업그레이드를 지원합니다. 특히 WCF(Windows Communication Foundation)는 보안 업그레이드를 제공합니다. 이 전송 보안의 구성은 구성하여 사용자 지정 바인딩에 추가할 수 있는 SslStreamSecurityBindingElement 및 이 클래스에 의해 캡슐화됩니다. 또한 제3자가 사용자 지정 StreamSecurityBindingElement를 직접 작성할 수 있습니다. 이러한 바인딩 요소는 클라이언트 및 서버 스트림 업그레이드 공급자를 빌드하기 위해 호출되는 StreamUpgradeBindingElement 클래스를 확장합니다.

사용자 지정 바인딩에는 특정 순서로 정렬된 바인딩 요소 컬렉션이 포함됩니다. 바인딩 스택의 최상위를 나타내는 요소가 가장 먼저 추가되고, 그 다음 요소가 두 번째로 추가되며 나머지 요소도 차례대로 추가됩니다.

바인딩에 이 클래스를 추가하려면

  1. BindingElementCollection를 만듭니다.

  2. 선택적인 TransactionFlowBindingElementReliableSessionBindingElement처럼 바인딩 스택에서 이 바인딩 요소의 위에 오는 사용자 지정 바인딩 요소를 만듭니다.

  3. BindingElementCollection 메서드를 사용하여 생성된 요소를 위에서 설명한 순서대로 InsertItem에 추가합니다.

  4. SslStreamSecurityBindingElement의 인스턴스를 만들어 컬렉션에 추가합니다.

  5. TcpTransportBindingElement와 같은 추가 사용자 지정 바인딩 요소를 컬렉션에 추가합니다.

WSDL을 가져온 후 클라이언트 엔드포인트에서 올바른 UPN/SPN을 수동으로 지정하거나 클라이언트의 SslStreamSecurityBindingElement에서 사용자 지정 IdentityVerifier 을 지정해야 하는 세 가지 시나리오가 있습니다.

  1. WSDL에 게시된 서비스 ID가 없습니다. SspiNegotiatedOverTransport 및 HTTPS가 사용됩니다(예: SecurityMode = WSHttpBindingTransportWithMessageCredential). 서비스가 컴퓨터 ID를 사용하여 실행되고 있지 않은 경우 WSDL을 가져온 후 클라이언트 엔드포인트에서 수동으로 올바른 UPN/SPN을 지정해야 합니다.

  2. DNS 서비스 ID는 WSDL에 게시됩니다. UPN/SPN 대신 SspiNegotiatedOverTransportSslStreamSecurityBindingElement가 사용됩니다(예: SecurityMode = NetTcpBindingTransportWithMessageCredential). 서비스가 컴퓨터 ID를 사용하여 실행되고 있지 않거나 DNS ID가 컴퓨터 ID가 아닌 경우 WSDL을 가져온 후 클라이언트 엔드포인트에서 수동으로 올바른 UPN/SPN을 지정해야 합니다.

  3. WSDL에 DNS ID가 게시되었습니다. 클라이언트에서 SslStreamSecurityBindingElement가 재정의되는 경우 클라이언트의 IdentityVerifier에서 사용자 지정 SslStreamSecurityBindingElement를 지정해야 합니다.

다음 코드에서는 클라이언트 엔드포인트에서 수동으로 올바른 UPN/SPN을 지정하는 방법과 클라이언트의 IdentityVerifier에서 사용자 지정 SslStreamSecurityBindingElement를 지정하는 방법을 보여 줍니다.

using System;  
using System.Collections.Generic;  
using System.Linq;  
using System.Net;  
using System.IdentityModel.Claims;  
using System.IdentityModel.Policy;  
using System.Security.Cryptography.X509Certificates;  
using System.ServiceModel;  
using System.ServiceModel.Channels;  
using System.ServiceModel.Description;  
using System.ServiceModel.Security;  
using System.Xml;  

namespace ServiceNamespace  
{  
    [ServiceContract]  
    interface IService  
    {  
        [OperationContract]  
        void DoSomething();  
    }  

    class DnsIdentityVerifier : IdentityVerifier  
    {  
        DnsEndpointIdentity _expectedIdentity;  

        public DnsIdentityVerifier(EndpointAddress serviceEndpoint)  
        {  
            _expectedIdentity = new DnsEndpointIdentity(serviceEndpoint.Uri.DnsSafeHost);  
        }  

        public override bool CheckAccess(EndpointIdentity identity, AuthorizationContext authContext)  
        {  
            Claim dnsClaim = authContext.Claims().Single(claim => claim.ClaimType == ClaimTypes.Dns);  
            return String.Equals(_expectedIdentity.IdentityClaim.Resource, dnsClaim.Resource);  
        }  

        public override bool TryGetIdentity(EndpointAddress reference, out EndpointIdentity identity)  
        {  
            identity = _expectedIdentity;  
            return true;  
        }  
    }  

    static class LinqExtensionForClaims  
    {  
        public static IEnumerable<Claim> Claims(this AuthorizationContext authContext)  
        {  
            if (null != authContext.ClaimSets)  
            {  
                foreach (ClaimSet claimSet in authContext.ClaimSets)  
                {  
                    if (null != claimSet)  
                    {  
                        foreach (Claim claim in claimSet)  
                        {  
                            yield return claim;  
                        }  
                    }  
                }  
            }  
        }  
    }  

    class Service : IService  
    {  
        public void DoSomething()  
        {  
            Console.WriteLine("Service called.");  
        }  
    }  

    class Program  
    {  
        static void Main(string[] args)  
        {  
            string hostname = Dns.GetHostEntry(String.Empty).HostName;  
            NetTcpBinding serviceBinding = new NetTcpBinding(SecurityMode.TransportWithMessageCredential);  

            ServiceHost serviceHost = new ServiceHost(typeof(Service), new Uri(String.Format("net.tcp://{0}:8080/Service", hostname)));  
            serviceHost.Credentials.ServiceCertificate.SetCertificate(StoreLocation.LocalMachine, StoreName.My, X509FindType.FindByThumbprint, "8a 42 1b eb cf 8a 14 b1 de 83 d9 a5 70 88 0a 62 f9 bf 69 06");  
            ServiceEndpoint serviceEndpoint = serviceHost.AddServiceEndpoint(typeof(IService), serviceBinding, "Endpoint");  
            serviceHost.Open();  

            CustomBinding clientBinding = new CustomBinding(serviceBinding.CreateBindingElements());  
            SslStreamSecurityBindingElement sslStream = clientBinding.Elements.Find<SslStreamSecurityBindingElement>();  
            sslStream.IdentityVerifier = new DnsIdentityVerifier(serviceEndpoint.Address);  

            ChannelFactory<IService> channelFactory = new ChannelFactory<IService>(clientBinding, new EndpointAddress(serviceEndpoint.Address.Uri, UpnEndpointIdentity.CreateUpnIdentity("username@domain")));  
            channelFactory.Credentials.Windows.AllowNtlm = false;  
            IService channel = channelFactory.CreateChannel();  
            channel.DoSomething();  
        }  
    }  

생성자

SslStreamSecurityBindingElement()

SslStreamSecurityBindingElement 클래스의 새 인스턴스를 초기화합니다.

SslStreamSecurityBindingElement(SslStreamSecurityBindingElement)

다른 SslStreamSecurityBindingElement의 값을 사용하여 SslStreamSecurityBindingElement 클래스의 새 인스턴스를 초기화합니다.

속성

IdentityVerifier

이 바인딩에 대한 ID 검증 도구를 가져오거나 설정합니다.

RequireClientCertificate

이 바인딩에 클라이언트 인증서가 필요한지 여부를 지정하는 값을 가져오거나 설정합니다.

SslProtocols

TcpClientCredentialType.Certificate의 클라이언트 자격 증명 형식을 사용하는 경우 협상할 SSL/TLS 프로토콜 목록을 지정합니다. 값은 열거형 멤버 Ssl3, Tls, Tls11, Tls12 중 하나 이상의 조합이 될 수 있습니다.

메서드

BuildChannelFactory<TChannel>(BindingContext)

지정된 형식의 채널 팩터리를 만듭니다.

BuildChannelListener<TChannel>(BindingContext)

지정된 형식의 채널 수신기를 만듭니다.

BuildChannelListener<TChannel>(BindingContext)

바인딩 컨텍스트를 사용하여 지정된 형식의 채널을 수락하기 위해 채널 수신기를 초기화합니다.

(다음에서 상속됨 BindingElement)
BuildClientStreamUpgradeProvider(BindingContext)

제공된 채널 컨텍스트를 기반으로 StreamUpgradeProvider의 클라이언트에서 인스턴스를 만듭니다.

BuildServerStreamUpgradeProvider(BindingContext)

제공된 채널 컨텍스트를 기반으로 StreamUpgradeProvider의 서버에서 인스턴스를 만듭니다.

BuildServerStreamUpgradeProvider(BindingContext)

제공된 채널 컨텍스트를 기반으로 StreamUpgradeProvider의 서버에서 인스턴스를 만듭니다.

(다음에서 상속됨 StreamUpgradeBindingElement)
CanBuildChannelFactory<TChannel>(BindingContext)

지정된 형식의 채널 팩터리를 생성할 수 있는지 여부를 나타내는 값을 가져옵니다.

CanBuildChannelListener<TChannel>(BindingContext)

지정된 형식의 채널 수신기를 생성할 수 있는지 여부를 나타내는 값을 가져옵니다.

CanBuildChannelListener<TChannel>(BindingContext)

바인딩 요소에서 특정 채널 형식에 대한 수신기를 만들 수 있는지 여부를 나타내는 값을 반환합니다.

(다음에서 상속됨 BindingElement)
Clone()

현재 인스턴스의 복사본인 새 인스턴스를 만듭니다.

Equals(Object)

지정된 개체가 현재 개체와 같은지 확인합니다.

(다음에서 상속됨 Object)
GetHashCode()

기본 해시 함수로 작동합니다.

(다음에서 상속됨 Object)
GetProperty<T>(BindingContext)

BindingContext에서 지정된 개체를 가져옵니다.

GetTransportTokenAssertion()

보안 바인딩에서 사용되는 전송 토큰을 나타내는 XmlElement를 가져옵니다.

GetType()

현재 인스턴스의 Type을 가져옵니다.

(다음에서 상속됨 Object)
MemberwiseClone()

현재 Object의 단순 복사본을 만듭니다.

(다음에서 상속됨 Object)
ShouldSerializeIdentityVerifier()

식별 검증 도구를 직렬화해야 하는지 표시하는 값을 가져옵니다.

ToString()

현재 개체를 나타내는 문자열을 반환합니다.

(다음에서 상속됨 Object)

명시적 인터페이스 구현

IPolicyExportExtension.ExportPolicy(MetadataExporter, PolicyConversionContext)

바인딩에 대한 사용자 지정 정책 어설션을 내보냅니다.

적용 대상