I'm trying to connect to Homeworks processor using a C# program in .NET Framework:
X509Certificate2Collection certificates = new X509Certificate2Collection();
string serverName = "IP OF THE PROCESSOR";
// ADD THE PFX CERTIFICATE
certificates.Add(new X509Certificate2(_certPath, "PASSWORD", X509KeyStorageFlags.DefaultKeySet));
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
ServicePointManager.ServerCertificateValidationCal lback = RemoteCertificateValidationCallback;
_client = new TcpClient(_ip, _port);
_sslStream = new SslStream(_client.GetStream(), true, RemoteCertificateValidationCallback, LocalCertificateSelectionCallback);
_sslStream.AuthenticateAsClient(serverName, certificates, SslProtocols.Tls12, false);
The AuthenticateAsClient function return the "Unknown error during certificate elaboration" and I don't know what I'm doing wrong. Using authentication with username and password the connection works.
The error is generic and I don't understand what can be the error.
The same certificates used to produce the pfx work with openssl connection.
Does anyone have a suggestion?
Thanks in advance