public int GetRemoteAvailableUnidirectionalStreamCount() { throw null; }
public System.Net.Quic.QuicStream OpenBidirectionalStream() { throw null; }
public System.Net.Quic.QuicStream OpenUnidirectionalStream() { throw null; }
+ public System.Security.Cryptography.X509Certificates.X509Certificate? RemoteCertificate { get { throw null; } }
public System.Threading.Tasks.ValueTask WaitForAvailableBidirectionalStreamsAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
public System.Threading.Tasks.ValueTask WaitForAvailableUnidirectionalStreamsAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
}
// The .NET Foundation licenses this file to you under the MIT license.
using System.Diagnostics;
-using System.Net;
using System.Net.Security;
+using System.Security.Cryptography.X509Certificates;
using System.Runtime.ExceptionServices;
using System.Threading;
using System.Threading.Channels;
internal PeerStreamLimit? LocalStreamLimit => _isClient ? _state?._clientStreamLimit : _state?._serverStreamLimit;
internal PeerStreamLimit? RemoteStreamLimit => _isClient ? _state?._serverStreamLimit : _state?._clientStreamLimit;
+ internal override X509Certificate? RemoteCertificate => null;
+
// Constructor for outbound connections
internal MockConnection(EndPoint? remoteEndPoint, SslClientAuthenticationOptions? sslClientAuthenticationOptions, IPEndPoint? localEndPoint = null, int maxUnidirectionalStreams = 100, int maxBidirectionalStreams = 100)
{
private bool _closing;
// Certificate validation properties
+ public X509Certificate? RemoteCertificate;
public bool RemoteCertificateRequired;
public X509RevocationMode RevocationMode = X509RevocationMode.Offline;
public RemoteCertificateValidationCallback? RemoteCertificateValidationCallback;
internal override EndPoint RemoteEndPoint => _remoteEndPoint;
+ internal override X509Certificate? RemoteCertificate => _state.RemoteCertificate;
+
internal override SslApplicationProtocol NegotiatedApplicationProtocol => _negotiatedAlpnProtocol;
internal override bool Connected => _state.Connected;
sslPolicyErrors &= ~SslPolicyErrors.RemoteCertificateNotAvailable;
}
+ state.RemoteCertificate = certificate;
+
if (state.RemoteCertificateValidationCallback != null)
{
bool success = state.RemoteCertificateValidationCallback(state, certificate, chain, sslPolicyErrors);
internal abstract System.Net.Security.SslApplicationProtocol NegotiatedApplicationProtocol { get; }
+ internal abstract System.Security.Cryptography.X509Certificates.X509Certificate? RemoteCertificate { get ; }
+
internal abstract ValueTask CloseAsync(long errorCode, CancellationToken cancellationToken = default);
public abstract void Dispose();
using System.Net.Quic.Implementations;
using System.Net.Security;
+using System.Security.Cryptography.X509Certificates;
using System.Threading;
using System.Threading.Tasks;
public EndPoint RemoteEndPoint => _provider.RemoteEndPoint;
+ public X509Certificate? RemoteCertificate => _provider.RemoteCertificate;
+
public SslApplicationProtocol NegotiatedApplicationProtocol => _provider.NegotiatedApplicationProtocol;
/// <summary>
Task<QuicConnection> serverTask = listener.AcceptConnectionAsync().AsTask();
await TaskTimeoutExtensions.WhenAllOrAnyFailed(clientConnection.ConnectAsync().AsTask(), serverTask, PassingTestTimeoutMilliseconds);
using QuicConnection serverConnection = serverTask.Result;
+ Assert.Equal(certificate, clientConnection.RemoteCertificate);
+ Assert.Null(serverConnection.RemoteCertificate);
}
[Fact]
await PingPong(clientConnection, serverConnection);
// check we completed the client certificate verification.
Assert.True(clientCertificateOK);
+ Assert.Equal(ClientCertificate, serverConnection.RemoteCertificate);
await serverConnection.CloseAsync(0);
}