且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

从内存中读取公钥/私钥与OpenSSL的

更新时间:2023-01-18 11:12:25

您是在正确的轨道上。您必须已经通过BIO缓冲的方式通过 BIO_new_mem_buf包裹PEM关键存储器()。换句话说,是这样的:

You are on the right track. You must wrap the PEM key already in memory by means of a BIO buffer via BIO_new_mem_buf(). In other words, something like:

BIO *bufio;
RSA *rsa

bufio = BIO_new_mem_buf((void*)pem_key_buffer, pem_key_buffer_len);
PEM_read_bio_RSAPublicKey(bufio, &rsa, 0, NULL);

同样的方法是有效的RSA私钥(通过 PEM_read_bio_RSAPrivateKey ),但在这种情况下,你肯定需要迎合密码短语。检查手册页了解详情。

The same approach is valid for an RSA private key (via PEM_read_bio_RSAPrivateKey), but in that case you most certainly need to cater for the pass phrase. Check the man page for details.