digitalmars.D.learn - Get Private Key in a File
- Vahid (5/5) Jun 18 Hi,
- Richard (Rikki) Andrew Cattermole (9/15) Jun 19 That function from PHP wraps a bunch of calls into OpenSSL.
Hi, I have a private key file and aim to retrieve the private key for utilization in other functions. In PHP, there exists a function named 'openssl_pkey_get_private' for this purpose. Is there a corresponding function available in D to achieve the same outcome?
Jun 18
On 19/06/2024 7:23 AM, Vahid wrote:Hi, I have a private key file and aim to retrieve the private key for utilization in other functions. In PHP, there exists a function named 'openssl_pkey_get_private' for this purpose. Is there a corresponding function available in D to achieve the same outcome?That function from PHP wraps a bunch of calls into OpenSSL. Long story short, you need to understand OpenSSL BIO's and call into ``PEM_write_bio_PKCS8PrivateKey`` with the ``EVP_PKEY`` already loaded which isn't the easiest thing to do. My version of the code: https://github.com/Project-Sidero/eventloop/blob/master/source/sidero/eventloop/certificates/defs.d#L168C17-L168C46 You'll also need an OpenSSL binding such as: https://github.com/D-Programming-Deimos/openssl
Jun 19