2012-03-30 59 views
0

我正在嘗試使用ws-security 1.2來使用WebLogic web服務。自定義綁定消費weblogic web服務ws-security 1.2

在WSDL,安全部分如下:

<wsp:UsingPolicy wssutil:Required="true"/> 
<wsp1_2:Policy wssutil:Id="Wssp1.2-2007-SignBody.xml"> 
<ns1:SignedParts xmlns:ns1="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702"> 
<ns1:Body/> 
</ns1:SignedParts> 
</wsp1_2:Policy> 
<wsp1_2:Policy wssutil:Id="Wssp1.2-2007-Wss1.0-X509-Basic256.xml"> 
<ns2:AsymmetricBinding xmlns:ns2="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702"> 
<wsp1_2:Policy> 
<ns2:InitiatorToken> 
<wsp1_2:Policy> 
<ns2:X509Token ns2:IncludeToken="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702/IncludeToken/AlwaysToRecipient"> 
<wsp1_2:Policy> 
<ns2:WssX509V3Token10/> 
</wsp1_2:Policy> 
</ns2:X509Token> 
</wsp1_2:Policy> 
</ns2:InitiatorToken> 
<ns2:RecipientToken> 
<wsp1_2:Policy> 
<ns2:X509Token ns2:IncludeToken="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702/IncludeToken/Never"> 
<wsp1_2:Policy> 
<ns2:WssX509V3Token10/> 
</wsp1_2:Policy> 
</ns2:X509Token> 
</wsp1_2:Policy> 
</ns2:RecipientToken> 
<ns2:AlgorithmSuite> 
<wsp1_2:Policy> 
<ns2:Basic256/> 
</wsp1_2:Policy> 
</ns2:AlgorithmSuite> 
<ns2:Layout> 
<wsp1_2:Policy> 
<ns2:Lax/> 
</wsp1_2:Policy> 
</ns2:Layout> 
<ns2:IncludeTimestamp/> 
<ns2:ProtectTokens/> 
<ns2:OnlySignEntireHeadersAndBody/> 
</wsp1_2:Policy> 
</ns2:AsymmetricBinding> 
<ns3:Wss10 xmlns:ns3="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702"> 
<wsp1_2:Policy> 
<ns3:MustSupportRefKeyIdentifier/> 
<ns3:MustSupportRefIssuerSerial/> 
</wsp1_2:Policy> 
</ns3:Wss10> 
</wsp1_2:Policy> 
<wsp:Policy wssutil:Id="Wssp1.2-2007-Wsp1.5-EncryptBody.xml"> 
<ns4:EncryptedParts xmlns:ns4="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702"> 
<ns4:Body/> 
</ns4:EncryptedParts> 
</wsp:Policy> 

很多搜​​索的,因爲我是新的WCF我結束了成以下的配置後:

<system.serviceModel> 
<client> 
    <endpoint name="wssMutualCert_Client" 
    address="https://..." 
    binding="customBinding" 
    bindingConfiguration="custom1" 
    contract="MyWebService.WebServicesMainMethod" 
    behaviorConfiguration="MutualCertBehavior"> 
    </endpoint> 
</client> 
<bindings> 
    <customBinding> 
     <binding name="custom1" closeTimeout="00:01:00" 
    openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"> 

      <textMessageEncoding messageVersion="Soap11" writeEncoding="UTF-8" /> 
      <security defaultAlgorithmSuite="Basic256" 
         authenticationMode="MutualCertificateDuplex" 
         includeTimestamp="True" 
         messageSecurityVersion="WSSecurity10WSTrustFebruary2005WSSecureConversationFebruary2005WSSecurityPolicy11BasicSecurityProfile10" 
         securityHeaderLayout="LaxTimestampLast" messageProtectionOrder="SignBeforeEncrypt"> 
       <localClientSettings maxClockSkew="00:07:00" /> 
       <localServiceSettings maxClockSkew="00:07:00" /> 
       <secureConversationBootstrap> 
        <localClientSettings maxClockSkew="00:07:00" /> 
        <localServiceSettings maxClockSkew="00:07:00" /> 
       </secureConversationBootstrap> 
      </security> 
      <context protectionLevel="EncryptAndSign"/> 
      <httpsTransport requireClientCertificate="true" maxBufferPoolSize="20000000" maxBufferSize="20000000" maxReceivedMessageSize="20000000"/> 
     </binding> 

    </customBinding> 
    <ws2007HttpBinding> 
     <binding name="wssMutualCertBinding"> 
      <security mode="TransportWithMessageCredential"> 
       <message clientCredentialType="Certificate"/> 
       <transport clientCredentialType="Certificate"/> 
      </security> 
     </binding> 
    </ws2007HttpBinding> 
</bindings> 
<behaviors> 
    <endpointBehaviors> 
     <behavior name="MutualCertBehavior"> 
      <clientCredentials> 
       <serviceCertificate> 
        <defaultCertificate 
         findValue="XXXXX" 
         storeLocation="LocalMachine" 
         storeName="TrustedPeople" x509FindType="FindByThumbprint"/> 
       </serviceCertificate> 
       <clientCertificate 
        findValue="YYYYY" 
        storeLocation="LocalMachine" 
        storeName="TrustedPeople" x509FindType="FindByThumbprint"/> 
      </clientCredentials> 
     </behavior> 
    </endpointBehaviors> 
</behaviors> 
<system.serviceModel> 

我測試appl看起來像如下:

static void Main(string[] args) 
{ 
    MyWebService.WebServicesMainMethodClient client = new WebServicesMainMethodClient("wssMutualCert_Client"); 
    MyWebService.webRequest request = new webRequest(); 
    ServicePointManager.ServerCertificateValidationCallback = RemoteCertificateValidationCallback; 

    try 
    { 
     webResponse response = client.retrieve(request); 
    } 
    catch (Exception e) 
    { 
     throw e; 
    } 
} 
public static bool RemoteCertificateValidationCallback(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors) 
{ 
    return true; 
} 

而且我試着在我的配置中改變什麼我接收ve以下內容:

An unsecured or incorrectly secured fault was received from the other party. See the inner FaultException for the fault code and detail. 

Server stack trace: 
    at  System.ServiceModel.Channels.SecurityChannelFactory`1.SecurityRequestChannel.ProcessReply  (Message reply, SecurityProtocolCorrelationState correlationState, TimeSpan timeout) 
at System.ServiceModel.Channels.SecurityChannelFactory`1.SecurityRequestChannel.Request  (Message message, TimeSpan timeout) 
    at System.ServiceModel.Dispatcher.RequestChannelBinder.Request(Message message,  TimeSpan timeout) 
    at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway,  ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout) 
    at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway,  ProxyOperationRuntime operation, Object[] ins, Object[] outs) 
    at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService (IMethodCallMessage methodCall, ProxyOperationRuntime operation) 
    at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message) 
Exception rethrown at [0]: 
    at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg) 
    at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type) 
    at Client.MyWebService.WebServicesMainMethod.retrieve(retrieve request) 

我一直在試圖找到一些有用的工具,差不多2天了。我研究過時間同步問題,證書問題。 任何想法或建議都會非常有幫助。 謝謝大家提前。

+0

請發佈一個示例工作肥皂(問一個來自供應商) – 2012-04-19 15:03:59

+0

如果你有類似的問題,可能值得看看這個SO問題如果你使用WCF那麼這個SO問題可以幫助你http:// stackoverflow。 com/questions/24635950/remove-timestamp-element-from-ws-security-headers-created-by-wcf – Ruskin 2014-07-11 08:17:34

回答

0

該錯誤表示SOAP請求WCF發送與weblogic安全性配置不兼容。通常WCF發送的時間戳和密碼是文本的問題,但非網絡服務通常需要摘要模式。沒有簡單的解決方案。閱讀thisthis。我降級到WSE 3.0以便能夠發送請求到基於Java的服務。這很容易實現。

+0

謝謝但我認爲WSE 3.0不支持ws-security 1.2 – 2012-03-30 14:09:12