@@ -333,43 +333,43 @@ internal override uint GenerateSspiClientContext(byte[] receivedBuff, uint recei
333333 internal override uint WaitForSSLHandShakeToComplete ( out int protocolVersion )
334334 {
335335 uint returnValue = SNINativeMethodWrapper . SNIWaitForSSLHandshakeToComplete ( Handle , GetTimeoutRemaining ( ) , out uint nativeProtocolVersion ) ;
336-
337- switch ( ( NativeProtocols ) nativeProtocolVersion )
336+ var nativeProtocol = ( NativeProtocols ) nativeProtocolVersion ;
337+
338+ /* The SslProtocols.Tls13 is supported by netcoreapp3.1 and later
339+ * This driver does not support this version yet!
340+ if (nativeProtocol.HasFlag(NativeProtocols.SP_PROT_TLS1_3_CLIENT) || nativeProtocol.HasFlag(NativeProtocols.SP_PROT_TLS1_3_SERVER))
341+ {
342+ protocolVersion = (int)SslProtocols.Tls13;
343+ }*/
344+ if ( nativeProtocol . HasFlag ( NativeProtocols . SP_PROT_TLS1_2_CLIENT ) || nativeProtocol . HasFlag ( NativeProtocols . SP_PROT_TLS1_2_SERVER ) )
345+ {
346+ protocolVersion = ( int ) SslProtocols . Tls12 ;
347+ }
348+ else if ( nativeProtocol . HasFlag ( NativeProtocols . SP_PROT_TLS1_1_CLIENT ) || nativeProtocol . HasFlag ( NativeProtocols . SP_PROT_TLS1_1_SERVER ) )
349+ {
350+ protocolVersion = ( int ) SslProtocols . Tls11 ;
351+ }
352+ else if ( nativeProtocol . HasFlag ( NativeProtocols . SP_PROT_TLS1_0_CLIENT ) || nativeProtocol . HasFlag ( NativeProtocols . SP_PROT_TLS1_0_SERVER ) )
353+ {
354+ protocolVersion = ( int ) SslProtocols . Tls ;
355+ }
356+ else if ( nativeProtocol . HasFlag ( NativeProtocols . SP_PROT_SSL3_CLIENT ) || nativeProtocol . HasFlag ( NativeProtocols . SP_PROT_SSL3_SERVER ) )
338357 {
339- case NativeProtocols . SP_PROT_SSL2_SERVER :
340- case NativeProtocols . SP_PROT_SSL2_CLIENT :
341358#pragma warning disable CS0618 // Type or member is obsolete : SSL is depricated
342- protocolVersion = ( int ) SslProtocols . Ssl2 ;
343- break ;
344- case NativeProtocols . SP_PROT_SSL3_SERVER :
345- case NativeProtocols . SP_PROT_SSL3_CLIENT :
346- protocolVersion = ( int ) SslProtocols . Ssl3 ;
359+ protocolVersion = ( int ) SslProtocols . Ssl3 ;
360+ }
361+ else if ( nativeProtocol . HasFlag ( NativeProtocols . SP_PROT_SSL2_CLIENT ) || nativeProtocol . HasFlag ( NativeProtocols . SP_PROT_SSL2_SERVER ) )
362+ {
363+ protocolVersion = ( int ) SslProtocols . Ssl2 ;
347364#pragma warning restore CS0618 // Type or member is obsolete : SSL is depricated
348- break ;
349- case NativeProtocols . SP_PROT_TLS1_0_SERVER :
350- case NativeProtocols . SP_PROT_TLS1_0_CLIENT :
351- protocolVersion = ( int ) SslProtocols . Tls ;
352- break ;
353- case NativeProtocols . SP_PROT_TLS1_1_SERVER :
354- case NativeProtocols . SP_PROT_TLS1_1_CLIENT :
355- protocolVersion = ( int ) SslProtocols . Tls11 ;
356- break ;
357- case NativeProtocols . SP_PROT_TLS1_2_SERVER :
358- case NativeProtocols . SP_PROT_TLS1_2_CLIENT :
359- protocolVersion = ( int ) SslProtocols . Tls12 ;
360- break ;
361- /* The SslProtocols.Tls13 is supported by netcoreapp3.1 and later
362- * This driver does not support this version yet!
363- case NativeProtocols.SP_PROT_TLS1_3_SERVER:
364- case NativeProtocols.SP_PROT_TLS1_3_CLIENT:
365- protocolVersion = (int)SslProtocols.Tls13;
366- break;
367- */
368- case NativeProtocols . SP_PROT_NONE :
369- protocolVersion = ( int ) SslProtocols . None ;
370- break ;
371- default :
372- throw new InvalidOperationException ( "Unknown protocol." ) ;
365+ }
366+ else if ( nativeProtocol . HasFlag ( NativeProtocols . SP_PROT_NONE ) )
367+ {
368+ protocolVersion = ( int ) SslProtocols . None ;
369+ }
370+ else
371+ {
372+ throw new ArgumentException ( SRHelper . Format ( SRHelper . net_invalid_enum , nameof ( NativeProtocols ) ) , nameof ( NativeProtocols ) ) ;
373373 }
374374 return returnValue ;
375375 }
0 commit comments