2016-06-28 82 views
0

.netクライアントからApache CXF 2.6 Webサービスを使用する必要があります。私は私のリクエストで送信していますヘッダは(シオマネキで撮影)このようなものです:セキュリティトークンを認証または承認できませんでした

<soap:Header> 
     <wsse:Security> 
      <wsse:BinarySecurityToken></wsse:BinarySecurityToken> 
      <ds:Signature ></ds:Signature> 

とサービスの応答:

:これは私の.configが

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> 
<soap:Header/> 
<soap:Body> 
    <soap:Fault> 
     <faultcode xmlns:ns1="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">ns1:FailedAuthentication</faultcode> 
     <faultstring>The security token could not be authenticated or authorized</faultstring> 
    </soap:Fault> 
</soap:Body> 

です

<system.serviceModel> 
    <bindings> 
     <customBinding> 
     <binding name="myCustomBinding"> 
      <security allowSerializedSigningTokenOnReply="true" enableUnsecuredResponse="true" 
      authenticationMode="MutualCertificate" securityHeaderLayout="Strict" 
      includeTimestamp="false" messageSecurityVersion="WSSecurity10WSTrustFebruary2005WSSecureConversationFebruary2005WSSecurityPolicy11BasicSecurityProfile10" 
      requireSignatureConfirmation="true" /> 
      <textMessageEncoding maxReadPoolSize="2147483647" messageVersion="Soap11"> 
      <readerQuotas maxDepth="32" maxStringContentLength="2147483647" 
       maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" /> 
      </textMessageEncoding> 
      <httpsTransport maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" 
      maxBufferSize="2147483647" requireClientCertificate="true" /> 
     </binding> 
     </customBinding> 
    </bindings>  
    </system.serviceModel> 

これは私のコードで私が私のプロキシオブジェクトを実装するところまで行ってきたことです:

public ConfigureProxy() 
{ 

    try { 


     CustomBinding customBinding = new CustomBinding("myCustomBinding"); 
     DnsEndpointIdentity oDNSEndPoint = new DnsEndpointIdentity(DNS);  
     EndpointAddress oEndPoint = new EndpointAddress(new Uri("Service"), oDNSEndPoint, new AddressHeaderCollection()); 
     StoreLocation oStore = StoreLocation.LocalMachine; 

     this.p_CanalProxy = new WSREACXFServiceClient(customBinding, oEndPoint); 

     ClientCredentials oCred = this.p_CanalProxy.ClientCredentials; 

     oCred.ClientCertificate.SetCertificate(oStore, StoreName.My, X509FindType.FindByThumbprint, "thumpr"); 

     if (oCred.ClientCertificate == null) 
      throw new InvalidOperationException("client cert "); 

     oCred.ServiceCertificate.SetDefaultCertificate(StoreLocation.LocalMachine, StoreName.My, X509FindType.FindByThumbprint, "thumpr sever cert"); 

     if (oCred.ServiceCertificate == null) 
      throw new InvalidOperationException("cert server "); 

     oCred.ServiceCertificate.Authentication.CertificateValidationMode = X509CertificateValidationMode.None; 
     oCred.ServiceCertificate.Authentication.RevocationMode = X509RevocationMode.NoCheck; 


    } catch (Exception ex) { 
     p_CanalProxy = null; 


    } finally { 

    } 
} 

しかし、私が持っている、それはそれはこのようにする必要が動作するようにとしたサンプルに基づいて:

<soap:Header> 
    <wsse:Security> 
     <wsse:BinarySecurityToken></wsse:BinarySecurityToken> 
     <ds:Signature ></ds:Signature>          
     <wsse:BinarySecurityToken></wsse:BinarySecurityToken> <!-- repeated --> 
     <xenc:EncryptedKey></xenc:EncryptedKey>   

誰も私を助けてくださいありませんか? ありがとうございます!

答えて

1

レスポンスに基づいて、証明書に問題が発生したようです。サービス側が証明書を認証できるかどうかを確認できます。

サービスホストされたサーバーとやり取りできない場合は、同じ証明書でSOAPクライアント(SoapUIなど)を使用して、応答を確認してください。そして、動作中のSOAPクライアント要求と生の要求メッセージの違いを確認してください。

関連する問題