I am trying to
handshake
via web socket in c# to a server with Self Signed Certificate and got exception as below:
Exception got as below:
<pre>The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel. ---> System.Security.Authentication.AuthenticationException: The remote certificate is invalid according to the validation procedure.
I have downloaded the ssl certificate got from server and imported in the client side successfully as per below link:
https://support.quovadisglobal.com/kb/a66/how-do-i-install-a-digital-certificate-onto-windows-7.aspx
Certificate Installed has come in intermediate store on checking. But even after that while trying to communicate getting the same exception:
underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel. ---> System.Security.Authentication.AuthenticationException: The remote certificate is invalid according to the validation procedure.
What I have tried:
Core code as below:
In the server side it is hosted as https://10.15.1.5/Test.aspx
Connecting to Client as below:
Connect("wss://10.15.1.5/Test.aspx/)
public async Task Connect(string uri)
{
Thread.Sleep(1000);
try
{
txtLog.Text += "Client:Connectivity Process Started under " + MethodInfo.GetCurrentMethod().Name + Environment.NewLine;
webSocket = new ClientWebSocket();
await webSocket.ConnectAsync(new Uri(uri), CancellationToken.None);
}
catch (Exception ex)
{
txtError.Text += "Client:Connectivity Process Failure under " + MethodInfo.GetCurrentMethod().Name + ex.Message.ToString() + Environment.NewLine;
txtError.Text += "Client:Connectivity Process Failure under " + MethodInfo.GetCurrentMethod().Name + ex.InnerException.ToString() + Environment.NewLine;
txtError.Text += "Client:Connectivity Process Failure under " + MethodInfo.GetCurrentMethod().Name + ex.StackTrace.ToString() + Environment.NewLine;
//throw ex;
}
finally
{
if (webSocket != null)
webSocket.Dispose();
}
}