Reading Public/Private Key from Memory with OpenSSL

后端 未结 3 664
予麋鹿
予麋鹿 2020-12-06 07:02

I am using Public/Private Keys in my project to encrypt/decrypt some data.

I am hosting a public key (\"public.pem\") on a server.

\"public.pem\" looks like

3条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-06 07:42

    SquareRootOfTwentyThree's method not work for me. Here is my solution.

    BIO* bio = BIO_new(BIO_s_mem());
    int len = BIO_write(bio, pem_key_buffer, pem_key_buffer_len);
    EVP_PKEY* evp_key = PEM_read_bio_PUBKEY(bio, NULL, NULL, NULL);
    RSA* rsa = EVP_PKEY_get1_RSA(evp_key);
    

提交回复
热议问题