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 @@ -1498,10 +1498,8 @@ await DriveHandshakeWithExternalValidationAsync(
[Fact]
public async Task ClientSession_ExternalCertificateValidation_AcceptWithDefaultValidation_FailsOnUntrustedCert()
{
// The test cert chain isn't installed in the system trust store, so the default
// validation policy must report at least RemoteCertificateChainErrors.
using X509Certificate2 serverCert = TestCertificates.GetServerCertificate();
string serverName = serverCert.GetNameInfo(X509NameType.SimpleName, forIssuer: false);
const string serverName = "localhost";
using TestCertificates.PkiHolder pkiHolder = TestCertificates.GenerateCertificates(serverName);

(Stream clientStream, Stream serverStream) = TestHelper.GetConnectedStreams();
using (clientStream)
Expand All @@ -1517,7 +1515,7 @@ public async Task ClientSession_ExternalCertificateValidation_AcceptWithDefaultV

Task serverHandshake = serverSsl.AuthenticateAsServerAsync(new SslServerAuthenticationOptions
{
ServerCertificate = serverCert,
ServerCertificateContext = pkiHolder.CreateSslStreamCertificateContext(),
EnabledSslProtocols = SslProtocols.Tls12 | SslProtocols.Tls13,
ClientCertificateRequired = false,
});
Expand All @@ -1539,7 +1537,7 @@ await DriveHandshakeWithExternalValidationAsync(
await serverHandshake.WaitAsync(TimeSpan.FromSeconds(30));
await clientHandshake.WaitAsync(TimeSpan.FromSeconds(30));

Assert.NotEqual(SslPolicyErrors.None, observedErrors);
Assert.Equal(SslPolicyErrors.RemoteCertificateChainErrors, observedErrors);

// Encrypt must now throw because validation reported errors.
byte[] plain = "should-fail"u8.ToArray();
Expand Down
Loading