Skip to content

Commit 52262b8

Browse files
authored
Revert "throw PNSE for unsupported SSL options in Quic. (#55877)" (#56097)
This reverts commit b2107c5.
1 parent 46d9b31 commit 52262b8

2 files changed

Lines changed: 10 additions & 46 deletions

File tree

src/libraries/System.Net.Quic/src/Resources/Strings.resx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,5 @@
150150
<data name="net_quic_writing_notallowed" xml:space="preserve">
151151
<value>Writing is not allowed on stream.</value>
152152
</data>
153-
<data name="net_quic_ssl_option" xml:space="preserve">
154-
<value>The '{0}' is not supported by System.Net.Quic.</value>
155-
</data>
156153
</root>
157154

src/libraries/System.Net.Quic/src/System/Net/Quic/Implementations/MsQuic/Interop/SafeMsQuicConfigurationHandle.cs

Lines changed: 10 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -36,39 +36,20 @@ protected override bool ReleaseHandle()
3636
public static unsafe SafeMsQuicConfigurationHandle Create(QuicClientConnectionOptions options)
3737
{
3838
X509Certificate? certificate = null;
39-
40-
if (options.ClientAuthenticationOptions != null)
39+
if (options.ClientAuthenticationOptions?.ClientCertificates != null)
4140
{
42-
if (options.ClientAuthenticationOptions.CipherSuitesPolicy != null)
43-
{
44-
throw new PlatformNotSupportedException(SR.Format(SR.net_quic_ssl_option, nameof(options.ClientAuthenticationOptions.CipherSuitesPolicy)));
45-
}
46-
47-
if (options.ClientAuthenticationOptions.EncryptionPolicy == EncryptionPolicy.NoEncryption)
41+
foreach (var cert in options.ClientAuthenticationOptions.ClientCertificates)
4842
{
49-
throw new PlatformNotSupportedException(SR.Format(SR.net_quic_ssl_option, nameof(options.ClientAuthenticationOptions.EncryptionPolicy)));
50-
}
51-
52-
if (options.ClientAuthenticationOptions.LocalCertificateSelectionCallback != null)
53-
{
54-
throw new PlatformNotSupportedException(SR.Format(SR.net_quic_ssl_option, nameof(options.ClientAuthenticationOptions.LocalCertificateSelectionCallback)));
55-
}
56-
57-
if (options.ClientAuthenticationOptions.ClientCertificates != null)
58-
{
59-
foreach (var cert in options.ClientAuthenticationOptions.ClientCertificates)
43+
try
6044
{
61-
try
45+
if (((X509Certificate2)cert).HasPrivateKey)
6246
{
63-
if (((X509Certificate2)cert).HasPrivateKey)
64-
{
65-
// Pick first certificate with private key.
66-
certificate = cert;
67-
break;
68-
}
47+
// Pick first certificate with private key.
48+
certificate = cert;
49+
break;
6950
}
70-
catch { }
7151
}
52+
catch { }
7253
}
7354
}
7455

@@ -78,23 +59,9 @@ public static unsafe SafeMsQuicConfigurationHandle Create(QuicClientConnectionOp
7859
public static unsafe SafeMsQuicConfigurationHandle Create(QuicListenerOptions options)
7960
{
8061
QUIC_CREDENTIAL_FLAGS flags = QUIC_CREDENTIAL_FLAGS.NONE;
81-
82-
if (options.ServerAuthenticationOptions != null)
62+
if (options.ServerAuthenticationOptions != null && options.ServerAuthenticationOptions.ClientCertificateRequired)
8363
{
84-
if (options.ServerAuthenticationOptions.CipherSuitesPolicy != null)
85-
{
86-
throw new PlatformNotSupportedException(SR.Format(SR.net_quic_ssl_option, nameof(options.ServerAuthenticationOptions.CipherSuitesPolicy)));
87-
}
88-
89-
if (options.ServerAuthenticationOptions.EncryptionPolicy == EncryptionPolicy.NoEncryption)
90-
{
91-
throw new PlatformNotSupportedException(SR.Format(SR.net_quic_ssl_option, nameof(options.ServerAuthenticationOptions.EncryptionPolicy)));
92-
}
93-
94-
if (options.ServerAuthenticationOptions.ClientCertificateRequired)
95-
{
96-
flags |= QUIC_CREDENTIAL_FLAGS.REQUIRE_CLIENT_AUTHENTICATION | QUIC_CREDENTIAL_FLAGS.INDICATE_CERTIFICATE_RECEIVED | QUIC_CREDENTIAL_FLAGS.NO_CERTIFICATE_VALIDATION;
97-
}
64+
flags |= QUIC_CREDENTIAL_FLAGS.REQUIRE_CLIENT_AUTHENTICATION | QUIC_CREDENTIAL_FLAGS.INDICATE_CERTIFICATE_RECEIVED | QUIC_CREDENTIAL_FLAGS.NO_CERTIFICATE_VALIDATION;
9865
}
9966

10067
return Create(options, flags, options.ServerAuthenticationOptions?.ServerCertificate, options.ServerAuthenticationOptions?.ServerCertificateContext, options.ServerAuthenticationOptions?.ApplicationProtocols);

0 commit comments

Comments
 (0)