2011-05-09 5 views
3

WS-Addressing, WS-Security 및 TLS가 포함 된 SOAP 1.1 요청을 작성하기 위해 WCF 클라이언트를 구성하려고합니다.어떻게 WCF가 TimeStamp 헤더에만 서명하도록 구성 할 수 있습니까?

보안 요구 사항은 메시지에 Username Token, TimeStamp가 포함되어 있고 TimeStamp가 포함 된 BinarySecurityToken을 사용하여 서명되어 있어야합니다.

다음 예제의 예제를 사용하여 link을 작성하여 WCF 클라이언트 바인딩을 작성했습니다. HTTPS가 전송 메커니즘으로 사용되고 MessageSecurity가 UsernameOverTransport를 기반으로하도록 예제를 약간 수정했습니다 (아래 참조). 해결하기 위해 타임 스탬프 주소뿐만 아니라 서명되고 :

  HttpsTransportBindingElement httpsTransport = new HttpsTransportBindingElement();    
     // the message security binding element will be configured to require 2 tokens: 
     // 1) A username-password encrypted with the service token 
     // 2) A client certificate used to sign the message 

     // Instantiate a binding element that will require the username/password token in the message (encrypted with the server cert) 
     TransportSecurityBindingElement messageSecurity = SecurityBindingElement.CreateUserNameOverTransportBindingElement(); 

     // Create supporting token parameters for the client X509 certificate. 
     X509SecurityTokenParameters clientX509SupportingTokenParameters = new X509SecurityTokenParameters(); 
     // Specify that the supporting token is passed in message send by the client to the service 
     clientX509SupportingTokenParameters.InclusionMode = SecurityTokenInclusionMode.AlwaysToRecipient; 
     // Turn off derived keys 
     clientX509SupportingTokenParameters.RequireDerivedKeys = false; 
     // Augment the binding element to require the client's X509 certificate as an endorsing token in the message 
     messageSecurity.EndpointSupportingTokenParameters.Endorsing.Add(clientX509SupportingTokenParameters); 

     // Create a CustomBinding based on the constructed security binding element. 
     return new CustomBinding(messageSecurity, httpsTransport); 

이 클라이언트에 의해 생성 된 SOAP 메시지

내가 전화하고 서비스의 요구 사항을 충족 매우 가까운, 유일한 문제는 WSA가 있다는 것입니다.

정확하게 WCF 헤더에 서명을 지정하는 방법이 있습니까? 클라이언트를 제한해야하므로 TimeStamp 헤더에만 서명하십시오. 이 작업을 수행 할 수있는 사용자 정의 메시지 헤더와

답변

0

:

//... rest of MessageContract 

[MessageHeader(ProtectionLevel = ProtectionLevel.Sign)] 
string MyCustomHeader; 

//... rest of MessageContract 

하지만 난 당신이 사용자 정의 바인딩에 의해 삽입되는 SOAP 헤더에 서명을 시도하기 때문에 그 상황에서 작동 믿지 않는다. 이러한 헤더를 수정하려면 IClientMessageInspector interface을 구현하고 클라이언트 구성에 사용자 지정 동작을 추가하여 TimeStamp 헤더에 서명해야 할 수 있습니다. 서명을하기 위해 인증서에 액세스하는 방법을 잘 모름 this may give you a good start.

+0

다음 링크 http://msdn.microsoft에서 인프라 데이터로 참조되는 TimeStamp에 서명하려고 할 때 ProtectionLevel 설정을 사용할 수 없습니다. .com/ko-us/library/aa347692.aspx # Y1432. 어떻게 되겠습니까? – Edward

+0

답변에서 IClientMessageInspector 링크를 확인하십시오. 비누 메시지를 서비스에 보내기 전에 수정하는 방법을 보여줍니다. BeforeSendRequest 메서드에서 모든 비누 헤더에 액세스 할 수 있습니다. wsa : To 헤더 항목에 디지털 서명을하고 비누 메시지에 기존 항목을 덮어 쓰는 방법을 알아내는 것만으로도 충분합니다 (이것은 아마도 어려운 부분 일 것입니다). –

+1

내가 가진 문제는 WCF 바인딩이 wsa : To와 wsu : TimeStamp에 모두 서명한다는 것입니다. wsu : TimeStamp 만 서명하면됩니다. 기존 서명을 바꾸기 위해 수동으로 메시지를 조작 할 수 있지만 SOAP 메시지에서 수행하는 사용자 지정 조작의 양을 최소화하고 싶습니다. 저는 Soap11WSAddressing10 대신에 soap11로 messageVersion을 지정하고 수동으로 서명 메커니즘을 구현할 필요가 없도록 나중에 수동으로 WS-Addresing 헤더를 추가하여이 작업을 처리했습니다. – Edward

관련 문제