Skip to content

.Net 4.72 AquireCrenedtialsHandle fails with 0x8009030D #18

Description

@AndersGustafsson

Hi! For various security/usability reasons do we not like to store certificates in the Windows store and therefore tried to use this package to create an X509 cert from files. For some reason does it work for signing, but not comunication. This is a snippet of the log:

System.Net Information: 0 : [0700] SecureChannel#64923656 - Certifikatet är av typ X509Certificate2 och innehåller den privata nyckeln.
System.Net Information: 0 : [0700] SecureChannel#64923656::.AcquireClientCredentials, new SecureCredential() (flags=(ValidateManual, NoDefaultCred, SendAuxRecord, UseStrongCrypto), m_ProtocolFlags=(Zero), m_EncryptionPolicy=RequireEncryption)
System.Net Information: 0 : [0700] AcquireCredentialsHandle(package = Microsoft Unified Security Protocol Provider, intent  = Outbound, scc     = System.Net.SecureCredential2)
System.Net Error: 0 : [0700] AcquireCredentialsHandle() misslyckades med felet 0X8009030D.
System.Net Information: 0 : [0700] AcquireCredentialsHandle(package = Microsoft Unified Security Protocol Provider, intent  = Outbound, scc     = System.Net.SecureCredential2)
System.Net Error: 0 : [0700] AcquireCredentialsHandle() misslyckades med felet 0X8009030D.

The code in question is:

provider = new OpenSSL.X509Certificate2Provider.CertificateFromFileProvider(Certificate, Key);
certificate = provider.Certificate;

// then:
        private static HttpClient GetClient(X509Certificate2 certificate)
        {
            var clientHandler = new HttpClientHandler();
            clientHandler.ClientCertificates.Add(certificate);
            var client = new HttpClient(clientHandler);
            return client;
        }
        
// then:
response = await httpClient.SendAsync(request, HttpCompletionOption.ResponseHeadersRead))

Where certificate and key are simply passed as strings created by File.ReadAllText()

if I create a .pfx file from certificate and key then returning the cerfificate from the collection works:

                    X509Certificate2Collection collection = new X509Certificate2Collection();
                    collection.Import("C:\\Prog\\lplib\\Certifikat\\TestAPICert8\\TestAPICert8.pfx", "password", X509KeyStorageFlags.PersistKeySet);

The last comment in this link seem to point to the same issue: https://stackoverflow.com/questions/50508622/what-might-cause-system-net-erroracquirecredentialshandle-failed-with-error-0

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions