فهرست منبع

Admin verbindung SSL verschlüsselt

Kolja Strohm 6 سال پیش
والد
کامیت
1654461703
3فایلهای تغییر یافته به همراه38 افزوده شده و 38 حذف شده
  1. 34 34
      InformationServer/InformationServer.cpp
  2. 3 3
      InformationServer/InformationServer.h
  3. 1 1
      InformationServer/main.cpp

+ 34 - 34
InformationServer/InformationServer.cpp

@@ -20,7 +20,10 @@ InformationServer::InformationServer( InitDatei *zIni )
 	ini = zIni->getThis();
 	id = *zIni->zWert( "ServerId" );
 	server = new Server();
-	aServer = new Server();
+	aServer = new SSLServer();
+    aServer->setPrivateKeyPassword( zIni->zWert( "SSLPasswort" )->getText() );
+    aServer->setCertificateFile( zIni->zWert( "SSLCert" )->getText() );
+    aServer->setPrivateKeyFile( zIni->zWert( "SSLKey" )->getText() );
 	std::cout << "IS: Starten des Admin Servers...\n";
 	if( !aServer->verbinde( (unsigned short)TextZuInt( ini->zWert( "AdminServerPort" )->getText(), 10 ), 10 ) )
 	{
@@ -59,7 +62,7 @@ void InformationServer::runn()
 {
 	while( !end )
 	{
-		SKlient *klient;
+		SSLSKlient *klient;
 		klient = aServer->getKlient();
 		if( end && klient )
 		{
@@ -299,13 +302,10 @@ InformationServer *InformationServer::release()
 
 // Inhalt der ISAKlient Klasse aus InformationServer.h
 // Konstruktor 
-ISAKlient::ISAKlient( SKlient *klient, InformationServer *is )
+ISAKlient::ISAKlient( SSLSKlient *klient, InformationServer *is )
 	: Thread()
 {
 	this->klient = klient;
-	unsigned char key[ 20 ] = { 37, 231, 77, 95, 83, 98, 112, 98, 11, 225, 186, 227, 172, 168, 11, 22, 254, 142, 14, 22 };
-	klient->setSendeKey( (char*)key, 20 );
-	klient->setEmpfangKey( (char*)key, 20 );
 	name = new Text( "" );
 	passwort = new Text( "" );
 	adminId = 0;
@@ -328,7 +328,7 @@ void ISAKlient::thread()
 	while( 1 )
 	{
 		char c = 0;
-		if( !klient->getNachrichtEncrypted( &c, 1 ) )
+		if( !klient->getNachricht( &c, 1 ) )
 			break;
 		else
 		{
@@ -338,23 +338,23 @@ void ISAKlient::thread()
 			case 1: // Login
 				if( 1 )
 				{
-					klient->sendeEncrypted( "\1", 1 );
+					klient->sende( "\1", 1 );
 					unsigned char nLen = 0;
-					klient->getNachrichtEncrypted( (char*)&nLen, 1 );
+					klient->getNachricht( (char*)&nLen, 1 );
 					char *n = new char[ nLen + 1 ];
 					n[ (int)nLen ] = 0;
 					if( nLen )
-						klient->getNachrichtEncrypted( n, nLen );
+						klient->getNachricht( n, nLen );
 					unsigned char pLen = 0;
-					klient->getNachrichtEncrypted( (char*)&pLen, 1 );
+					klient->getNachricht( (char*)&pLen, 1 );
 					char *p = new char[ pLen + 1 ];
 					p[ (int)pLen ] = 0;
 					if( pLen )
-						klient->getNachrichtEncrypted( p, pLen );
+						klient->getNachricht( p, pLen );
 					int adminId = is->zDB()->istAdministrator( n, p );
 					if( adminId )
 					{
-						klient->sendeEncrypted( "\1", 1 );
+						klient->sende( "\1", 1 );
 						name->setText( n );
 						passwort->setText( p );
 						this->adminId = adminId;
@@ -369,11 +369,11 @@ void ISAKlient::thread()
 				adminId = 0;
 				name->setText( "" );
 				passwort->setText( "" );
-				klient->sendeEncrypted( "\1", 1 );
+				klient->sende( "\1", 1 );
 				break;
 			case 3: // Trennen
 				br = 1;
-				klient->sendeEncrypted( "\1", 1 );
+				klient->sende( "\1", 1 );
 				break;
 			case 4: // Server starten
 				if( !adminId )
@@ -390,7 +390,7 @@ void ISAKlient::thread()
 							err->release();
 						}
 						else
-							klient->sendeEncrypted( "\1", 1 );
+							klient->sende( "\1", 1 );
 					}
 					else
 						errorZuKlient( "Du bist nicht berechtigt den Server zu starten." );
@@ -404,7 +404,7 @@ void ISAKlient::thread()
 					if( is->zDB()->adminHatRecht( adminId, Admin_Recht::ISBeenden ) )
 					{
 						if( is->serverBeenden() )
-							klient->sendeEncrypted( "\1", 1 );
+							klient->sende( "\1", 1 );
 						else
 						{
 							Text *err = new Text();
@@ -449,7 +449,7 @@ void ISAKlient::thread()
 					}
 					if( ok )
 					{
-						klient->sendeEncrypted( "\1", 1 );
+						klient->sende( "\1", 1 );
 						std::cout << "IS: Der Server wird von Benutzer " << adminId << " heruntergefahren.\n";
 						is->close();
 						br = 1;
@@ -476,7 +476,7 @@ void ISAKlient::thread()
 						ok = 1;
 					if( ok )
 					{
-						klient->sendeEncrypted( "\1", 1 );
+						klient->sende( "\1", 1 );
 						std::cout << "IS: Der Server wurde von Benutzer " << adminId << " terminiert.\n";
 						is->close();
 						br = 1;
@@ -493,8 +493,8 @@ void ISAKlient::thread()
 						if( is->istAn() )
 							status = 2;
 					}
-					klient->sendeEncrypted( "\1", 1 );
-					klient->sendeEncrypted( &status, 1 );
+					klient->sende( "\1", 1 );
+					klient->sende( &status, 1 );
 				}
 				break;
 			case 9: // Server pausieren
@@ -502,9 +502,9 @@ void ISAKlient::thread()
 					errorZuKlient( "Du musst dich einloggen." );
 				else
 				{
-					klient->sendeEncrypted( "\1", 1 );
+					klient->sende( "\1", 1 );
 					char pause = 0;
-					klient->getNachrichtEncrypted( &pause, 1 );
+					klient->getNachricht( &pause, 1 );
 					if( is->zDB()->adminHatRecht( adminId, Admin_Recht::ISPausieren ) )
 					{
 						bool ok = 0;
@@ -513,7 +513,7 @@ void ISAKlient::thread()
 						else
 							ok = is->serverFortsetzen();
 						if( ok )
-							klient->sendeEncrypted( "\1", 1 );
+							klient->sende( "\1", 1 );
 						else
 						{
 							Text *err = new Text();
@@ -536,13 +536,13 @@ void ISAKlient::thread()
 					errorZuKlient( "Du musst dich einloggen." );
 				else
 				{
-					klient->sendeEncrypted( "\1", 1 );
+					klient->sende( "\1", 1 );
 					int maxC = 0;
-					klient->getNachrichtEncrypted( (char*)&maxC, 4 );
+					klient->getNachricht( (char*)&maxC, 4 );
 					if( is->zDB()->adminHatRecht( adminId, Admin_Recht::ISMCChange ) )
 					{
 						if( is->setMaxKlients( maxC ) )
-							klient->sendeEncrypted( "\1", 1 );
+							klient->sende( "\1", 1 );
 						else
 						{
 							Text *err = new Text();
@@ -558,13 +558,13 @@ void ISAKlient::thread()
             case 0xC: // klient absturtz
                 if( 1 )
                 {
-                    klient->sendeEncrypted( "\1", 1 );
+                    klient->sende( "\1", 1 );
                     int klientId = 0;
-                    klient->getNachrichtEncrypted( (char*)&klientId, 4 );
+                    klient->getNachricht( (char*)&klientId, 4 );
                     if( klientId && is->absturzKlient( klientId ) )
-                        klient->sendeEncrypted( "\1", 1 );
+                        klient->sende( "\1", 1 );
                     else
-                        klient->sendeEncrypted( "\0", 1 );
+                        klient->sende( "\0", 1 );
                 }
                 break;
 			default:
@@ -584,10 +584,10 @@ void ISAKlient::thread()
 
 void ISAKlient::errorZuKlient( const char *nachricht ) const // sendet eine Fehlernachricht zum Klient
 {
-	klient->sendeEncrypted( "\3", 1 );
+	klient->sende( "\3", 1 );
 	char len = (char)textLength( nachricht );
-	klient->sendeEncrypted( &len, 1 );
-	klient->sendeEncrypted( nachricht, len );
+	klient->sende( &len, 1 );
+	klient->sende( nachricht, len );
 }
 
 

+ 3 - 3
InformationServer/InformationServer.h

@@ -17,7 +17,7 @@ class InformationServer : public Thread
 {
 private:
 	Server *server;
-	Server *aServer;
+	SSLServer *aServer;
 	InitDatei *ini;
 	ISDatenbank *db;
 	CRITICAL_SECTION cs;
@@ -64,7 +64,7 @@ public:
 class ISAKlient : public Thread
 {
 private:
-	SKlient *klient;
+	SSLSKlient *klient;
 	Text *name;
 	Text *passwort;
 	int adminId;
@@ -72,7 +72,7 @@ private:
 
 public:
 	// Konstruktor 
-	ISAKlient( SKlient *klient, InformationServer *is );
+	ISAKlient( SSLSKlient *klient, InformationServer *is );
 	// Destruktor 
 	virtual ~ISAKlient( );
 	// nicht constant

+ 1 - 1
InformationServer/main.cpp

@@ -34,7 +34,7 @@ int main()
 		dat->release();
 		exit( 1 );
 	}
-    const char *wichtig[] = { "ServerId", "DBBenutzer", "DBPasswort", "DBName", "DBIP", "DBPort", "Aktiv" };
+    const char *wichtig[] = { "ServerId", "DBBenutzer", "DBPasswort", "DBName", "DBIP", "DBPort", "Aktiv", "SSLCert", "SSLKey", "SSLPasswort" };
     for( const char *w : wichtig )
     {
         if( !dat->wertExistiert( w ) )