Skip to content

Commit 715c3b5

Browse files
committed
Don't use SslProtocols.None on .NET Core 1.1. Fixes #482
Also add an exception handler to retry TLS negotiation when SslProtocols.None is rejected.
1 parent 9c450ed commit 715c3b5

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

src/MySqlConnector/Core/ServerSession.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,11 @@ public async Task ConnectAsync(ConnectionSettings cs, ILoadBalancer loadBalancer
299299
await InitSslAsync(initialHandshake.ProtocolCapabilities, cs, sslProtocols, ioBehavior, cancellationToken).ConfigureAwait(false);
300300
shouldRetrySsl = false;
301301
}
302+
catch (ArgumentException ex) when (ex.ParamName == "sslProtocolType" && sslProtocols == SslProtocols.None)
303+
{
304+
Log.Warn(ex, "Session{0} doesn't support SslProtocols.None; falling back to explicitly specifying SslProtocols", m_logArguments);
305+
sslProtocols = SslProtocols.Tls | SslProtocols.Tls11 | SslProtocols.Tls12;
306+
}
302307
catch (Exception ex) when (shouldRetrySsl && ((ex is MySqlException && ex.InnerException is IOException) || ex is IOException))
303308
{
304309
// negotiating TLS 1.2 with a yaSSL-based server throws an exception on Windows, see comment at top of method

src/MySqlConnector/Utilities/Utility.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,8 @@ public static SslProtocols GetDefaultSslProtocols()
293293
}
294294

295295
static SslProtocols? s_defaultSslProtocols;
296+
#elif NETSTANDARD1_3
297+
public static SslProtocols GetDefaultSslProtocols() => SslProtocols.Tls | SslProtocols.Tls11 | SslProtocols.Tls12;
296298
#else
297299
public static SslProtocols GetDefaultSslProtocols() => SslProtocols.None;
298300
#endif

0 commit comments

Comments
 (0)