2010-05-26 7 views
0

WCF를 사용하여 타사의 Oracle Application Server에서 제공하는 웹 서비스를 사용하려고합니다. 요청의 일부로 UsernameToken에 사용자 이름과 암호를 전달하고 응답의 일부로 웹 서비스는 헤더에 다이제스트 및 서명이 포함 된 표준 보안 태그를 반환합니다.응답에서 UserName 자격 증명을 사용하도록 WCF 클라이언트 구성 요청 및 인증서 자격 증명 확인

현재 설정으로는 서버에 요청을 성공적으로 보내고 웹 서비스는 예상 응답 데이터를 되돌려 보냅니다. 그러나 응답을 구문 분석 할 때 WCF는 MessageSecurityException을 throw하고 InnerException.Message가 "토큰 서명을 지원하지 않습니다."라는 메시지를 표시합니다.

내 생각에 WCF가 서명을 처리하고 확인하도록 WCF에서 구성하기를 원합니다. 인증서를 확인하는 데 사용할 수 있어야하는 웹 서비스를 호스팅하는 제 3 자의 인증서가 있습니다. 필요한 경우 확실하지 않습니다.

<?xml version="1.0" encoding="UTF-8"?> 
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> 
    <soap:Header> 
    <wsse:Security soap:mustUnderstand="1" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"> 
     <dsig:Signature xmlns="http://www.w3.org/2000/09/xmldsig#" xmlns:dsig="http://www.w3.org/2000/09/xmldsig#"> 
     <dsig:SignedInfo> 
      <dsig:CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/> 
      <dsig:SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1"/> 
      <dsig:Reference URI="#_51IUwNWRVvPOcz12pZHLNQ22"> 
      <dsig:Transforms> 
       <dsig:Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/> 
      </dsig:Transforms> 
      <dsig:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/> 
      <dsig:DigestValue> 
       [DigestValue here] 
      </dsig:DigestValue> 
      </dsig:Reference> 
      <dsig:Reference URI="#_dI5j0EqxrVsj0e62J6vd6w22"> 
      <dsig:Transforms> 
       <dsig:Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/> 
      </dsig:Transforms> 
      <dsig:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/> 
      <dsig:DigestValue> 
       [DigestValue here] 
      </dsig:DigestValue> 
      </dsig:Reference> 
     </dsig:SignedInfo> 
     <dsig:SignatureValue> 
      [Signature Value Here] 
     </dsig:SignatureValue> 
     <dsig:KeyInfo> 
      <wsse:SecurityTokenReference xmlns="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"> 
      <wsse:Reference URI="#BST-9nKWbrE4LRv6maqstrGuUQ22" ValueType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#X509v3"/> 
      </wsse:SecurityTokenReference> 
     </dsig:KeyInfo> 
     </dsig:Signature> 
     <wsse:BinarySecurityToken ValueType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#X509v3" EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary" wsu:Id="BST-9nKWbrE4LRv6maqstrGuUQ22" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"> 
     [Security Token Here] 
     </wsse:BinarySecurityToken> 
     <wsu:Timestamp wsu:Id="_dI5j0EqxrVsj0e62J6vd6w22" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"> 
     <wsu:Created>2010-05-26T18:46:30Z</wsu:Created> 
     </wsu:Timestamp> 
    </wsse:Security> 
    </soap:Header> 
    <soap:Body wsu:Id="_51IUwNWRVvPOcz12pZHLNQ22" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"> 
    [Body content here] 
    </soap:Body> 
</soap:Envelope> 

내 바인딩 구성 보이는 같은 :

<basicHttpBinding> 
    <binding name="myBinding" 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="TransportWithMessageCredential"> 
     <transport clientCredentialType="None" proxyCredentialType="None" realm="" /> 
     <message clientCredentialType="UserName" algorithmSuite="Default" /> 
    </security> 
    </binding> 
</basicHttpBinding> 

나는 기본적으로 내가 WCF를 구성한다 무엇을해야한다고 생각 여기

는 WCF는 예외를 발생하게하는 응답의 샘플 헤더의 요청에 UserName 클라이언트 자격 증명을 사용하고 응답에 인증서 클라이언트 자격 증명을 사용합니다. 나는 어떻게 이런 일을해야할지 모르겠다.

저는 WCF에서 새로 왔으므로, 이것이 바보 같은 질문이라면 유감입니다. 나는 Google 솔루션을 시도했지만 WCF를 구성하는 방법이 너무 많아서 압도적 인 상황입니다.

미리 감사드립니다.

답변

1

관심있는 사람이라면 WCF가 처리 할 수 ​​있기 전에 응답 메시지를 가로 채기 위해 CustomMessageEncoder (this MSDN article의 도움으로)를 만들어이 문제를 해결할 수있었습니다. 거기에서 BinarySecurityToken 및 Signature 요소를 WCF로 전달하기 전에 응답에서 제거했습니다. 스트림에서 문제가되는 요소를 제거하기 위해 다음 방법을 사용했습니다.

private Stream RemoveSignatures(Stream stream) 
    { 
     XmlDocument doc = new XmlDocument(); 
     doc.Load(stream); 

     XmlNamespaceManager nsMgr = new XmlNamespaceManager(doc.NameTable); 
     nsMgr.AddNamespace("soap", "http://schemas.xmlsoap.org/soap/envelope/"); 
     nsMgr.AddNamespace("dsig", "http://www.w3.org/2000/09/xmldsig#"); 
     nsMgr.AddNamespace("wsse", "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"); 

     XmlNode signatureNode = doc.SelectSingleNode("/soap:Envelope/soap:Header/wsse:Security/dsig:Signature", nsMgr); 
     XmlNode binarySecurityTokenNode = doc.SelectSingleNode("/soap:Envelope/soap:Header/wsse:Security/wsse:BinarySecurityToken", nsMgr); 
     XmlNode headerNode = doc.SelectSingleNode("/soap:Envelope/soap:Header/wsse:Security", nsMgr); 

     headerNode.RemoveChild(signatureNode); 
     headerNode.RemoveChild(binarySecurityTokenNode); 

     return new MemoryStream(new UTF8Encoding().GetBytes(doc.OuterXml)); 
    } 

분명히 이것은 최고의 해결책이 아닙니다. 그것은 매우 '해킹'입니다. 그러나 작동하고 필요하다면 메시지 보안이 이미 HTTPS 전송에 의해 처리되기 때문에 계속 사용할 수 있습니다.

누구든지이 문제를 해결하는 더 좋은 방법을 말할 수 있다면 열려 있습니다.

0

서비스와 같은 것 같은데 서비스를 제공하는 장소에서 자격 증명을 기다리고 있지 않습니다. 대신 전송 레벨의 사용자 이름과 암호를 지정하십시오.

+0

서비스가 지금 설정 한 방식으로 메시지에 내 자격 증명을 허용합니다. 요청을 보내고 WCF가 올바른 응답을받습니다. 문제는 WCF가 응답의 서명을 처리하지 못하는 것입니다. – AlEl

관련 문제