0
我需要使用通過https連接暴露的Web服務,該服務由給予我證書(.pfx)並且是密碼的客戶端管理,因此我需要調用此操作服務,但我嘗試時遇到一些問題。通過https消費WCF服務
也許我沒有正確地創建客戶端和服務之間的SSL連接,我會告訴我的web.config和一塊代碼中調用該服務
web.config
:
<configuration>
<system.serviceModel>
<behaviors>
<endpointBehaviors>
<behavior name="credentialConfiguration">
<clientCredentials>
<clientCertificate
findValue="10 14 08 f4 00 00 00 00 0f 3f"
storeLocation="CurrentUser"
x509FindType="FindBySerialNumber"/>
</clientCredentials>
</behavior>
</endpointBehaviors>
</behaviors>
<bindings>
<wsHttpBinding>
<binding name="myBinding">
<security mode="Transport">
<transport clientCredentialType="Certificate" />
</security>
</binding>
</wsHttpBinding>
</bindings>
<client>
<endpoint address="https://aaaaaaaaaaaaaaaaaa:700/aaa/aa/"
behaviorConfiguration="credentialConfiguration"
binding="wsHttpBinding"
bindingConfiguration="myBinding"
contract="mydll.service"
name="faturasSOAP" />
</client>
</system.serviceModel>
</configuration>
代碼,其中調用服務:
//Create authentication header
CdoHeaderCredentials header = GetEncryptedCredentials();
//Client Proxy
InvoiceService.faturasClient clientProxy = new faturasClient();
//Custom header
AddWseSecurityHeaderEndpointBehavior customEndpointBehavior =
new AddWseSecurityHeaderEndpointBehavior(header.Username, header.Password, header.Nonce, header.ClientDate);
clientProxy.Endpoint.Behaviors.Add(customEndpointBehavior);
//get document to register on service
RegisterInvoiceType documentToSnyc = manager.DocumentToSnyc();
//Load private certificate with key
X509Certificate2 cert = new X509Certificate2(
certPath,
_certKey,
X509KeyStorageFlags.Exportable);
//Link the certificate with the proxy
clientProxy.ClientCredentials.ClientCertificate.Certificate = cert;
//invoke operation
RegisterInvoiceResponse response = clientProxy.RegisterInvoice(new RegisterInvoiceRequest(documentToSnyc));
每當我調用該服務的響應是一樣的:
<env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope">
<s:Header xmlns:s="http://www.w3.org/2003/05/soap-envelope" />
<env:Body>
<env:Fault>
<env:Code>
<env:Value>
env:Receiver</env:Value>
</env:Code>
<env:Reason>
<env:Text xml:lang="en-US">
Internal Error (from server)
</env:Text>
</env:Reason>
</env:Fault>
</env:Body>
</env:Envelope>
我的問題是,如果這個錯誤是關於客戶端身份驗證拋出ssl,或者是其他什麼?
在此先感謝
感謝您的迴應,我有疑問,因爲驗證請求一些參數必須加密,問題是我不知道如果錯誤來自這個加密參數,但是我的客戶端已經建立了這些情況下的錯誤代碼,例如(8 - 公鑰無效,9 - 密碼未填寫,11對稱密鑰無效)。正如你所看到的,這些代碼都沒有返回 – mastervv