mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-04-25 17:58:33 +02:00
Version 2.x
This commit is contained in:
@@ -1,12 +1,11 @@
|
||||
// Copyright © WireMock.Net
|
||||
|
||||
#if USE_ASPNETCORE && !NETSTANDARD1_3
|
||||
//#if USE_ASPNETCORE && !NETSTANDARD1_3
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Net;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.AspNetCore.Server.Kestrel.Core;
|
||||
using Microsoft.AspNetCore.Server.Kestrel.Https;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using CertificateLoader = WireMock.HttpsCertificate.CertificateLoader;
|
||||
@@ -38,7 +37,7 @@ internal partial class AspNetCoreSelfHost
|
||||
options.ServerCertificate = CertificateLoader.LoadCertificate(wireMockMiddlewareOptions, urlDetail.Host);
|
||||
}
|
||||
|
||||
options.ClientCertificateMode = (ClientCertificateMode)wireMockMiddlewareOptions.ClientCertificateMode;
|
||||
options.ClientCertificateMode = wireMockMiddlewareOptions.ClientCertificateMode;
|
||||
if (wireMockMiddlewareOptions.AcceptAnyClientCertificate)
|
||||
{
|
||||
options.ClientCertificateValidation = (_, _, _) => true;
|
||||
@@ -47,7 +46,7 @@ internal partial class AspNetCoreSelfHost
|
||||
|
||||
if (urlDetail.IsHttp2)
|
||||
{
|
||||
listenOptions.Protocols = HttpProtocols.Http2;
|
||||
SetHttp2AsProtocolsOnListenOptions(listenOptions);
|
||||
}
|
||||
});
|
||||
continue;
|
||||
@@ -55,10 +54,7 @@ internal partial class AspNetCoreSelfHost
|
||||
|
||||
if (urlDetail.IsHttp2)
|
||||
{
|
||||
Listen(kestrelOptions, urlDetail, listenOptions =>
|
||||
{
|
||||
listenOptions.Protocols = HttpProtocols.Http2;
|
||||
});
|
||||
Listen(kestrelOptions, urlDetail, SetHttp2AsProtocolsOnListenOptions);
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -66,6 +62,15 @@ internal partial class AspNetCoreSelfHost
|
||||
}
|
||||
}
|
||||
|
||||
private static void SetHttp2AsProtocolsOnListenOptions(ListenOptions listenOptions)
|
||||
{
|
||||
#if NET8_0_OR_GREATER
|
||||
listenOptions.Protocols = HttpProtocols.Http2;
|
||||
#else
|
||||
throw new NotSupportedException("HTTP/2 is only supported in .NET 8 or greater.");
|
||||
#endif
|
||||
}
|
||||
|
||||
private static void Listen(KestrelServerOptions kestrelOptions, HostUrlDetails urlDetail, Action<ListenOptions> configure)
|
||||
{
|
||||
// Listens on any IP with the given port.
|
||||
@@ -112,4 +117,4 @@ internal static class IWebHostBuilderExtensions
|
||||
});
|
||||
}
|
||||
}
|
||||
#endif
|
||||
//#endif
|
||||
Reference in New Issue
Block a user