OpenSSL is a widely used cryptographic library that provides tools for secure communication. As OpenSSL evolves, ensuring compatibility with the correct version is critical for both functionality and security. This tutorial explains how to get OpenSSL version using C++.
OpenSSL provides a pre-defined macro to help to retrieve version information easily at compile time. In the provided code snippet, the OpenSSL version is assigned to a variable, which is then displayed on the console.
#include <openssl/opensslv.h>
#include <iostream>
int main() {
std::string version = OPENSSL_VERSION_STR;
std::cout << version << std::endl;
return 0;
}
The version is formatted as major.minor.patch
. For example, the output might look like:
3.4.0
Leave a Comment
Cancel reply