我正在尝试从OpenSSL1.0.2更新到最近的(比如3.0.1)。问题是,我有大量的代码和第三方库,它们依赖于较早版本的API,这将成为一种不现实的估计任务。我发现openssl脚本有一个很棒的configure级别,用于构建OpenSSL库以支持指定版本的API,但是,我没有看到该选项的任何效果。
下面是我如何使用它:
$ ./Configure --api=1.0.2 --release --prefix=/opt/openssl
$ make -j
$ make install在此之后,我尝试在/opt/openssl中使用构建,但是我用OpenSSL1.0.2成功构建的代码现在无法编译。
$ g++ test.cpp
$ g++ test.cpp -lcrypto -I/opt/openssl/include/ -L/opt/openssl/lib64/
test.cpp: In function ‘int main()’:
test.cpp:5:16: error: aggregate ‘EVP_MD_CTX context’ has incomplete type and cannot be defined
5 | EVP_MD_CTX context;
| ^~~~~~~我是不是误解了什么?我在这里错过了什么?
发布于 2022-10-06 06:46:51
从3.0API开始,EVP_MD_CTX结构对用户是隐藏的。它只是在SSL头文件/usr/include/openssl/typees.h:105:typedef struct evp_md_ctx_st EVP_MD_CTX中进行了转发声明;
需要使用EVP_MD_CTX_create/new来代替以前使用的变量声明EVP_MD_CTX mdc;
#include <openssl/evp.h>
...
EVP_MD_CTX *mdc ;
//(Even though struct is anonymous pointer to anonymous
// struct can always be handled by compiler)
mdc = EVP_MD_CTX_new() ;
EVP_MD_CTX_init(mdc);
...
EVP_MD_CTX_cleanup(mdc);
EVP_MD_CTX_free(mdc) ;https://stackoverflow.com/questions/70925193
复制相似问题