客户端证书Web服务调用

时间:2015-06-12 12:31:43

标签: web-services asp.net-mvc-4 client-certificates

我需要使用客户端证书调用服务器Web服务。他们为我提供了一个.crt文件。我在WindowsServer2008 IIS7中托管我的项目。

我从右键单击属性安装.crt,因为我无法通过完整证书申请将证书添加到服务器证书。我收到了错误:

CertEnroll::CX509Enrollment::p_InstallResponse: ANSI bad tag value met.

我用谷歌搜索,没有发现如何安装.crt客户端证书。还尝试在第4步安装解释here

当我这样打电话时

string certPath = Server.MapPath("../certificate/iot01.servername.crt");
X509Certificate2 cert = new X509Certificate2(certPath);
ws.ClientCertificates.Add(cert);
res = ws.methodName(params);

我收到了错误: System.IO.IOException:由于意外的数据包格式,握手失败。 System.Net.Security.SslState的System.Net.Security.SslState.StartReadFrame(Byte []缓冲区,Int32 readBytes,AsyncProtocolRequest asyncRequest)处于System.Net.Security.SslState的System.Net.Security.SslState.StartReceiveBlob(Byte []缓冲区,AsyncProtocolRequest asyncRequest)。 System.Net.Security.SslState.ForceAuthentication(Boolean receiveFirst,Byte [] buffer,AsyncProtocolRequest)上的System.Net.Security.SslState.StartSendBlob(Byte []传入,Int32计数,AsyncProtocolRequest asyncRequest)中的CheckCompletionBeforeNextReceive(ProtocolToken消息,AsyncProtocolRequest asyncRequest) System.Thread.ExecutionContext.RunInternal(ExecutionContext executionContext,ContextCallback callback,Object state,Boolean preserveSyncCtx)的System.Net.TlsStream.CallProcessAuthentication(Object state)处的System.Net.Security.SslState.ProcessAuthentication(LazyAsyncResult lazyResult)处的asyncRequest) System.Threading.ExecutionContext.Run(ExecutionContext executionContext,ContextCallback回调,Object state,Boolean preserveSy ncCtx)System.Threading.ExecutionContext.Run(ExecutionContext executionContext,ContextCallback回调,对象状态),位于System.Net.TlsStream.Write(Byte []缓冲区,Int32偏移量,Int32处的System.Net.TlsStream.ProcessAuthentication(LazyAsyncResult结果) System.Net.ConnectStream.WriteHeaders(布尔异步)的System.Net.PooledStream.Write(Byte []缓冲区,Int32偏移量,Int32大小)处理的大小) System.Web.Services.Protocols.Protocols.ProtWeb上的System.Web.Services.Protocols.WebClientProtocol.GetWebResponse(WebRequest请求)处的System.Web.Services.Protocols.HttpWebClientProtocol.GetWebResponse(WebRequest请求)处于System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName,Object [参数)在......

这与我的证书安装和调用有关。有人能指出我哪里出错了。

1 个答案:

答案 0 :(得分:0)

错误明确提及"握手失败"。我怀疑这是一个SSL身份验证错误,因为WSDL格式不匹配。

您应该检查请求的格式和响应的格式是否相同。他们需要匹配才能沟通。

Microsoft网络监视器可以帮助您确定格式。

相关问题