【问题标题】:Public Key Error WCF Client公钥错误 WCF 客户端
【发布时间】:2013-11-11 22:48:00
【问题描述】:

我正在开发 WCF 服务。它托管在 IIS 中并由 SSL 保护。我正在使用 Soap11 的自定义投标。我有这个服务的私钥,它在 web.config 文件中被引用。我已经从私钥导出了公钥,并计划将此公钥提供给将调用此服务的供应商。

当我尝试使用客户端测试服务时。我收到以下错误。在我的客户中,我引用了公钥。我的客户正在向受私钥保护的服务发送请求。我已经检查了私钥以确保我有“您有一个与此证书相对应的私钥。另外,我的 IIS 应用程序池以我的用户名运行。我是计算机的管理员。

但是,当我尝试发送请求时,我收到错误消息“X.509 证书中不存在私钥”。在客户端。什么可能导致此错误?

堆栈跟踪:

System.NotSupportedException was caught
  HResult=-2146233067
  Message=The private key is not present in the X.509 certificate.
  Source=mscorlib
  StackTrace:
    Server stack trace: 
       at System.IdentityModel.Tokens.X509AsymmetricSecurityKey.GetSignatureFormatter(String algorithm)
       at System.IdentityModel.SignedXml.ComputeSignature(SecurityKey signingKey)
       at System.ServiceModel.Security.WSSecurityOneDotZeroSendSecurityHeader.CompletePrimarySignatureCore(SendSecurityHeaderElement[] signatureConfirmations, SecurityToken[] signedEndorsingTokens, SecurityToken[] signedTokens, SendSecurityHeaderElement[] basicTokens, Boolean isPrimarySignature)
       at System.ServiceModel.Security.SendSecurityHeader.CompleteSignature()
       at System.ServiceModel.Security.SendSecurityHeader.CompleteSecurityApplication()
       at System.ServiceModel.Security.SecurityAppliedMessage.OnWriteMessage(XmlDictionaryWriter writer)
       at System.ServiceModel.Channels.BufferedMessageWriter.WriteMessage(Message message, BufferManager bufferManager, Int32 initialOffset, Int32 maxSizeQuota)
       at System.ServiceModel.Channels.TextMessageEncoderFactory.TextMessageEncoder.WriteMessage(Message message, Int32 maxMessageSize, BufferManager bufferManager, Int32 messageOffset)
       at System.ServiceModel.Channels.HttpOutput.SerializeBufferedMessage(Message message)
       at System.ServiceModel.Channels.HttpOutput.Send(TimeSpan timeout)
       at System.ServiceModel.Channels.HttpChannelFactory`1.HttpRequestChannel.HttpChannelRequest.SendRequest(Message message, TimeSpan timeout)
       at System.ServiceModel.Channels.RequestChannel.Request(Message message, 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.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 PaymentGatewayTestClient.Customer.ICustomerDetails.CustomerDetails(CustomerDetailRequest request)
       at PaymentGatewayTestClient.Customer.CustomerDetailsClient.CustomerDetails(CustomerDetailRequest request) in c:\temp\Test\PaymentGatewayTestClient\PaymentGatewayTestClient\Service References\Customer\Reference.cs:line 937
       at PaymentGatewayTestClient.Program.Main(String[] args) in c:\temp\Test\PaymentGatewayTestClient\PaymentGatewayTestClient\Program.cs:line 38
  InnerException: 

【问题讨论】:

    标签: wcf wcf-security x509


    【解决方案1】:

    看起来服务器无法访问密钥的私有部分。您必须为运行您的应用程序池的用户授予私钥权限。

    另见: PrivateKey trust permissions for local machine "Trusted roots" certificates

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-07-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-02-07
      • 1970-01-01
      • 2015-12-18
      • 2013-01-19
      相关资源
      最近更新 更多