C++ 使用VCPKG 调用OpenSSL (OPENSSL_Uplink(00007FFBD1635068,08): no OPENSSL_Applink)

错误:

OPENSSL_Uplink(00007FFBD1635068,08): no OPENSSL_Applink

出现这种错误的原因是因为,应该使用OpenSSL BIO 函数来写入或读取证书文件,

FILE* keyFile = fopen("private_key.pem", "w");
PEM_write_RSAPrivateKey(keyFile, rsa, nullptr, nullptr, 0, nullptr, nullptr);
fclose(keyFile);

应该替换为

BIO* keyFile = BIO_new_file("private_key.pem", "w");
PEM_write_bio_RSAPrivateKey(keyFile, rsa, nullptr, nullptr, 0, nullptr, nullptr);
BIO_free(keyFile);

另外一种解决方法,直接 包含 #include <openssl/applink.c>

#include <iostream>
#include <openssl/rsa.h>
#include <openssl/pem.h>

#include <openssl/applink.c>

#参考资料

https://www.openssl.org/docs/man3.1/man3/OPENSSL_Applink.html

https://www.openssl.org/docs/man3.1/man3/BIO_new_file.html

版权声明:本文为NII.CN的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://nii.cn/4296.html 发布者:nii

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
nii的头像nii
上一篇 2024-04-23
下一篇 2024-01-09

相关推荐

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注

联系我们

邮件:83390286[AT]QQ.COM

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信