0

我需要使用通过 https 连接公开的 Web 服务,该服务由给我证书 (.pfx) 和密码的客户端管理,所以我需要对该服务调用一个操作但是我在尝试时遇到了一些问题它。

也许我没有正确创建客户端和服务之间的 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,还是其他什么?

提前致谢

4

1 回答 1

0

这里没有足够的信息来确定您为什么在不了解服务器的情况下看到错误,但由于错误文本显示“内部错误(来自服务器)”,我的猜测是它与您的任何事情无关重新在客户端做。无论如何,一旦你看到这样的东西,你可能应该联系网络服务的所有者寻求帮助——如果这是一个“内部错误”,他们应该负责调试它或告诉你你的实际错误是什么这个“内部错误”代表的一面。

于 2012-12-17T16:24:02.267 回答