Procházet zdrojové kódy

Check context attributes of established schannel context

Bart van Strien před 6 roky
rodič
revize
b26e82cb23
1 změnil soubory, kde provedl 17 přidání a 1 odebrání
  1. 17 1
      src/windows/SChannelConnection.cpp

+ 17 - 1
src/windows/SChannelConnection.cpp

@@ -236,7 +236,23 @@ bool SChannelConnection::connect(const std::string &hostname, uint16_t port)
 	} while (!done);
 
 	debug << "Done!\n";
-	// TODO: Check resulting context attributes
+
+	if (success)
+	{
+		SecPkgContext_Flags resultFlags;
+		QueryContextAttributes(context.get(), SECPKG_ATTR_FLAGS, &resultFlags);
+		if (resultFlags.Flags & ISC_REQ_CONFIDENTIALITY == 0)
+		{
+			debug << "Resulting context is not encrypted, marking as failed\n";
+			success = false;
+		}
+		if (resultFlags.Flags & ISC_REQ_INTEGRITY == 0)
+		{
+			debug << "Resulting context is not signed, marking as failed\n";
+			success = false;
+		}
+	}
+
 	if (success)
 		this->context = static_cast<void*>(context.release());
 	else if (contextCreated)