⚡️ Initailiza OpenSSL in a more modern way if possible
This commit is contained in:
parent
a631bfac39
commit
414341ebc6
1 changed files with 15 additions and 2 deletions
|
@ -1,7 +1,9 @@
|
|||
#include <arpa/inet.h>
|
||||
#include <iostream>
|
||||
#include <netinet/in.h>
|
||||
#include <openssl/crypto.h>
|
||||
#include <openssl/err.h>
|
||||
#include <openssl/opensslv.h>
|
||||
#include <openssl/ssl.h>
|
||||
#include <ostream>
|
||||
#include <sys/socket.h>
|
||||
|
@ -33,8 +35,19 @@ string getCtxError() {
|
|||
|
||||
int main() {
|
||||
|
||||
SSL_library_init();
|
||||
SSL_load_error_strings();
|
||||
// Inistialize the SSL library
|
||||
if (OpenSSL_version_num() < 0x10100000L) {
|
||||
// Old version, deprecated as of version 1.1.0
|
||||
SSL_library_init();
|
||||
|
||||
// Loads human readable error strings
|
||||
// Automatically inistialized in newer versions
|
||||
SSL_load_error_strings();
|
||||
} else {
|
||||
// New version
|
||||
// Initalizes both SSl and crypto and is generally better
|
||||
OPENSSL_init_ssl(0, nullptr);
|
||||
}
|
||||
|
||||
SSL_CTX *ctx = SSL_CTX_new(TLS_server_method());
|
||||
if (!ctx) {
|
||||
|
|
Reference in a new issue