–1 vote

I am getting following error randomly when connecting via ConnectSSL method.
Please provide your feedback.

at System.Net.Security.SslState.StartSendAuthResetSignal(ProtocolToken message, AsyncProtocolRequest asyncRequest, Exception exception) 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.ProcessReceivedBlob(Byte[] buffer, Int32 count, AsyncProtocolRequest asyncRequest) 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.Security.SslStream.AuthenticateAsClient(String targetHost, X509CertificateCollection clientCertificates, SslProtocols enabledSslProtocols, Boolean checkCertificateRevocation) at Limilabs.Client.ClientBase.(Stream ) at Limilabs.Client.ClientBase.() at Limilabs.Client.ClientBase.Connect(String host, Int32 port, Boolean useSSL) at Limilabs.Client.ClientBase.ConnectSSL(String host, Int32 port)

by (670 points)
What is the error message? and exception type?

1 Answer

0 votes

Without the error message and exception type, I can't help you.
My guess is:
"The remote certificate is invalid according to the validation procedure"

Use the following code to check what is wrong with the certificate:

client.ServerCertificateValidate +=
   new ServerCertificateValidateEventHandler(Validate);

private static void Validate(
    object sender,
    ServerCertificateValidateEventArgs e)
{
    const SslPolicyErrors ignoredErrors =
        SslPolicyErrors.RemoteCertificateChainErrors |  // self-signed
        SslPolicyErrors.RemoteCertificateNameMismatch;  // name mismatch

    string nameOnCertificate = e.Certificate.Subject;

    if ((e.SslPolicyErrors & ~ignoredErrors) == SslPolicyErrors.None)
    {
        e.IsValid = true;
        return;
    }
    e.IsValid = false;
}

} ;

You can find details here:
https://www.limilabs.com/blog/the-remote-certificate-is-invalid-according-to-the-validation-procedure

by (301k points)
...