Bug #104988 Connection to MySQL fails when updating NuGet package from 8.0.25 to 8.0.26
Submitted: 20 Sep 2021 9:04 Modified: 4 Oct 2021 11:56
Reporter: Derek Jackson Email Updates:
Status: Closed Impact on me:
None 
Category:Connector / NET Severity:S2 (Serious)
Version:8.0.26 OS:Windows (C# using VS 2019)
Assigned to: CPU Architecture:x86
Tags: NuGet Version 8.0.26

[20 Sep 2021 9:04] Derek Jackson
Description:
When I update the NuGet package in a working project from 8.0.25 to 8.0.26 the MySQL connection fails to open. 

The exception text is :-

·           ex       {"SSL Connection error."}   System.Exception {MySql.Data.MySqlClient.MySqlException}
·           Code     0       uint
·          
·           Data     {System.Collections.ListDictionaryInternal}   System.Collections.IDictionary {System.Collections.ListDictionaryInternal}
·           Count    0       int
·           IsFixedSize      false   bool
·           IsReadOnly       false   bool
·           IsSynchronized   false   bool
·          
·           Keys   {System.Collections.ListDictionaryInternal.NodeKeyValueCollection}   System.Collections.ICollection {System.Collections.ListDictionaryInternal.NodeKeyValueCollection}
·           SyncRoot {object}       object
·          
·           Values   {System.Collections.ListDictionaryInternal.NodeKeyValueCollection}   System.Collections.ICollection {System.Collections.ListDictionaryInternal.NodeKeyValueCollection}
·          
·           Non-Public members              
·          
·           Results View     Expanding the Results View will enumerate the IEnumerable        
·           ErrorCode        -2147467259    int
·           HResult  -2147467259    int
·           HelpLink null    string
·          
·           InnerException   Count = 1      System.Exception {System.AggregateException}
·           Message  "SSL Connection error."     string
·           Number   0       int
·           Source   "MySql.Data" string
·           SqlState null    string
·           StackTrace       "   at MySql.Data.Common.Ssl.StartSSL(Stream& baseStream, Encoding encoding, String connectionString)\r\n   at MySql.Data.MySqlClient.NativeDriver.Open()\r\n   at MySql.Data.MySqlClient.Driver.Open()\r\n   at MySql.Data.MySqlClient.Driver.Create(MySqlConnectionStringBuilder settings)\r\n   at MySql.Data.MySqlClient.MySqlPool.CreateNewPooledConnection()\r\n   at MySql.Data.MySqlClient.MySqlPool.GetPooledConnection()\r\n   at MySql.Data.MySqlClient.MySqlPool.TryToGetDriver()\r\n   at MySql.Data.MySqlClient.MySqlPool.GetConnection()\r\n   at MySql.Data.MySqlClient.MySqlConnection.Open()\r\n   at DT_Apps.GetBasicInfo.LoadInfo() in C:\\Users\\Derek\\source\\repos\\DT_Apps\\DT_Apps\\GetBasicInfo.cs:line 61"   string
·          
·           TargetSite       {MySql.Data.MySqlClient.MySqlStream StartSSL(System.IO.Stream ByRef, System.Text.Encoding, System.String)}   System.Reflection.MethodBase {System.Reflection.RuntimeMethodInfo}
·          
·           Static members          
·          
·           Non-Public members         

I'll attach a test project to this report when I can.

How to repeat:
Degrade package to 8.0.25 works fine.
[20 Sep 2021 9:11] Derek Jackson
MS VS2019 project with SSL and MySql packages removed

Attachment: MySqlTest.zip (application/x-zip-compressed, text), 45.02 KiB.

[20 Sep 2021 9:14] Derek Jackson
Project file uploaded.

I've had to remove package files to keep the size below 30M
Packages removes are :-
BouncyCastle.1.8.5
Google.Protobuf.3.14.0
K4os.Compression.LZ4.1.1.11
K4os.Compression.LZ4.Streams.1.1.11
K4os.Hash.xxHash.1.0.6
MySql.Data.8.0.25
SSH.NET.2020.0.1
System.Buffers.4.5.1
System.Memory.4.5.3
System.Numerics.Vectors.4.4.0
System.Runtime.CompilerServices.Unsafe.4.5.2
[3 Oct 2021 14:59] Bradley Grainger
Since you're already tunneling the DB connection through an (encrypted) SSH connection, you could try adding "SslMode = None" to your connection string; this may avoid the SSL exception you're getting, but shouldn't reduce security at all.
[3 Oct 2021 16:22] Derek Jackson
Yes, adding
SslMode = MySqlSslMode.None 
to the connection string works for me. 

Thanks for the solution,
Derek Jackson
[4 Oct 2021 11:56] MySQL Verification Team
Hello Derek Jackson,

Thanks for letting us know that you fixed it by adding SslMode to the connection string.
Closing the report.

Regards,
Ashwini Patil