From 48f56cb6dd82674c5348a056e72ec04dce7dea38 Mon Sep 17 00:00:00 2001 From: hhhFun Date: Tue, 24 Sep 2024 09:31:26 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=8E=B7=E5=8F=96pem?= =?UTF-8?q?=E7=A7=81=E9=92=A5=E5=87=BA=E9=94=99=E6=97=B6=E6=A6=82=E7=8E=87?= =?UTF-8?q?=E5=8D=A1=E4=BD=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: hhhFun --- plugin/openssl_plugin/common/src/openssl_common.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/plugin/openssl_plugin/common/src/openssl_common.c b/plugin/openssl_plugin/common/src/openssl_common.c index 512219e..3669142 100644 --- a/plugin/openssl_plugin/common/src/openssl_common.c +++ b/plugin/openssl_plugin/common/src/openssl_common.c @@ -572,6 +572,12 @@ HcfResult ConvertPubPemStrToKey(EVP_PKEY **pkey, const char *keyType, int select return HCF_SUCCESS; } +int PrivateKeyReadNullCb(char *buf, int size, int rwflag, void *userdata) +{ + LOGE("Failed to read private key from bio."); + return -1; +} + HcfResult ConvertPriPemStrToKey(const char *keyStr, EVP_PKEY **pkey, const char *keyType) { BIO *bio = OpensslBioNew(OpensslBioSMem()); @@ -588,7 +594,7 @@ HcfResult ConvertPriPemStrToKey(const char *keyStr, EVP_PKEY **pkey, const char return HCF_ERR_CRYPTO_OPERATION; } - EVP_PKEY *pkeyRet = OpensslPemReadBioPrivateKey(bio, pkey, NULL, NULL); + EVP_PKEY *pkeyRet = OpensslPemReadBioPrivateKey(bio, pkey, PrivateKeyReadNullCb, NULL); OpensslBioFreeAll(bio); if (pkeyRet == NULL) { LOGE("Failed to read private key from bio");