1

I am trying to use SslStream to establish TLS connection to server.
When I don't provide the certificate, everything is working as expected.

However when I try to use self signed client certificate with same server, it does not works.

  • When I use cer file (certificate without private key), the certificate is not sent (certificate tls packet has certificate length 0).

  • When I try to use pfx file that contains certificate, private key and ca certificate, I receive the error

"The credentials supplied to the package were not recognized"

I have tried to install both pfx and server certificate on Windows, however it did not help.

Exception stack trace is:

at System.Net.Security.SslState.InternalEndProcessAuthentication(LazyAsyncResult lazyResult)
at System.Net.Security.SslState.EndProcessAuthentication(IAsyncResult result)
at System.Threading.Tasks.TaskFactory1.FromAsyncCoreLogic(IAsyncResult iar, Func2 endFunction, Action1 endAction, Task1 promise, Boolean requiresSynchronization)

I have tried to load the pfx by using:

System.Security.Cryptography.X509Certificates.X509Certificate2(path, password);

And

System.Security.Cryptography.X509Certificates.X509Certificate2Collection collection = 
    new System.Security.Cryptography.X509Certificates.X509Certificate2Collection();

collection.Import(path, password, System.Security.Cryptography.X509Certificates.X509KeyStorageFlags.PersistKeySet);

Both lead to same errors.
- CheckCertificateRevocation is set to false.
- Enabled protocols are set to Tls | Tls11 | Tls12
- Target host is set to dns name of remote server.

What am I doing wrong?

Jimi
  • 29,621
  • 8
  • 43
  • 61
Yulian Oifa
  • 111
  • 7
  • See following posting : https://stackoverflow.com/questions/46722997/saml-assertion-in-a-xml-using-c-sharp/46724392 Codeproject is another goo source. There are many c# ssl project at codeprojects. See this one as a sample : https://www.codeproject.com/Articles/1000189/A-Working-TCP-Client-and-Server-With-SSL – jdweng Nov 06 '18 at 10:57

0 Answers0