Skip to content

Commit 51927f3

Browse files
author
Roberto Garcia
committed
Merge branch '6.8' into 6.8-release
2 parents 72d1792 + 7b4e8c7 commit 51927f3

File tree

13 files changed

+71
-40
lines changed

13 files changed

+71
-40
lines changed

CHANGES

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
- Fix for Nested transactions are not supported in Entity Framework (MySQL Bug #71502, Oracle Bug #22366266).
33
- Fix for EF5 and EF6 wrong SQL statement to set primary key (MySQL Bug 76292, Oracle Bug #20711384)
44
- Fixed problem where mysql.proc tables would not be used for metadata even though access was available (MySQL Bug #74116, Oracle Bug #20960373)
5+
- Added support for TLSv1.1 and TLSv1.2
6+
- Fixed Fix for "Aborted connection" (MySQL Bug #80997, Oracle Bug # 23346197).
7+
58

69
6.8.7
710
- Changed handshake process to use bytes instead of encoded strings.

Source/MySql.Data/Driver.cs

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright © 2004, 2015, Oracle and/or its affiliates. All rights reserved.
1+
// Copyright © 2004, 2016, Oracle and/or its affiliates. All rights reserved.
22
//
33
// MySQL Connector/NET is licensed under the terms of the GPLv2
44
// <http://www.gnu.org/licenses/old-licenses/gpl-2.0.html>, like most
@@ -58,7 +58,7 @@ internal class Driver : IDisposable
5858
private bool firstResult;
5959
protected IDriver handler;
6060
internal MySqlDataReader reader;
61-
private bool disposeInProgress;
61+
private bool disposed;
6262

6363
/// <summary>
6464
/// For pooled connections, time when the driver was
@@ -532,20 +532,16 @@ public virtual void CloseQuery(MySqlConnection connection, int statementId)
532532
protected virtual void Dispose(bool disposing)
533533
{
534534
// Avoid cyclic calls to Dispose.
535-
if (disposeInProgress)
535+
if (disposed)
536536
return;
537-
538-
disposeInProgress = true;
539-
540537
try
541538
{
542-
ResetTimeout(1000);
543-
if (disposing)
544-
handler.Close(isOpen);
539+
ResetTimeout(1000);
540+
handler.Close(isOpen);
545541
// if we are pooling, then release ourselves
546542
if (connectionString.Pooling)
547-
MySqlPoolManager.RemoveConnection(this);
548-
}
543+
MySqlPoolManager.RemoveConnection(this);
544+
}
549545
catch (Exception)
550546
{
551547
if (disposing)
@@ -555,7 +551,7 @@ protected virtual void Dispose(bool disposing)
555551
{
556552
reader = null;
557553
isOpen = false;
558-
disposeInProgress = false;
554+
disposed = true;
559555
}
560556
}
561557

Source/MySql.Data/NativeDriver.cs

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ internal class NativeDriver : IDriver
6060
private Driver owner;
6161
private int warnings;
6262
private MySqlAuthenticationPlugin authPlugin;
63+
private bool isEnterprise;
6364

6465
// Windows authentication method string, used by the protocol.
6566
// Also known as "client plugin name".
@@ -222,6 +223,7 @@ public void Open()
222223
packet = stream.ReadPacket();
223224
int protocol = packet.ReadByte();
224225
string versionString = packet.ReadString();
226+
isEnterprise = versionString.ToLowerInvariant().Contains("-enterprise-");
225227
version = DBVersion.Parse(versionString);
226228
if (!version.isAtLeast(5, 0, 0))
227229
throw new NotSupportedException(Resources.ServerTooOld);
@@ -379,11 +381,16 @@ private void StartSSL()
379381
new RemoteCertificateValidationCallback(ServerCheckValidation);
380382
SslStream ss = new SslStream(baseStream, true, sslValidateCallback, null);
381383
X509CertificateCollection certs = GetClientCertificates();
382-
ss.AuthenticateAsClient(Settings.Server, certs, SslProtocols.Tls, false);
384+
SslProtocols sslProtocols = SslProtocols.Tls;
385+
#if NET_45_OR_GREATER
386+
sslProtocols |= SslProtocols.Tls11;
387+
if (version.isAtLeast(5, 6, 0) && isEnterprise)
388+
sslProtocols |= SslProtocols.Tls12;
389+
#endif
390+
ss.AuthenticateAsClient(Settings.Server, certs, sslProtocols, false);
383391
baseStream = ss;
384392
stream = new MySqlStream(ss, Encoding, false);
385393
stream.SequenceByte = 2;
386-
387394
}
388395

389396
private bool ServerCheckValidation(object sender, X509Certificate certificate,
@@ -410,16 +417,16 @@ private bool ServerCheckValidation(object sender, X509Certificate certificate,
410417
}
411418

412419

413-
#endregion
420+
#endregion
414421

415422
#endif
416423

417-
#region Authentication
424+
#region Authentication
418425

419-
/// <summary>
420-
/// Return the appropriate set of connection flags for our
421-
/// server capabilities and our user requested options.
422-
/// </summary>
426+
/// <summary>
427+
/// Return the appropriate set of connection flags for our
428+
/// server capabilities and our user requested options.
429+
/// </summary>
423430
private void SetConnectionFlags(ClientFlags serverCaps)
424431
{
425432
// allow load data local infile

Source/MySql.Data/transaction.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,16 @@ public void Dispose()
8989
GC.SuppressFinalize(this);
9090
}
9191

92+
#if RT
93+
protected void Dispose(bool disposing)
94+
#else
9295
protected override void Dispose(bool disposing)
96+
#endif
9397
{
9498
if (disposed) return;
99+
#if !RT
95100
base.Dispose(disposing);
101+
#endif
96102
if (disposing)
97103
{
98104
if ((conn != null && conn.State == ConnectionState.Open || conn.SoftClosed) && open)

Tests/MySql.Data.Tests/MySqlConnectionTests.cs

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright © 2013, 2015 Oracle and/or its affiliates. All rights reserved.
1+
// Copyright © 2013, 2016 Oracle and/or its affiliates. All rights reserved.
22
//
33
// MySQL Connector/NET is licensed under the terms of the GPLv2
44
// <http://www.gnu.org/licenses/old-licenses/gpl-2.0.html>, like most
@@ -1341,7 +1341,7 @@ public void SslPreferredByDefault()
13411341
using (MySqlDataReader reader = command.ExecuteReader())
13421342
{
13431343
Assert.True(reader.Read());
1344-
Assert.Equal("TLSv1", reader.GetString(1));
1344+
Assert.True(reader.GetString(1).StartsWith("TLSv1"));
13451345
}
13461346
}
13471347
}
@@ -1361,5 +1361,42 @@ public void SslOverrided()
13611361
}
13621362
}
13631363
}
1364+
1365+
1366+
1367+
/// <summary>
1368+
/// Fix for aborted connections MySQL bug 80997 OraBug 23346197
1369+
/// </summary>
1370+
[Fact]
1371+
public void MarkConnectionAsClosedProperlyWhenDisposing()
1372+
{
1373+
MySqlConnection con = new MySqlConnection(st.GetConnectionString(true));
1374+
con.Open();
1375+
MySqlCommand cmd = new MySqlCommand() { Connection = con };
1376+
cmd.CommandText = "Flush status"; // reset values
1377+
cmd.ExecuteNonQuery();
1378+
1379+
AppDomain appDomain = FullTrustSandbox.CreateFullTrustDomain();
1380+
FullTrustSandbox sandbox = (FullTrustSandbox)appDomain.CreateInstanceAndUnwrap(
1381+
typeof(FullTrustSandbox).Assembly.FullName,
1382+
typeof(FullTrustSandbox).FullName);
1383+
try
1384+
{
1385+
MySqlConnection connection = sandbox.TryOpenConnection("server=localhost;userid=root;pwd=;port=3305");
1386+
Assert.NotNull(connection);
1387+
Assert.True(connection.State == ConnectionState.Open);
1388+
}
1389+
finally
1390+
{
1391+
AppDomain.Unload(appDomain);
1392+
}
1393+
cmd = new MySqlCommand("show global status like 'aborted_clients'", con);
1394+
MySqlDataReader r = cmd.ExecuteReader();
1395+
r.Read();
1396+
int numClientsAborted = r.GetInt32(1);
1397+
r.Close();
1398+
Assert.Equal(0, numClientsAborted);
1399+
con.Close();
1400+
}
13641401
}
13651402
}

Tests/MySql.Data.Tests/certificates/ca-cert.pem

Lines changed: 0 additions & 18 deletions
This file was deleted.
28 Bytes
Binary file not shown.
1.07 KB
Binary file not shown.
-2.39 KB
Binary file not shown.
28 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)