From 117486de94fadcda9f93165e678b4c352b45e808 Mon Sep 17 00:00:00 2001 From: Chris R Date: Mon, 27 Apr 2015 14:18:02 -0700 Subject: [PATCH] #277 Rename IHttpClientCertificateFeature. #279 prefer X509Certificate2. --- src/Microsoft.AspNet.Http.Core/ConnectionInfo.cs | 4 ++-- ...ficateFeature.cs => ITlsConnectionFeature.cs} | 6 +++--- .../DefaultConnectionInfo.cs | 16 ++++++++-------- ...ificateFeature.cs => TlsConnectionFeature.cs} | 8 ++++---- src/Microsoft.AspNet.Owin/OwinEnvironment.cs | 6 +++--- .../OwinFeatureCollection.cs | 14 +++++++------- 6 files changed, 27 insertions(+), 27 deletions(-) rename src/Microsoft.AspNet.Http.Interfaces/{IHttpClientCertificateFeature.cs => ITlsConnectionFeature.cs} (74%) rename src/Microsoft.AspNet.Http/{HttpClientCertificateFeature.cs => TlsConnectionFeature.cs} (60%) diff --git a/src/Microsoft.AspNet.Http.Core/ConnectionInfo.cs b/src/Microsoft.AspNet.Http.Core/ConnectionInfo.cs index 54175ec2f2..0587fde7ca 100644 --- a/src/Microsoft.AspNet.Http.Core/ConnectionInfo.cs +++ b/src/Microsoft.AspNet.Http.Core/ConnectionInfo.cs @@ -20,8 +20,8 @@ namespace Microsoft.AspNet.Http public abstract bool IsLocal { get; set; } - public abstract X509Certificate ClientCertificate { get; set; } + public abstract X509Certificate2 ClientCertificate { get; set; } - public abstract Task GetClientCertificateAsync(CancellationToken cancellationToken = new CancellationToken()); + public abstract Task GetClientCertificateAsync(CancellationToken cancellationToken = new CancellationToken()); } } \ No newline at end of file diff --git a/src/Microsoft.AspNet.Http.Interfaces/IHttpClientCertificateFeature.cs b/src/Microsoft.AspNet.Http.Interfaces/ITlsConnectionFeature.cs similarity index 74% rename from src/Microsoft.AspNet.Http.Interfaces/IHttpClientCertificateFeature.cs rename to src/Microsoft.AspNet.Http.Interfaces/ITlsConnectionFeature.cs index da8fd38115..fdac0526e2 100644 --- a/src/Microsoft.AspNet.Http.Interfaces/IHttpClientCertificateFeature.cs +++ b/src/Microsoft.AspNet.Http.Interfaces/ITlsConnectionFeature.cs @@ -7,17 +7,17 @@ using System.Threading.Tasks; namespace Microsoft.AspNet.Http { - public interface IHttpClientCertificateFeature + public interface ITlsConnectionFeature { /// /// Synchronously retrieves the client certificate, if any. /// - X509Certificate ClientCertificate { get; set; } + X509Certificate2 ClientCertificate { get; set; } /// /// Asynchronously retrieves the client certificate, if any. /// /// - Task GetClientCertificateAsync(CancellationToken cancellationToken); + Task GetClientCertificateAsync(CancellationToken cancellationToken); } } diff --git a/src/Microsoft.AspNet.Http/DefaultConnectionInfo.cs b/src/Microsoft.AspNet.Http/DefaultConnectionInfo.cs index f400f6aaff..a01cee053e 100644 --- a/src/Microsoft.AspNet.Http/DefaultConnectionInfo.cs +++ b/src/Microsoft.AspNet.Http/DefaultConnectionInfo.cs @@ -15,7 +15,7 @@ namespace Microsoft.AspNet.Http private readonly IFeatureCollection _features; private FeatureReference _connection = FeatureReference.Default; - private FeatureReference _clientCertificate = FeatureReference.Default; + private FeatureReference _tlsConnectoin = FeatureReference.Default; public DefaultConnectionInfo(IFeatureCollection features) { @@ -27,9 +27,9 @@ namespace Microsoft.AspNet.Http get { return _connection.Fetch(_features) ?? _connection.Update(_features, new HttpConnectionFeature()); } } - private IHttpClientCertificateFeature HttpClientCertificateFeature + private ITlsConnectionFeature TlsConnectionFeature { - get { return _clientCertificate.Fetch(_features) ?? _clientCertificate.Update(_features, new HttpClientCertificateFeature()); } + get { return _tlsConnectoin.Fetch(_features) ?? _tlsConnectoin.Update(_features, new TlsConnectionFeature()); } } public override IPAddress RemoteIpAddress @@ -62,15 +62,15 @@ namespace Microsoft.AspNet.Http set { HttpConnectionFeature.IsLocal = value; } } - public override X509Certificate ClientCertificate + public override X509Certificate2 ClientCertificate { - get { return HttpClientCertificateFeature.ClientCertificate; } - set { HttpClientCertificateFeature.ClientCertificate = value; } + get { return TlsConnectionFeature.ClientCertificate; } + set { TlsConnectionFeature.ClientCertificate = value; } } - public override Task GetClientCertificateAsync(CancellationToken cancellationToken = new CancellationToken()) + public override Task GetClientCertificateAsync(CancellationToken cancellationToken = new CancellationToken()) { - return HttpClientCertificateFeature.GetClientCertificateAsync(cancellationToken); + return TlsConnectionFeature.GetClientCertificateAsync(cancellationToken); } } } \ No newline at end of file diff --git a/src/Microsoft.AspNet.Http/HttpClientCertificateFeature.cs b/src/Microsoft.AspNet.Http/TlsConnectionFeature.cs similarity index 60% rename from src/Microsoft.AspNet.Http/HttpClientCertificateFeature.cs rename to src/Microsoft.AspNet.Http/TlsConnectionFeature.cs index 22ef21f704..bf22639161 100644 --- a/src/Microsoft.AspNet.Http/HttpClientCertificateFeature.cs +++ b/src/Microsoft.AspNet.Http/TlsConnectionFeature.cs @@ -7,15 +7,15 @@ using System.Threading.Tasks; namespace Microsoft.AspNet.Http { - public class HttpClientCertificateFeature : IHttpClientCertificateFeature + public class TlsConnectionFeature : ITlsConnectionFeature { - public HttpClientCertificateFeature() + public TlsConnectionFeature() { } - public X509Certificate ClientCertificate { get; set; } + public X509Certificate2 ClientCertificate { get; set; } - public Task GetClientCertificateAsync(CancellationToken cancellationToken) + public Task GetClientCertificateAsync(CancellationToken cancellationToken) { return Task.FromResult(ClientCertificate); } diff --git a/src/Microsoft.AspNet.Owin/OwinEnvironment.cs b/src/Microsoft.AspNet.Owin/OwinEnvironment.cs index 9dfae8a833..f35bedcd34 100644 --- a/src/Microsoft.AspNet.Owin/OwinEnvironment.cs +++ b/src/Microsoft.AspNet.Owin/OwinEnvironment.cs @@ -99,9 +99,9 @@ namespace Microsoft.AspNet.Owin if (context.Request.IsHttps) { - _entries.Add(OwinConstants.CommonKeys.ClientCertificate, new FeatureMap(feature => feature.ClientCertificate, - (feature, value) => feature.ClientCertificate = (X509Certificate)value)); - _entries.Add(OwinConstants.CommonKeys.LoadClientCertAsync, new FeatureMap( + _entries.Add(OwinConstants.CommonKeys.ClientCertificate, new FeatureMap(feature => feature.ClientCertificate, + (feature, value) => feature.ClientCertificate = (X509Certificate2)value)); + _entries.Add(OwinConstants.CommonKeys.LoadClientCertAsync, new FeatureMap( feature => new Func(() => feature.GetClientCertificateAsync(CancellationToken.None)))); } diff --git a/src/Microsoft.AspNet.Owin/OwinFeatureCollection.cs b/src/Microsoft.AspNet.Owin/OwinFeatureCollection.cs index 195fb04cb0..0c270bfc3a 100644 --- a/src/Microsoft.AspNet.Owin/OwinFeatureCollection.cs +++ b/src/Microsoft.AspNet.Owin/OwinFeatureCollection.cs @@ -29,7 +29,7 @@ namespace Microsoft.AspNet.Owin IHttpResponseFeature, IHttpConnectionFeature, IHttpSendFileFeature, - IHttpClientCertificateFeature, + ITlsConnectionFeature, IHttpRequestLifetimeFeature, IHttpAuthenticationFeature, IHttpWebSocketFeature, @@ -228,20 +228,20 @@ namespace Microsoft.AspNet.Owin } } - X509Certificate IHttpClientCertificateFeature.ClientCertificate + X509Certificate2 ITlsConnectionFeature.ClientCertificate { - get { return Prop(OwinConstants.CommonKeys.ClientCertificate); } + get { return Prop(OwinConstants.CommonKeys.ClientCertificate); } set { Prop(OwinConstants.CommonKeys.ClientCertificate, value); } } - async Task IHttpClientCertificateFeature.GetClientCertificateAsync(CancellationToken cancellationToken) + async Task ITlsConnectionFeature.GetClientCertificateAsync(CancellationToken cancellationToken) { var loadAsync = Prop>(OwinConstants.CommonKeys.LoadClientCertAsync); if (loadAsync != null) { await loadAsync(); } - return Prop(OwinConstants.CommonKeys.ClientCertificate); + return Prop(OwinConstants.CommonKeys.ClientCertificate); } CancellationToken IHttpRequestLifetimeFeature.RequestAborted @@ -308,7 +308,7 @@ namespace Microsoft.AspNet.Owin { return SupportsSendFile; } - else if (key == typeof(IHttpClientCertificateFeature)) + else if (key == typeof(ITlsConnectionFeature)) { return SupportsClientCerts; } @@ -342,7 +342,7 @@ namespace Microsoft.AspNet.Owin } if (SupportsClientCerts) { - keys.Add(typeof(IHttpClientCertificateFeature)); + keys.Add(typeof(ITlsConnectionFeature)); } if (SupportsWebSockets) {