Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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