SSL connection error while acessing the certificates from console application.

Atturu Tharun Kumar 1 Reputation point
2022-01-20T12:35:51.043+00:00

Hi,
This is tharun_atturu, I am trying to use the ACM certificates by importing them from the .pfx file. I get the desired result when the application is run with system privileges but when I try the console application with admin privileges I am getting the SSL connection error.

Code:

                    X509Certificate2Collection collection = new X509Certificate2Collection();
                    collection.Import(certPath, CertFilePassword, X509KeyStorageFlags.MachineKeySet | 
                                                 X509KeyStorageFlags.PersistKeySet);

                    X509Store RootStore = new X509Store(StoreName.Root, StoreLocation.LocalMachine);
                    X509Store CertificateAuthorityStore = new X509Store(StoreName.CertificateAuthority, 
                                                                                                           StoreLocation.LocalMachine);
                    X509Store ClientCertStore = new X509Store("ClientAuthIssuer", StoreLocation.LocalMachine);

                    RootStore.Open(OpenFlags.ReadWrite);
                    RootStore.Add(collection[0]);

                    CertificateAuthorityStore.Open(OpenFlags.ReadWrite);
                    CertificateAuthorityStore.Add(collection[1]);

                    ClientCertStore.Open(OpenFlags.ReadWrite);
                    ClientCertStore.Add(collection[2]);

                    RootStore.Close();
                    CertificateAuthorityStore.Close();
                    ClientCertStore.Close();

I am trying to access the cert from CPP using "Curl" to make an API call.
and I am getting this
ERROR:

  • schannel: AcquireCredentialsHandle failed: SEC_E_UNKNOWN_CREDENTIALS (0x8009030D) - The credentials supplied to the package were not recognized
  • Closing connection 0
  • schannel: shutting down SSL/TLS connection with api*****.com port 443
    curl_easy_perform() failed: SSL connect error

Thank You.

Windows for business Windows Server User experience Other
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.