I have a requirement to call server web service with client certificate. They have provided me one .crt file. I am hosting my project in WindowsServer2008 IIS7.
I install .crt from right click properties, as i can't add certificate to Server Certificates by Complete Certificate Request. I got the error:
CertEnroll::CX509Enrollment::p_InstallResponse: ANSI bad tag value met.
I googled and found nothing on how to install .crt client certificate. Also tried installing as explaining here on step4.
And when i called like this
string certPath = Server.MapPath("../certificate/iot01.servername.crt");
X509Certificate2 cert = new X509Certificate2(certPath);
ws.ClientCertificates.Add(cert);
res = ws.methodName(params);
I got the error: System.IO.IOException: The handshake failed due to an unexpected packet format. at System.Net.Security.SslState.StartReadFrame(Byte[] buffer, Int32 readBytes, AsyncProtocolRequest asyncRequest) at System.Net.Security.SslState.StartReceiveBlob(Byte[] buffer, AsyncProtocolRequest asyncRequest) at System.Net.Security.SslState.CheckCompletionBeforeNextReceive(ProtocolToken message, AsyncProtocolRequest asyncRequest) at System.Net.Security.SslState.StartSendBlob(Byte[] incoming, Int32 count, AsyncProtocolRequest asyncRequest) at System.Net.Security.SslState.ForceAuthentication(Boolean receiveFirst, Byte[] buffer, AsyncProtocolRequest asyncRequest) at System.Net.Security.SslState.ProcessAuthentication(LazyAsyncResult lazyResult) at System.Net.TlsStream.CallProcessAuthentication(Object state) at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) at System.Net.TlsStream.ProcessAuthentication(LazyAsyncResult result) at System.Net.TlsStream.Write(Byte[] buffer, Int32 offset, Int32 size) at System.Net.PooledStream.Write(Byte[] buffer, Int32 offset, Int32 size) at System.Net.ConnectStream.WriteHeaders(Boolean async) at System.Web.Services.Protocols.WebClientProtocol.GetWebResponse(WebRequest request) at System.Web.Services.Protocols.HttpWebClientProtocol.GetWebResponse(WebRequest request) at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters) at .....
Is this is related to my certificate installing and calling. Can someone point me where am i gone wrong.
The error clearly mentions "handshake failed". I suspect it is an SSL auth error because of a WSDL format mismatch.
You should check whether the format of your request, and that of the response are the same. They need to match to be able to communicate.
Microsoft Network Monitor can help you figure out the format.