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 length0
).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, Func
2 endFunction, Action1 endAction, Task
1 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?