@@ -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