Skip to content

Commit

Permalink
add test for nested ssl authentication (dotnet#873)
Browse files Browse the repository at this point in the history
* add test for nested ssl authentication

* feedback from review
  • Loading branch information
wfurt authored Dec 17, 2019
1 parent 5cc6019 commit c2ffb0f
Showing 1 changed file with 18 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using System.IO;
using System.Net.Sockets;
using System.Net.Test.Common;
using System.Security.Authentication;
using System.Security.Cryptography.X509Certificates;
using System.Text;
using System.Threading.Tasks;

using Xunit;

namespace System.Net.Security.Tests
Expand Down Expand Up @@ -167,6 +168,22 @@ public async Task SslStream_NetworkStream_Renegotiation_Succeeds()
}
}

[Fact]
public async Task SslStream_NestedAuth_Throws()
{
VirtualNetwork network = new VirtualNetwork();

using (var clientStream = new VirtualNetworkStream(network, isServer: false))
using (var serverStream = new VirtualNetworkStream(network, isServer: true))
using (var ssl = new SslStream(clientStream))
{
// Start handshake.
Task task = ssl.AuthenticateAsClientAsync("foo.com", null, SslProtocols.Tls12, false);
// Do it again without waiting for previous one to finish.
await Assert.ThrowsAsync<InvalidOperationException>(() => ssl.AuthenticateAsClientAsync("foo.com", null, SslProtocols.Tls12, false));
}
}

private static bool ValidateServerCertificate(
object sender,
X509Certificate retrievedServerPublicCertificate,
Expand Down

0 comments on commit c2ffb0f

Please sign in to comment.