Ver Fonte

moved from deprecated ssl method to TLS1.2 or 1.3

Kolja Strohm há 3 anos atrás
pai
commit
e13cd94331
3 ficheiros alterados com 10 adições e 3 exclusões
  1. 3 1
      Network/Klient.cpp
  2. 1 0
      Network/Network.cpp
  3. 6 2
      Network/Server.cpp

+ 3 - 1
Network/Klient.cpp

@@ -226,7 +226,9 @@ const char *Klient::getServerIp() const // gibt die Ip zur
 SSLKlient::SSLKlient()
     : ReferenceCounter()
 {
-    ctx = SSL_CTX_new( SSLv23_client_method() );
+    ctx = SSL_CTX_new( TLS_client_method() );
+    SSL_CTX_set_min_proto_version( ctx, TLS1_2_VERSION );
+    SSL_CTX_set_max_proto_version( ctx, TLS1_3_VERSION );
     ip = 0;
     port = 0;
     bio = BIO_new_ssl_connect( ctx );

+ 1 - 0
Network/Network.cpp

@@ -23,6 +23,7 @@ void Network::Start( int maxClients )
 #endif
     SSL_library_init();
     SSL_load_error_strings();
+    OpenSSL_add_ssl_algorithms();
 }
 
 void Network::getHostName( char *name, int bufferLen )

+ 6 - 2
Network/Server.cpp

@@ -6,6 +6,7 @@
 #endif
 #include <Key.h>
 #include <Text.h>
+#include <iostream>
 
 using namespace Network;
 
@@ -310,8 +311,11 @@ SSLServer::SSLServer()
     : ReferenceCounter()
 {
     s = 0;
-    ctx = SSL_CTX_new( SSLv23_server_method() );
-    SSL_CTX_set_min_proto_version( ctx, TLS1_2_VERSION );
+    const SSL_METHOD *method = TLS_server_method();
+    ctx = SSL_CTX_new( method );
+    SSLErrorCheck( SSL_CTX_set_min_proto_version( ctx, TLS1_2_VERSION ), "SSL_CTX_set_min_proto_version" );
+    SSLErrorCheck( SSL_CTX_set_max_proto_version( ctx, TLS1_3_VERSION ), "SSL_CTX_set_max_proto_version" );
+    SSL_CTX_set_verify( ctx, SSL_VERIFY_NONE, 0 );
     SSL_CTX_set_default_passwd_cb( ctx, pem_passwd_cb );
     passw = new Text();
     SSL_CTX_set_default_passwd_cb_userdata( ctx, passw );