!445 修改获取pem私钥出错时概率卡住

Merge pull request !445 from hhhFun/hhhfun
This commit is contained in:
openharmony_ci 2024-09-24 06:49:19 +00:00 committed by Gitee
commit ad25a0bd04
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F

View File

@ -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");