Files
Krishnendu Ghosh 1d3eda9a74 SNI Support (ported netty SniHandler) (#219)
* First cut commit *unfinished

* Replace SNI handler with TlsHandler with certificate selected based on host name found in clientHello

* first cut tests for SniHandler

* test update

* Test update

* Supress further read when handler is replaced

* made the snitest more effective and IDN in hostname lower case as per netty impl

* More asserts to check whether snihandler gets replaces with tlshaldler in the pipeline

* assert server name is always found in clienthello as per the test setup

* Provided option to select default host name in case of error or client hello does not contail SNI extension, otherwise handshake fails in those cases

* More elaborate tests

* verbosity in test

* Fixed Read continues to get called after handler removed and removed the workaround in SniHandler

* relaced goto statement with flag for breaking outer for loop from within switch

* Update SniHandler.cs

* trigger CI build

* addressed review comments

* Fixed task continuation option

* addresses further review comments

* triggere build again with some more assert in test #221

* suppress read logic is still needed due to async "void"

*  changing the map to (string -> Task<ServerTlsSettings)

* one more constructor overload

* extensive tls read/write test is not needed since that's already done in tlshandler test

* more readable target host validation in test to force retrigger confusing CI build

* retrigger

* addressed review comment "this generates 30 random data frames. pls replace with new [] { 1 }"
2017-03-29 02:27:53 -07:00

38 lines
1.4 KiB
C#

// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
namespace DotNetty.Tests.Common
{
using System.IO;
using System.Reflection;
using System.Security.Cryptography.X509Certificates;
public static class TestResourceHelper
{
public static X509Certificate2 GetTestCertificate()
{
byte[] certData;
using (Stream resStream = typeof(TestResourceHelper).GetTypeInfo().Assembly.GetManifestResourceStream(typeof(TestResourceHelper).Namespace + "." + "dotnetty.com.pfx"))
using (var memStream = new MemoryStream())
{
resStream.CopyTo(memStream);
certData = memStream.ToArray();
}
return new X509Certificate2(certData, "password");
}
public static X509Certificate2 GetTestCertificate2()
{
byte[] certData;
using (Stream resStream = typeof(TestResourceHelper).GetTypeInfo().Assembly.GetManifestResourceStream(typeof(TestResourceHelper).Namespace + "." + "contoso.com.pfx"))
using (var memStream = new MemoryStream())
{
resStream.CopyTo(memStream);
certData = memStream.ToArray();
}
return new X509Certificate2(certData, "password");
}
}
}