在 Linux 系統中,您可以使用以下方法之一來查看 OpenSSL 的版本信息:
命令行界面(CLI): 打開終端并輸入以下命令:
openssl version
按 Enter 鍵,系統將顯示您當前安裝的 OpenSSL 版本。
通過編程接口(API): 如果您正在編寫一個使用 OpenSSL 的程序,可以使用以下代碼片段來獲取 OpenSSL 版本信息:
#include <stdio.h>
#include <openssl/opensslv.h>
#include <openssl/crypto.h>
int main() {
const OpenSSL_version_num *version_num = OpenSSL_version_num();
const char *version_str = OpenSSL_version(OPENSSL_VERSION);
printf("OpenSSL version: %s\n", version_str);
printf("OpenSSL version number: %ld\n", version_num->version);
return 0;
}
編譯并運行此程序,它將輸出 OpenSSL 的版本信息和版本號。
檢查系統庫: 您還可以檢查系統庫中是否存在 OpenSSL,并獲取其版本信息。在終端中輸入以下命令:
ldconfig -p | grep libssl
按 Enter 鍵,您將看到與 libssl 相關的庫及其版本信息。