I am working on macOS software agent implemented in C++. The agent communicates with the central controller over TLS. The agent and controller do mutual TLS authentication. The agent, which acts as a TLS client, requires a certificate and it's private key which are passed to OpenSSL to perform mutual TLS. I am trying to retrieve the certificate and its private key from the Keychain. But the problem is, private key extraction from Keychain fails if the private key is non-extractable or non-exportable.
Is there a way to retrieve the non-extractable private key from macOS Keychain using C++ or any other alternate option? Please suggest an option to solve this problem.