Skip to content

Commit 6cffd96

Browse files
committed
Host specific TLS contexts
Added host specific TLS contexts that are cached, so we not longer share a single global context. Fixed the vast majority of *real* issues reported by badssl.com. Removed old manual ECDH negotation key generation for server contexts and replaced with an openSSL option to auto handle this process. Added i-case string hash and equality functors based on boost for i-case string key hashmaps. Fixes TechnikEmpire#127 Fixes TechnikEmpire#113
1 parent a8ebfe7 commit 6cffd96

14 files changed

Lines changed: 190 additions & 39 deletions

ide/msvc/AssemblyInfo.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ using namespace System::Security::Permissions;
3939
// You can specify all the value or you can default the Revision and Build Numbers
4040
// by using the '*' as shown below:
4141

42-
[assembly:AssemblyVersionAttribute("2.0.1")];
42+
[assembly:AssemblyVersionAttribute("2.0.2")];
4343

4444
[assembly:ComVisible(false)];
4545

ide/msvc/HttpFe.Common/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,5 @@
3232
//
3333
// You can specify all the values or you can default the Build and Revision Numbers by using the '*'
3434
// as shown below: [assembly: AssemblyVersion("1.0.*")]
35-
[assembly: AssemblyVersion("2.0.1.0")]
36-
[assembly: AssemblyFileVersion("2.0.1.0")]
35+
[assembly: AssemblyVersion("2.0.2.0")]
36+
[assembly: AssemblyFileVersion("2.0.2.0")]

ide/msvc/HttpFe.Managed/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,5 @@
3232
//
3333
// You can specify all the values or you can default the Build and Revision Numbers by using the '*'
3434
// as shown below: [assembly: AssemblyVersion("1.0.*")]
35-
[assembly: AssemblyVersion("2.0.1.0")]
36-
[assembly: AssemblyFileVersion("2.0.1.0")]
35+
[assembly: AssemblyVersion("2.0.2.0")]
36+
[assembly: AssemblyFileVersion("2.0.2.0")]

ide/msvc/Tests/Program.cs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,20 @@
88
using HttpFe.Common;
99
using HttpFe.Managed;
1010
using System;
11+
using System.Threading;
1112

1213
namespace Tests
1314
{
1415
internal class Program
1516
{
16-
private static volatile bool s_running = false;
17+
private static ManualResetEvent s_rstEvent = new ManualResetEvent(false);
1718

1819
private static void Main(string[] args)
1920
{
2021
Console.CancelKeyPress += (sender, eArgs) =>
2122
{
2223
Console.WriteLine("Ctrl+C detected. Terminating.");
23-
s_running = false;
24+
s_rstEvent.Set();
2425
};
2526

2627
try
@@ -51,11 +52,7 @@ private static void RunProgram()
5152
engine.OnError += OnError;
5253

5354
engine.Start();
54-
s_running = true;
55-
56-
while(s_running)
57-
{
58-
}
55+
s_rstEvent.WaitOne();
5956

6057
engine.Stop();
6158
}

ide/msvc/Tests/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,5 @@
3232
// You can specify all the values or you can default the Build and Revision Numbers
3333
// by using the '*' as shown below:
3434
// [assembly: AssemblyVersion("1.0.*")]
35-
[assembly: AssemblyVersion("2.0.1.0")]
36-
[assembly: AssemblyFileVersion("2.0.1.0")]
35+
[assembly: AssemblyVersion("2.0.2.0")]
36+
[assembly: AssemblyFileVersion("2.0.2.0")]

ide/msvc/Tests/Tests.csproj

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,16 @@
5959
<None Include="App.config" />
6060
<None Include="app.manifest" />
6161
</ItemGroup>
62+
<ItemGroup>
63+
<ProjectReference Include="..\HttpFe.Common\HttpFe.Common.csproj">
64+
<Project>{64938257-0baa-4e25-9f44-715ff8c9828c}</Project>
65+
<Name>HttpFe.Common</Name>
66+
</ProjectReference>
67+
<ProjectReference Include="..\HttpFe.Managed\HttpFe.Managed.csproj">
68+
<Project>{0940a14e-98a1-44ed-b6f0-a9370610a761}</Project>
69+
<Name>HttpFe.Managed</Name>
70+
</ProjectReference>
71+
</ItemGroup>
6272
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
6373
<PropertyGroup>
6474
<PostBuildEvent>xcopy /D /Y /S /E "$(SolutionDir)..\..\build\HttpFe.Managed\$(Configuration)\*.*" "$(TargetDir)"</PostBuildEvent>

ide/msvc/libhttpfilteringengine.vcxproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -559,6 +559,7 @@ xcopy /Y "$(ProjectDir)..\..\deps\windivert\msvc\x64\*.sys" "$(OutDir)"</Command
559559
<ClInclude Include="..\..\src\te\httpengine\network\SocketTypes.hpp" />
560560
<ClInclude Include="..\..\src\te\httpengine\util\cb\EngineCallbackTypes.h" />
561561
<ClInclude Include="..\..\src\te\httpengine\util\cb\EventReporter.hpp" />
562+
<ClInclude Include="..\..\src\te\httpengine\util\hash\StringHashUtils.hpp" />
562563
<ClInclude Include="..\..\src\te\util\http\KnownHttpHeaders.hpp" />
563564
<ClInclude Include="..\..\src\te\util\string\StringRefUtil.hpp" />
564565
<ClInclude Include="resource.h" />

ide/msvc/libhttpfilteringengine.vcxproj.filters

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,9 @@
127127
<Filter Include="Header Files\cpprestsdk">
128128
<UniqueIdentifier>{4f0dbcad-9dd2-4ec2-88d0-b9db517d6c3d}</UniqueIdentifier>
129129
</Filter>
130+
<Filter Include="Header Files\te\httpengine\util\hash">
131+
<UniqueIdentifier>{e858d8bc-1735-4271-b0f2-155dc53f2a87}</UniqueIdentifier>
132+
</Filter>
130133
</ItemGroup>
131134
<ItemGroup>
132135
<ClInclude Include="resource.h">
@@ -189,6 +192,9 @@
189192
<ClInclude Include="..\..\contrib\cpprestsdk\src\http\client\x509_cert_utilities.h">
190193
<Filter>Header Files\cpprestsdk</Filter>
191194
</ClInclude>
195+
<ClInclude Include="..\..\src\te\httpengine\util\hash\StringHashUtils.hpp">
196+
<Filter>Header Files\te\httpengine\util\hash</Filter>
197+
</ClInclude>
192198
</ItemGroup>
193199
<ItemGroup>
194200
<ClCompile Include="AssemblyInfo.cpp">

nuget/HttpFilteringEngine.nuspec

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
<package >
33
<metadata>
44
<id>HttpFilteringEngine</id>
5-
<version>2.0.1</version>
5+
<version>2.0.2</version>
66
<title>HttpFilteringEngine</title>
77
<authors>TechnikEmpire</authors>
8-
<releaseNotes>Forced .NET framework version to 4.6. Fixed IPV6 filtering so it now functions.</releaseNotes>
8+
<releaseNotes>We now create an isolated, unique TLS context for every unique host connected to.</releaseNotes>
99
<owners>TechnikEmpire</owners>
1010
<projectUrl>https://github.com/TechnikEmpire/HttpFilteringEngine</projectUrl>
1111
<requireLicenseAcceptance>true</requireLicenseAcceptance>

src/te/httpengine/mitm/secure/BaseInMemoryCertificateStore.cpp

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -275,24 +275,7 @@ namespace te
275275

276276
SSL_CTX_set_options(ctx->native_handle(), SSL_OP_CIPHER_SERVER_PREFERENCE);
277277

278-
EC_KEY* tmpNegotiationEcKey;
279-
280-
if (nullptr == (tmpNegotiationEcKey = EC_KEY_new_by_curve_name(NID_X9_62_prime256v1)))
281-
{
282-
EVP_PKEY_free(spoofedCertKeypair);
283-
X509_free(spoofedCert);
284-
throw std::runtime_error(u8"In BaseInMemoryCertificateStore::GetServerContext(std::string, X509*) - Failed to allocate server context temporary negotiation EC key.");
285-
}
286-
287-
if (EC_KEY_generate_key(tmpNegotiationEcKey) != 1)
288-
{
289-
EC_KEY_free(tmpNegotiationEcKey);
290-
EVP_PKEY_free(spoofedCertKeypair);
291-
X509_free(spoofedCert);
292-
throw std::runtime_error(u8"In BaseInMemoryCertificateStore::GetServerContext(std::string, X509*) - Failed to generate server context temporary negotiation EC key.");
293-
}
294-
295-
SSL_CTX_set_tmp_ecdh(ctx->native_handle(), tmpNegotiationEcKey);
278+
SSL_CTX_set_ecdh_auto(ctx->native_handle(), 1);
296279

297280
bool atLeastOneInsert = false;
298281

@@ -318,8 +301,7 @@ namespace te
318301
{
319302
// In this case, either the user has made an error and is duplicating data, or perhaps
320303
// something more dirty is going on, where we have spoofed a certificate that is lying
321-
// about its SN and or SAN's.
322-
EC_KEY_free(tmpNegotiationEcKey);
304+
// about its SN and or SAN's.
323305
EVP_PKEY_free(spoofedCertKeypair);
324306
X509_free(spoofedCert);
325307
delete ctx;

0 commit comments

Comments
 (0)