This commit is contained in:
parent
43a38c1b58
commit
117486de94
|
|
@ -20,8 +20,8 @@ namespace Microsoft.AspNet.Http
|
||||||
|
|
||||||
public abstract bool IsLocal { get; set; }
|
public abstract bool IsLocal { get; set; }
|
||||||
|
|
||||||
public abstract X509Certificate ClientCertificate { get; set; }
|
public abstract X509Certificate2 ClientCertificate { get; set; }
|
||||||
|
|
||||||
public abstract Task<X509Certificate> GetClientCertificateAsync(CancellationToken cancellationToken = new CancellationToken());
|
public abstract Task<X509Certificate2> GetClientCertificateAsync(CancellationToken cancellationToken = new CancellationToken());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -7,17 +7,17 @@ using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace Microsoft.AspNet.Http
|
namespace Microsoft.AspNet.Http
|
||||||
{
|
{
|
||||||
public interface IHttpClientCertificateFeature
|
public interface ITlsConnectionFeature
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Synchronously retrieves the client certificate, if any.
|
/// Synchronously retrieves the client certificate, if any.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
X509Certificate ClientCertificate { get; set; }
|
X509Certificate2 ClientCertificate { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Asynchronously retrieves the client certificate, if any.
|
/// Asynchronously retrieves the client certificate, if any.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task<X509Certificate> GetClientCertificateAsync(CancellationToken cancellationToken);
|
Task<X509Certificate2> GetClientCertificateAsync(CancellationToken cancellationToken);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -15,7 +15,7 @@ namespace Microsoft.AspNet.Http
|
||||||
private readonly IFeatureCollection _features;
|
private readonly IFeatureCollection _features;
|
||||||
|
|
||||||
private FeatureReference<IHttpConnectionFeature> _connection = FeatureReference<IHttpConnectionFeature>.Default;
|
private FeatureReference<IHttpConnectionFeature> _connection = FeatureReference<IHttpConnectionFeature>.Default;
|
||||||
private FeatureReference<IHttpClientCertificateFeature> _clientCertificate = FeatureReference<IHttpClientCertificateFeature>.Default;
|
private FeatureReference<ITlsConnectionFeature> _tlsConnectoin = FeatureReference<ITlsConnectionFeature>.Default;
|
||||||
|
|
||||||
public DefaultConnectionInfo(IFeatureCollection features)
|
public DefaultConnectionInfo(IFeatureCollection features)
|
||||||
{
|
{
|
||||||
|
|
@ -27,9 +27,9 @@ namespace Microsoft.AspNet.Http
|
||||||
get { return _connection.Fetch(_features) ?? _connection.Update(_features, new HttpConnectionFeature()); }
|
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
|
public override IPAddress RemoteIpAddress
|
||||||
|
|
@ -62,15 +62,15 @@ namespace Microsoft.AspNet.Http
|
||||||
set { HttpConnectionFeature.IsLocal = value; }
|
set { HttpConnectionFeature.IsLocal = value; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public override X509Certificate ClientCertificate
|
public override X509Certificate2 ClientCertificate
|
||||||
{
|
{
|
||||||
get { return HttpClientCertificateFeature.ClientCertificate; }
|
get { return TlsConnectionFeature.ClientCertificate; }
|
||||||
set { HttpClientCertificateFeature.ClientCertificate = value; }
|
set { TlsConnectionFeature.ClientCertificate = value; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public override Task<X509Certificate> GetClientCertificateAsync(CancellationToken cancellationToken = new CancellationToken())
|
public override Task<X509Certificate2> GetClientCertificateAsync(CancellationToken cancellationToken = new CancellationToken())
|
||||||
{
|
{
|
||||||
return HttpClientCertificateFeature.GetClientCertificateAsync(cancellationToken);
|
return TlsConnectionFeature.GetClientCertificateAsync(cancellationToken);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -7,15 +7,15 @@ using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace Microsoft.AspNet.Http
|
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<X509Certificate> GetClientCertificateAsync(CancellationToken cancellationToken)
|
public Task<X509Certificate2> GetClientCertificateAsync(CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
return Task.FromResult(ClientCertificate);
|
return Task.FromResult(ClientCertificate);
|
||||||
}
|
}
|
||||||
|
|
@ -99,9 +99,9 @@ namespace Microsoft.AspNet.Owin
|
||||||
|
|
||||||
if (context.Request.IsHttps)
|
if (context.Request.IsHttps)
|
||||||
{
|
{
|
||||||
_entries.Add(OwinConstants.CommonKeys.ClientCertificate, new FeatureMap<IHttpClientCertificateFeature>(feature => feature.ClientCertificate,
|
_entries.Add(OwinConstants.CommonKeys.ClientCertificate, new FeatureMap<ITlsConnectionFeature>(feature => feature.ClientCertificate,
|
||||||
(feature, value) => feature.ClientCertificate = (X509Certificate)value));
|
(feature, value) => feature.ClientCertificate = (X509Certificate2)value));
|
||||||
_entries.Add(OwinConstants.CommonKeys.LoadClientCertAsync, new FeatureMap<IHttpClientCertificateFeature>(
|
_entries.Add(OwinConstants.CommonKeys.LoadClientCertAsync, new FeatureMap<ITlsConnectionFeature>(
|
||||||
feature => new Func<Task>(() => feature.GetClientCertificateAsync(CancellationToken.None))));
|
feature => new Func<Task>(() => feature.GetClientCertificateAsync(CancellationToken.None))));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@ namespace Microsoft.AspNet.Owin
|
||||||
IHttpResponseFeature,
|
IHttpResponseFeature,
|
||||||
IHttpConnectionFeature,
|
IHttpConnectionFeature,
|
||||||
IHttpSendFileFeature,
|
IHttpSendFileFeature,
|
||||||
IHttpClientCertificateFeature,
|
ITlsConnectionFeature,
|
||||||
IHttpRequestLifetimeFeature,
|
IHttpRequestLifetimeFeature,
|
||||||
IHttpAuthenticationFeature,
|
IHttpAuthenticationFeature,
|
||||||
IHttpWebSocketFeature,
|
IHttpWebSocketFeature,
|
||||||
|
|
@ -228,20 +228,20 @@ namespace Microsoft.AspNet.Owin
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
X509Certificate IHttpClientCertificateFeature.ClientCertificate
|
X509Certificate2 ITlsConnectionFeature.ClientCertificate
|
||||||
{
|
{
|
||||||
get { return Prop<X509Certificate>(OwinConstants.CommonKeys.ClientCertificate); }
|
get { return Prop<X509Certificate2>(OwinConstants.CommonKeys.ClientCertificate); }
|
||||||
set { Prop(OwinConstants.CommonKeys.ClientCertificate, value); }
|
set { Prop(OwinConstants.CommonKeys.ClientCertificate, value); }
|
||||||
}
|
}
|
||||||
|
|
||||||
async Task<X509Certificate> IHttpClientCertificateFeature.GetClientCertificateAsync(CancellationToken cancellationToken)
|
async Task<X509Certificate2> ITlsConnectionFeature.GetClientCertificateAsync(CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
var loadAsync = Prop<Func<Task>>(OwinConstants.CommonKeys.LoadClientCertAsync);
|
var loadAsync = Prop<Func<Task>>(OwinConstants.CommonKeys.LoadClientCertAsync);
|
||||||
if (loadAsync != null)
|
if (loadAsync != null)
|
||||||
{
|
{
|
||||||
await loadAsync();
|
await loadAsync();
|
||||||
}
|
}
|
||||||
return Prop<X509Certificate>(OwinConstants.CommonKeys.ClientCertificate);
|
return Prop<X509Certificate2>(OwinConstants.CommonKeys.ClientCertificate);
|
||||||
}
|
}
|
||||||
|
|
||||||
CancellationToken IHttpRequestLifetimeFeature.RequestAborted
|
CancellationToken IHttpRequestLifetimeFeature.RequestAborted
|
||||||
|
|
@ -308,7 +308,7 @@ namespace Microsoft.AspNet.Owin
|
||||||
{
|
{
|
||||||
return SupportsSendFile;
|
return SupportsSendFile;
|
||||||
}
|
}
|
||||||
else if (key == typeof(IHttpClientCertificateFeature))
|
else if (key == typeof(ITlsConnectionFeature))
|
||||||
{
|
{
|
||||||
return SupportsClientCerts;
|
return SupportsClientCerts;
|
||||||
}
|
}
|
||||||
|
|
@ -342,7 +342,7 @@ namespace Microsoft.AspNet.Owin
|
||||||
}
|
}
|
||||||
if (SupportsClientCerts)
|
if (SupportsClientCerts)
|
||||||
{
|
{
|
||||||
keys.Add(typeof(IHttpClientCertificateFeature));
|
keys.Add(typeof(ITlsConnectionFeature));
|
||||||
}
|
}
|
||||||
if (SupportsWebSockets)
|
if (SupportsWebSockets)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue