diff --git a/src/Microsoft.AspNetCore.Server.Kestrel.Core/Internal/ServerAddressesFeature.cs b/src/Microsoft.AspNetCore.Server.Kestrel.Core/Internal/ServerAddressesFeature.cs new file mode 100644 index 0000000000..76a9d960b5 --- /dev/null +++ b/src/Microsoft.AspNetCore.Server.Kestrel.Core/Internal/ServerAddressesFeature.cs @@ -0,0 +1,16 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using System.Collections.Generic; +using System.Text; +using Microsoft.AspNetCore.Hosting.Server.Features; + +namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal +{ + internal class ServerAddressesFeature : IServerAddressesFeature + { + public ICollection Addresses { get; } = new List(); + public bool PreferHostingUrls { get; set; } + } +} diff --git a/src/Microsoft.AspNetCore.Server.Kestrel.Core/KestrelServer.cs b/src/Microsoft.AspNetCore.Server.Kestrel.Core/KestrelServer.cs index 2b8678b5ff..3958755ea1 100644 --- a/src/Microsoft.AspNetCore.Server.Kestrel.Core/KestrelServer.cs +++ b/src/Microsoft.AspNetCore.Server.Kestrel.Core/KestrelServer.cs @@ -12,6 +12,7 @@ using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting.Server; using Microsoft.AspNetCore.Hosting.Server.Features; using Microsoft.AspNetCore.Http.Features; +using Microsoft.AspNetCore.Server.Kestrel.Core.Internal; using Microsoft.AspNetCore.Server.Kestrel.Internal; using Microsoft.AspNetCore.Server.Kestrel.Internal.Http; using Microsoft.AspNetCore.Server.Kestrel.Internal.Infrastructure; @@ -24,7 +25,6 @@ namespace Microsoft.AspNetCore.Server.Kestrel { public class KestrelServer : IServer { - //private Stack _disposables; private readonly List _transports = new List(); private readonly ILogger _logger; @@ -60,7 +60,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel _logger = loggerFactory.CreateLogger(typeof(KestrelServer).GetTypeInfo().Namespace); Features = new FeatureCollection(); _serverAddresses = new ServerAddressesFeature(); - Features.Set(_serverAddresses); + Features.Set(_serverAddresses); Features.Set(InternalOptions); } @@ -278,11 +278,11 @@ namespace Microsoft.AspNetCore.Server.Kestrel } catch (AggregateException ex) when (ex.InnerException is AddressInUseException) { - throw new IOException($"Failed to bind to address {parsedAddress} on the IPv4 loopback interface: port already in use.", ex); + throw new IOException($"Failed to bind to address {parsedAddress} on the IPv4 loopback interface: port already in use.", ex); } catch (AggregateException ex) { - _logger.LogWarning(0, $"Unable to bind to {parsedAddress} on the IPv4 loopback interface: ({ex.Message})"); + _logger.LogWarning(0, $"Unable to bind to {parsedAddress} on the IPv4 loopback interface: ({ex.Message})"); exceptions.Add(ex.InnerException); } @@ -329,4 +329,4 @@ namespace Microsoft.AspNetCore.Server.Kestrel return new IPEndPoint(ip, address.Port); } } -} +} \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Server.Kestrel.Core/Microsoft.AspNetCore.Server.Kestrel.Core.csproj b/src/Microsoft.AspNetCore.Server.Kestrel.Core/Microsoft.AspNetCore.Server.Kestrel.Core.csproj index b7038ded2a..931898c08b 100644 --- a/src/Microsoft.AspNetCore.Server.Kestrel.Core/Microsoft.AspNetCore.Server.Kestrel.Core.csproj +++ b/src/Microsoft.AspNetCore.Server.Kestrel.Core/Microsoft.AspNetCore.Server.Kestrel.Core.csproj @@ -13,9 +13,11 @@ - - + + + + diff --git a/src/Microsoft.AspNetCore.Server.Kestrel.Https/Internal/TlsConnectionFeature.cs b/src/Microsoft.AspNetCore.Server.Kestrel.Https/Internal/TlsConnectionFeature.cs new file mode 100644 index 0000000000..2fb85037b5 --- /dev/null +++ b/src/Microsoft.AspNetCore.Server.Kestrel.Https/Internal/TlsConnectionFeature.cs @@ -0,0 +1,21 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using System.Security.Cryptography.X509Certificates; +using System.Threading; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Http.Features; + +namespace Microsoft.AspNetCore.Server.Kestrel.Https.Internal +{ + internal class TlsConnectionFeature : ITlsConnectionFeature + { + public X509Certificate2 ClientCertificate { get; set; } + + public Task GetClientCertificateAsync(CancellationToken cancellationToken) + { + return Task.FromResult(ClientCertificate); + } + } +} diff --git a/src/Microsoft.AspNetCore.Server.Kestrel.Https/Microsoft.AspNetCore.Server.Kestrel.Https.csproj b/src/Microsoft.AspNetCore.Server.Kestrel.Https/Microsoft.AspNetCore.Server.Kestrel.Https.csproj index f49fae3639..6ee24eba77 100644 --- a/src/Microsoft.AspNetCore.Server.Kestrel.Https/Microsoft.AspNetCore.Server.Kestrel.Https.csproj +++ b/src/Microsoft.AspNetCore.Server.Kestrel.Https/Microsoft.AspNetCore.Server.Kestrel.Https.csproj @@ -16,6 +16,7 @@ + diff --git a/src/Microsoft.AspNetCore.Server.Kestrel/Microsoft.AspNetCore.Server.Kestrel.csproj b/src/Microsoft.AspNetCore.Server.Kestrel/Microsoft.AspNetCore.Server.Kestrel.csproj index 27e7cc51fe..91e491c4f9 100644 --- a/src/Microsoft.AspNetCore.Server.Kestrel/Microsoft.AspNetCore.Server.Kestrel.csproj +++ b/src/Microsoft.AspNetCore.Server.Kestrel/Microsoft.AspNetCore.Server.Kestrel.csproj @@ -11,6 +11,10 @@ false + + + +