Skip to main content

Fixed: "The requested security protocol is not supported" with MySql.Data

· 4 min read
Jagdish Kumawat
Founder @ Dewiride

Asking for TLS 1.3 on a Mac gave me The requested security protocol is not supported, though MySQL and .NET 10 both support it. By default, .NET on macOS uses a TLS library that doesn't, and there's a switch to use the one that does.

What I Was Doing​

I set TlsVersion=TLSv1.3 in a connection string, on MySql.Data 26.10.0 and .NET 10, on macOS:

Connection string
…;SslMode=Required;TlsVersion=TLSv1.3
Terminal
dotnet run test-connection.cs

What I Expected​

A connection using TLS 1.3. The server allows it: its tls_version is TLSv1.2,TLSv1.3.

What I Got​

Output
Unhandled exception. System.Security.Authentication.AuthenticationException: Authentication failed, see inner exception.
---> System.PlatformNotSupportedException: The requested security protocol is not supported.

The test program stopping with AuthenticationException: Authentication failed, see inner exception, and PlatformNotSupportedException: The requested security protocol is not supported.

What I Checked​

A Linux container, with the same connection string, connected with TLS 1.3. So the problem is on the Mac, not in the driver or the server.

Microsoft's documentation. The .NET 10 notes explain it: "Historically, macOS used Secure Transport which doesn't support TLS 1.3; opting into Network.framework enables TLS 1.3." It's opt-in: "Existing apps continue to use the current stack unless enabled."

Why It Happens​

.NET on macOS uses Apple's Secure Transport by default, which stops at TLS 1.2. Naming only 1.3 leaves it nothing it can offer.

The Fix​

Pick one, depending on what you need.

To use TLS 1.3 on macOS, turn on Network.framework, for the process:

Terminal
export DOTNET_SYSTEM_NET_SECURITY_USENETWORKFRAMEWORK=1
dotnet run test-connection.cs

If you don't need TLS 1.3 on your Mac, which is the usual case for development, list both versions. Each platform then uses the best it can:

Connection string
…;SslMode=Required;TlsVersion=TLSv1.2,TLSv1.3

That gave TLS 1.2 on macOS, and TLS 1.3 in a Linux container.

After the Fix​

With the switch, on macOS:

Output
Connected as inventory_app@% to MySQL 9.7.4
TLS: TLSv1.3

Without the switch, with both versions listed:

Output
Connected as inventory_app@% to MySQL 9.7.4
TLS: TLSv1.2

The test program printing TLS: TLSv1.3 with the Network.framework switch, and TLS: TLSv1.2 without it when both versions are listed.

Common Mistakes​

MistakeWhat happensDo this instead
Setting the switch and no TlsVersionThe driver still asks for 1.2Set both
Naming only TLSv1.3 in a shared connection stringIt fails for anyone on a MacList both versions
Spending time on the serverThe server's fineLook at the client's platform

Troubleshooting​

SymptomLikely causeFix
Cannot determine the frame size…The server is TLS 1.3 only, and the driver offered 1.2The fix
The switch seems to do nothingThe variable isn't set in the process that runs the appSet it in the same terminal

Conclusion​

The requested security protocol is not supported on a Mac means .NET's default TLS library can't do what you asked. Turn on Network.framework for TLS 1.3, or list both versions so that each platform uses what it can.

Additional Resources​

Stay Updated

Subscribe to our newsletter for the latest tutorials, tech insights, and developer news.

By subscribing, you agree to our privacy policy. Unsubscribe at any time.