From 361d40189b5ebd2d6d79c88ee591837c22b53b0a Mon Sep 17 00:00:00 2001 From: Stef Heyenrath Date: Fri, 2 Feb 2018 22:52:08 +0100 Subject: [PATCH] Fixed https proxy for netstandard 1.3 and netstandard 2.0 (#85) --- WireMock.Net Solution.sln | 18 ++- .../WireMock.Net.Console.NETCoreApp.csproj | 2 +- .../Program.cs | 36 ++++++ .../Properties/launchSettings.json | 27 +++++ ...eMock.Net.Console.Proxy.NETCoreApp2.csproj | 18 +++ .../App.config | 6 + .../Program.cs | 36 ++++++ .../Properties/AssemblyInfo.cs | 35 ++++++ .../WireMock.Net.Console.Proxy.Net452.csproj | 105 ++++++++++++++++++ .../packages.config | 5 + .../Program.cs | 2 +- ...eMock.Net.Console.Proxy.NETCoreApp.csproj} | 6 +- .../WireMock.Net.StandAlone.csproj | 12 +- src/WireMock.Net/Http/HttpClientHelper.cs | 6 +- src/WireMock.Net/Http/PortUtil.cs | 2 +- src/WireMock.Net/Owin/AspNetCoreSelfHost.cs | 45 +++++++- src/WireMock.Net/Server/FluentMockServer.cs | 2 +- src/WireMock.Net/WireMock.Net.csproj | 17 ++- src/WireMock.Net/self-signed-certificate.pfx | Bin 0 -> 4150 bytes 19 files changed, 356 insertions(+), 24 deletions(-) create mode 100644 examples/WireMock.Net.Console.Proxy.NETCoreApp2/Program.cs create mode 100644 examples/WireMock.Net.Console.Proxy.NETCoreApp2/Properties/launchSettings.json create mode 100644 examples/WireMock.Net.Console.Proxy.NETCoreApp2/WireMock.Net.Console.Proxy.NETCoreApp2.csproj create mode 100644 examples/WireMock.Net.Console.Proxy.Net452/App.config create mode 100644 examples/WireMock.Net.Console.Proxy.Net452/Program.cs create mode 100644 examples/WireMock.Net.Console.Proxy.Net452/Properties/AssemblyInfo.cs create mode 100644 examples/WireMock.Net.Console.Proxy.Net452/WireMock.Net.Console.Proxy.Net452.csproj create mode 100644 examples/WireMock.Net.Console.Proxy.Net452/packages.config rename examples/WireMock.Net.Console.Record.NETCoreApp/{WireMock.Net.Console.Record.NETCoreApp.csproj => WireMock.Net.Console.Proxy.NETCoreApp.csproj} (69%) create mode 100644 src/WireMock.Net/self-signed-certificate.pfx diff --git a/WireMock.Net Solution.sln b/WireMock.Net Solution.sln index 41e1226b..f0ddcdb9 100644 --- a/WireMock.Net Solution.sln +++ b/WireMock.Net Solution.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 15 -VisualStudioVersion = 15.0.27130.2020 +VisualStudioVersion = 15.0.27130.2027 MinimumVisualStudioVersion = 10.0.40219.1 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{EF242EDF-7133-4277-9A0C-18744DE08707}" EndProject @@ -23,7 +23,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WireMock.Net.Tests", "test\ EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WireMock.Net.Console.NETCoreApp", "examples\WireMock.Net.Console.NETCoreApp\WireMock.Net.Console.NETCoreApp.csproj", "{FE281639-B014-4C8A-96FA-141164A74713}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WireMock.Net.Console.Record.NETCoreApp", "examples\WireMock.Net.Console.Record.NETCoreApp\WireMock.Net.Console.Record.NETCoreApp.csproj", "{1995E414-F197-4AB4-90C2-68D806B5AF59}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WireMock.Net.Console.Proxy.NETCoreApp", "examples\WireMock.Net.Console.Record.NETCoreApp\WireMock.Net.Console.Proxy.NETCoreApp.csproj", "{1995E414-F197-4AB4-90C2-68D806B5AF59}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WireMock.Net.Client", "examples\WireMock.Net.Client\WireMock.Net.Client.csproj", "{058D4B6C-C03E-49D0-91DB-A535B058FA0D}" EndProject @@ -40,6 +40,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WireMock.Net.Console.NET452 EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WireMock.Net.WebApplication", "examples\WireMock.Net.WebApplication\WireMock.Net.WebApplication.csproj", "{049539C1-7A66-4559-AD7A-B1C73B97CBB0}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WireMock.Net.Console.Proxy.Net452", "examples\WireMock.Net.Console.Proxy.Net452\WireMock.Net.Console.Proxy.Net452.csproj", "{26433A8F-BF01-4962-97EB-81BFFBB61096}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WireMock.Net.Console.Proxy.NETCoreApp2", "examples\WireMock.Net.Console.Proxy.NETCoreApp2\WireMock.Net.Console.Proxy.NETCoreApp2.csproj", "{23A9AA3C-40FC-42AA-8A5E-05899795A1C6}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -86,6 +90,14 @@ Global {049539C1-7A66-4559-AD7A-B1C73B97CBB0}.Debug|Any CPU.Build.0 = Debug|Any CPU {049539C1-7A66-4559-AD7A-B1C73B97CBB0}.Release|Any CPU.ActiveCfg = Release|Any CPU {049539C1-7A66-4559-AD7A-B1C73B97CBB0}.Release|Any CPU.Build.0 = Release|Any CPU + {26433A8F-BF01-4962-97EB-81BFFBB61096}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {26433A8F-BF01-4962-97EB-81BFFBB61096}.Debug|Any CPU.Build.0 = Debug|Any CPU + {26433A8F-BF01-4962-97EB-81BFFBB61096}.Release|Any CPU.ActiveCfg = Release|Any CPU + {26433A8F-BF01-4962-97EB-81BFFBB61096}.Release|Any CPU.Build.0 = Release|Any CPU + {23A9AA3C-40FC-42AA-8A5E-05899795A1C6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {23A9AA3C-40FC-42AA-8A5E-05899795A1C6}.Debug|Any CPU.Build.0 = Debug|Any CPU + {23A9AA3C-40FC-42AA-8A5E-05899795A1C6}.Release|Any CPU.ActiveCfg = Release|Any CPU + {23A9AA3C-40FC-42AA-8A5E-05899795A1C6}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -101,6 +113,8 @@ Global {668F689E-57B4-422E-8846-C0FF643CA999} = {F0C22C47-DF71-463C-9B04-B4E0F3B8708A} {668F689E-57B4-422E-8846-C0FF643CA268} = {F0C22C47-DF71-463C-9B04-B4E0F3B8708A} {049539C1-7A66-4559-AD7A-B1C73B97CBB0} = {F0C22C47-DF71-463C-9B04-B4E0F3B8708A} + {26433A8F-BF01-4962-97EB-81BFFBB61096} = {F0C22C47-DF71-463C-9B04-B4E0F3B8708A} + {23A9AA3C-40FC-42AA-8A5E-05899795A1C6} = {F0C22C47-DF71-463C-9B04-B4E0F3B8708A} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {BF428BCC-C837-433B-87D2-15C7014B73E9} diff --git a/examples/WireMock.Net.Console.NETCoreApp/WireMock.Net.Console.NETCoreApp.csproj b/examples/WireMock.Net.Console.NETCoreApp/WireMock.Net.Console.NETCoreApp.csproj index 5448a240..37a4ed8d 100644 --- a/examples/WireMock.Net.Console.NETCoreApp/WireMock.Net.Console.NETCoreApp.csproj +++ b/examples/WireMock.Net.Console.NETCoreApp/WireMock.Net.Console.NETCoreApp.csproj @@ -22,7 +22,7 @@ - + diff --git a/examples/WireMock.Net.Console.Proxy.NETCoreApp2/Program.cs b/examples/WireMock.Net.Console.Proxy.NETCoreApp2/Program.cs new file mode 100644 index 00000000..3fa7bf11 --- /dev/null +++ b/examples/WireMock.Net.Console.Proxy.NETCoreApp2/Program.cs @@ -0,0 +1,36 @@ +using Newtonsoft.Json; +using WireMock.Server; +using WireMock.Settings; + +namespace WireMock.Net.Console.Proxy.NETCoreApp2 +{ + class Program + { + static void Main(string[] args) + { + var server = FluentMockServer.Start(new FluentMockServerSettings + { + Urls = new[] { "http://localhost:9091", "https://localhost:9443" }, + StartAdminInterface = true, + ReadStaticMappings = false, + ProxyAndRecordSettings = new ProxyAndRecordSettings + { + Url = "https://www.google.com", + //X509Certificate2ThumbprintOrSubjectName = "www.yourclientcertname.com OR yourcertificatethumbprint (only if the service you're proxying to requires it)", + SaveMapping = true, + SaveMappingToFile = false, + BlackListedHeaders = new[] { "dnt", "Content-Length" } + } + }); + + server.LogEntriesChanged += (sender, eventRecordArgs) => + { + System.Console.WriteLine(JsonConvert.SerializeObject(eventRecordArgs.NewItems, Formatting.Indented)); + }; + + System.Console.WriteLine("Press any key to stop the server"); + System.Console.ReadKey(); + server.Stop(); + } + } +} diff --git a/examples/WireMock.Net.Console.Proxy.NETCoreApp2/Properties/launchSettings.json b/examples/WireMock.Net.Console.Proxy.NETCoreApp2/Properties/launchSettings.json new file mode 100644 index 00000000..616b68b0 --- /dev/null +++ b/examples/WireMock.Net.Console.Proxy.NETCoreApp2/Properties/launchSettings.json @@ -0,0 +1,27 @@ +{ + "iisSettings": { + "windowsAuthentication": false, + "anonymousAuthentication": true, + "iisExpress": { + "applicationUrl": "http://localhost:63377/", + "sslPort": 0 + } + }, + "profiles": { + "IIS Express": { + "commandName": "IISExpress", + "launchBrowser": true, + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "WireMock.Net.Console.Proxy.NETCoreApp2": { + "commandName": "Project", + "launchBrowser": true, + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + }, + "applicationUrl": "http://localhost:63378/" + } + } +} \ No newline at end of file diff --git a/examples/WireMock.Net.Console.Proxy.NETCoreApp2/WireMock.Net.Console.Proxy.NETCoreApp2.csproj b/examples/WireMock.Net.Console.Proxy.NETCoreApp2/WireMock.Net.Console.Proxy.NETCoreApp2.csproj new file mode 100644 index 00000000..08a0483c --- /dev/null +++ b/examples/WireMock.Net.Console.Proxy.NETCoreApp2/WireMock.Net.Console.Proxy.NETCoreApp2.csproj @@ -0,0 +1,18 @@ + + + + Exe + netcoreapp2.0 + ../../WireMock.Net-Logo.ico + + + + + + + + + + + + diff --git a/examples/WireMock.Net.Console.Proxy.Net452/App.config b/examples/WireMock.Net.Console.Proxy.Net452/App.config new file mode 100644 index 00000000..8227adb9 --- /dev/null +++ b/examples/WireMock.Net.Console.Proxy.Net452/App.config @@ -0,0 +1,6 @@ + + + + + + diff --git a/examples/WireMock.Net.Console.Proxy.Net452/Program.cs b/examples/WireMock.Net.Console.Proxy.Net452/Program.cs new file mode 100644 index 00000000..78df8f0d --- /dev/null +++ b/examples/WireMock.Net.Console.Proxy.Net452/Program.cs @@ -0,0 +1,36 @@ +using Newtonsoft.Json; +using WireMock.Server; +using WireMock.Settings; + +namespace WireMock.Net.Console.Proxy.Net452 +{ + class Program + { + static void Main(string[] args) + { + var server = FluentMockServer.Start(new FluentMockServerSettings + { + Urls = new[] { "http://localhost:9091/", "https://localhost:9443/" }, + StartAdminInterface = true, + ReadStaticMappings = false, + ProxyAndRecordSettings = new ProxyAndRecordSettings + { + Url = "https://www.google.com", + //X509Certificate2ThumbprintOrSubjectName = "www.yourclientcertname.com OR yourcertificatethumbprint (only if the service you're proxying to requires it)", + SaveMapping = true, + SaveMappingToFile = false, + BlackListedHeaders = new[] { "dnt", "Content-Length" } + } + }); + + server.LogEntriesChanged += (sender, eventRecordArgs) => + { + System.Console.WriteLine(JsonConvert.SerializeObject(eventRecordArgs.NewItems, Formatting.Indented)); + }; + + System.Console.WriteLine("Press any key to stop the server"); + System.Console.ReadKey(); + server.Stop(); + } + } +} \ No newline at end of file diff --git a/examples/WireMock.Net.Console.Proxy.Net452/Properties/AssemblyInfo.cs b/examples/WireMock.Net.Console.Proxy.Net452/Properties/AssemblyInfo.cs new file mode 100644 index 00000000..60253665 --- /dev/null +++ b/examples/WireMock.Net.Console.Proxy.Net452/Properties/AssemblyInfo.cs @@ -0,0 +1,35 @@ +using System.Reflection; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("WireMock.Net.Console.Proxy.Net452")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("WireMock.Net.Console.Proxy.Net452")] +[assembly: AssemblyCopyright("Copyright © Stef Heyenrath 2018")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("26433a8f-bf01-4962-97eb-81bffbb61096")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/examples/WireMock.Net.Console.Proxy.Net452/WireMock.Net.Console.Proxy.Net452.csproj b/examples/WireMock.Net.Console.Proxy.Net452/WireMock.Net.Console.Proxy.Net452.csproj new file mode 100644 index 00000000..04605b1a --- /dev/null +++ b/examples/WireMock.Net.Console.Proxy.Net452/WireMock.Net.Console.Proxy.Net452.csproj @@ -0,0 +1,105 @@ + + + + + Debug + AnyCPU + {26433A8F-BF01-4962-97EB-81BFFBB61096} + Exe + WireMock.Net.Console.Proxy.Net452 + WireMock.Net.Console.Proxy.Net452 + v4.5.2 + 512 + true + + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + WireMock.Net.Console.Proxy.Net452.Program + + + true + bin\x64\Debug\ + DEBUG;TRACE + full + x64 + prompt + MinimumRecommendedRules.ruleset + true + + + bin\x64\Release\ + TRACE + true + pdbonly + x64 + prompt + MinimumRecommendedRules.ruleset + true + + + + PreserveNewest + False + libuv.dll + + + PreserveNewest + False + libuv.dll + + + + + ..\..\packages\Microsoft.Owin.Host.HttpListener.3.1.0\lib\net45\Microsoft.Owin.Host.HttpListener.dll + + + ..\..\packages\Newtonsoft.Json.10.0.3\lib\net45\Newtonsoft.Json.dll + + + + + + + + + + + + + + + + + + + + + {b6269aac-170a-43d5-8b9a-579ded3d9a95} + WireMock.Net.StandAlone + + + {d3804228-91f4-4502-9595-39584e5a01ad} + WireMock.Net + + + + \ No newline at end of file diff --git a/examples/WireMock.Net.Console.Proxy.Net452/packages.config b/examples/WireMock.Net.Console.Proxy.Net452/packages.config new file mode 100644 index 00000000..524c4b7b --- /dev/null +++ b/examples/WireMock.Net.Console.Proxy.Net452/packages.config @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/examples/WireMock.Net.Console.Record.NETCoreApp/Program.cs b/examples/WireMock.Net.Console.Record.NETCoreApp/Program.cs index 8f7c3712..f70e493e 100644 --- a/examples/WireMock.Net.Console.Record.NETCoreApp/Program.cs +++ b/examples/WireMock.Net.Console.Record.NETCoreApp/Program.cs @@ -2,7 +2,7 @@ using WireMock.Server; using WireMock.Settings; -namespace WireMock.Net.Console.Record.NETCoreApp +namespace WireMock.Net.Console.Proxy.NETCoreApp { static class Program { diff --git a/examples/WireMock.Net.Console.Record.NETCoreApp/WireMock.Net.Console.Record.NETCoreApp.csproj b/examples/WireMock.Net.Console.Record.NETCoreApp/WireMock.Net.Console.Proxy.NETCoreApp.csproj similarity index 69% rename from examples/WireMock.Net.Console.Record.NETCoreApp/WireMock.Net.Console.Record.NETCoreApp.csproj rename to examples/WireMock.Net.Console.Record.NETCoreApp/WireMock.Net.Console.Proxy.NETCoreApp.csproj index 7e9abd17..23d023f3 100644 --- a/examples/WireMock.Net.Console.Record.NETCoreApp/WireMock.Net.Console.Record.NETCoreApp.csproj +++ b/examples/WireMock.Net.Console.Record.NETCoreApp/WireMock.Net.Console.Proxy.NETCoreApp.csproj @@ -6,13 +6,9 @@ ../../WireMock.Net-Logo.ico - - - - - + diff --git a/src/WireMock.Net.StandAlone/WireMock.Net.StandAlone.csproj b/src/WireMock.Net.StandAlone/WireMock.Net.StandAlone.csproj index c1a85fb4..f6b85c9b 100644 --- a/src/WireMock.Net.StandAlone/WireMock.Net.StandAlone.csproj +++ b/src/WireMock.Net.StandAlone/WireMock.Net.StandAlone.csproj @@ -1,4 +1,4 @@ - + Lightweight StandAlone Http Mocking Server for .Net. @@ -16,11 +16,17 @@ https://raw.githubusercontent.com/WireMock-Net/WireMock.Net/master/LICENSE git https://github.com/WireMock-Net/WireMock.Net - True - portable ../../WireMock.Net-Logo.ico WireMock.Net.StandAlone + + + full + True + True + $(MSBuildProjectDirectory)=/ + true + NETSTANDARD diff --git a/src/WireMock.Net/Http/HttpClientHelper.cs b/src/WireMock.Net/Http/HttpClientHelper.cs index 7a7b411f..ffe55f1c 100644 --- a/src/WireMock.Net/Http/HttpClientHelper.cs +++ b/src/WireMock.Net/Http/HttpClientHelper.cs @@ -43,7 +43,11 @@ namespace WireMock.Http // If UseCookies enabled, httpClient ignores Cookie header handler.UseCookies = false; - return new HttpClient(handler); + var client = new HttpClient(handler); +#if NET452 || NET46 + ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls; +#endif + return client; } public static async Task SendAsync(HttpClient client, RequestMessage requestMessage, string url) diff --git a/src/WireMock.Net/Http/PortUtil.cs b/src/WireMock.Net/Http/PortUtil.cs index 4ebba7df..519a9902 100644 --- a/src/WireMock.Net/Http/PortUtil.cs +++ b/src/WireMock.Net/Http/PortUtil.cs @@ -37,7 +37,7 @@ namespace WireMock.Http public static bool TryExtractProtocolAndPort(string url, out string proto, out int port) { proto = null; - port = -1; + port = 0; Match m = UrlDetailsRegex.Match(url); if (m.Success) diff --git a/src/WireMock.Net/Owin/AspNetCoreSelfHost.cs b/src/WireMock.Net/Owin/AspNetCoreSelfHost.cs index 18e64581..f8e05bac 100644 --- a/src/WireMock.Net/Owin/AspNetCoreSelfHost.cs +++ b/src/WireMock.Net/Owin/AspNetCoreSelfHost.cs @@ -1,5 +1,8 @@ #if NETSTANDARD +using System; using System.Collections.Generic; +using System.Linq; +using System.Net; using System.Threading; using System.Threading.Tasks; using JetBrains.Annotations; @@ -14,7 +17,7 @@ namespace WireMock.Owin { private readonly CancellationTokenSource _cts = new CancellationTokenSource(); private readonly WireMockMiddlewareOptions _options; - private readonly string[] _uriPrefixes; + private readonly string[] _urls; private IWebHost _host; @@ -38,7 +41,7 @@ namespace WireMock.Owin } _options = options; - _uriPrefixes = uriPrefixes; + _urls = uriPrefixes; } public Task StartAsync() @@ -51,12 +54,38 @@ namespace WireMock.Owin appBuilder.UseMiddleware(_options); _options.PostWireMockMiddlewareInit?.Invoke(appBuilder); }) - .UseKestrel() - .UseUrls(_uriPrefixes) + .UseKestrel(options => + { +#if NETSTANDARD1_3 + if (_urls.Any(u => u.StartsWith("https://", StringComparison.OrdinalIgnoreCase))) + { + options.UseHttps("self-signed-certificate.pfx"); + } +#else + // https://docs.microsoft.com/en-us/aspnet/core/fundamentals/servers/kestrel?tabs=aspnetcore2x + foreach (string url in _urls.Where(u => u.StartsWith("http://", StringComparison.OrdinalIgnoreCase))) + { + PortUtil.TryExtractProtocolAndPort(url, out string host, out int port); + options.Listen(IPAddress.Loopback, port); + } + + foreach (string url in _urls.Where(u => u.StartsWith("https://", StringComparison.OrdinalIgnoreCase))) + { + PortUtil.TryExtractProtocolAndPort(url, out string host, out int port); + options.Listen(IPAddress.Loopback, port, listenOptions => + { + listenOptions.UseHttps("self-signed-certificate.pfx"); + }); + } +#endif + }) +#if NETSTANDARD1_3 + .UseUrls(_urls) +#endif .Build(); #if NETSTANDARD1_3 - System.Console.WriteLine("WireMock.Net server using netstandard1.3"); + Console.WriteLine("WireMock.Net server using netstandard1.3"); return Task.Run(() => { _host.Run(_cts.Token); @@ -65,7 +94,11 @@ namespace WireMock.Owin #else System.Console.WriteLine("WireMock.Net server using netstandard2.0"); IsStarted = true; - return _host.RunAsync(_cts.Token); + return Task.Run(() => + { + _host.Run(); + IsStarted = true; + }, _cts.Token); #endif } diff --git a/src/WireMock.Net/Server/FluentMockServer.cs b/src/WireMock.Net/Server/FluentMockServer.cs index 156d94cb..b2e55cc3 100644 --- a/src/WireMock.Net/Server/FluentMockServer.cs +++ b/src/WireMock.Net/Server/FluentMockServer.cs @@ -157,7 +157,7 @@ namespace WireMock.Server { if (settings.Urls != null) { - Urls = settings.Urls; + Urls = settings.Urls.Select(u => u.EndsWith("/") ? u : $"{u}/").ToArray(); } else { diff --git a/src/WireMock.Net/WireMock.Net.csproj b/src/WireMock.Net/WireMock.Net.csproj index 3cea9b91..22915689 100644 --- a/src/WireMock.Net/WireMock.Net.csproj +++ b/src/WireMock.Net/WireMock.Net.csproj @@ -16,12 +16,16 @@ https://raw.githubusercontent.com/WireMock-Net/WireMock.Net/master/LICENSE git https://github.com/WireMock-Net/WireMock.Net - True ../../WireMock.Net-Logo.ico WireMock - full + + + + full True True + $(MSBuildProjectDirectory)=/ + true @@ -33,7 +37,7 @@ All - + @@ -52,6 +56,7 @@ + @@ -61,4 +66,10 @@ + + + PreserveNewest + + + \ No newline at end of file diff --git a/src/WireMock.Net/self-signed-certificate.pfx b/src/WireMock.Net/self-signed-certificate.pfx new file mode 100644 index 0000000000000000000000000000000000000000..a3bf2a055972c1c1476ddb055c7c0d5d44f0bfae GIT binary patch literal 4150 zcmZWrcTm&cvi}A`fY7B#2Pr|Sp#+d7f(eKeDJmG65Sj=`uOfsh9TX{sP=bOq5u^pA zN|z=bqVyu5AYF>y{O-JW@4R`lvwQY@KA+v4^Us-uW0~bBK$LJS(@zMkM6_=75d(-C zl!s-S17n$H$?zl`3yu9h6f_Wwh5C|VPqMo~=>DgQ9txt!!_tPrv9v*OUI_GmVRCau zFilM|$v07HESQ3VdKiqQHFr%Gy=L7U*AvZRb~;4qZv#ng-HUPfq*}v#jh>0l(GT5b zI2k=U_{bXV(6+Ylecr}a?9wHdU`&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