I'm trying to connect a Unity project to a remote MySQL database (first time I try this). I've been stuck for hours due to this error:
TlsException: Handshake failed - error code: UNITYTLS_INTERNAL_ERROR, verify result: UNITYTLS_X509VERIFY_NOT_DONE
Mono.Unity.Debug.CheckAndThrow (Mono.Unity.UnityTls+unitytls_errorstate errorState, Mono.Unity.UnityTls+unitytls_x509verify_result verifyResult, System.String context, Mono.Security.Interface.AlertDescription defaultAlert) (at <aa976c2104104b7ca9e1785715722c9d>:0)
Mono.Unity.UnityTlsContext.ProcessHandshake () (at <aa976c2104104b7ca9e1785715722c9d>:0)
Mono.Net.Security.MobileAuthenticatedStream.ProcessHandshake (Mono.Net.Security.AsyncOperationStatus status) (at <aa976c2104104b7ca9e1785715722c9d>:0)
(wrapper remoting-invoke-with-check) Mono.Net.Security.MobileAuthenticatedStream.ProcessHandshake(Mono.Net.Security.AsyncOperationStatus)
Mono.Net.Security.AsyncHandshakeRequest.Run (Mono.Net.Security.AsyncOperationStatus status) (at <aa976c2104104b7ca9e1785715722c9d>:0)
Mono.Net.Security.AsyncProtocolRequest+<ProcessOperation>d__24.MoveNext () (at <aa976c2104104b7ca9e1785715722c9d>:0)
--- End of stack trace from previous location where exception was thrown ---
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () (at <9577ac7a62ef43179789031239ba8798>:0)
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) (at <9577ac7a62ef43179789031239ba8798>:0)
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) (at <9577ac7a62ef43179789031239ba8798>:0)
System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) (at <9577ac7a62ef43179789031239ba8798>:0)
System.Runtime.CompilerServices.ConfiguredTaskAwaitable+ConfiguredTaskAwaiter.GetResult () (at <9577ac7a62ef43179789031239ba8798>:0)
Mono.Net.Security.AsyncProtocolRequest+<StartOperation>d__23.MoveNext () (at <aa976c2104104b7ca9e1785715722c9d>:0)
Rethrow as AuthenticationException: A call to SSPI failed, see inner exception.
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () (at <9577ac7a62ef43179789031239ba8798>:0)
Mono.Net.Security.MobileAuthenticatedStream+<ProcessAuthentication>d__47.MoveNext () (at <aa976c2104104b7ca9e1785715722c9d>:0)
Rethrow as AggregateException: One or more errors occurred.
System.Threading.Tasks.Task.ThrowIfExceptional (System.Boolean includeTaskCanceledExceptions) (at <9577ac7a62ef43179789031239ba8798>:0)
System.Threading.Tasks.Task.Wait (System.Int32 millisecondsTimeout, System.Threading.CancellationToken cancellationToken) (at <9577ac7a62ef43179789031239ba8798>:0)
System.Threading.Tasks.Task.Wait () (at <9577ac7a62ef43179789031239ba8798>:0)
Mono.Net.Security.MobileAuthenticatedStream.AuthenticateAsClient (System.String targetHost, System.Security.Cryptography.X509Certificates.X509CertificateCollection clientCertificates, System.Security.Authentication.SslProtocols enabledSslProtocols, System.Boolean checkCertificateRevocation) (at <aa976c2104104b7ca9e1785715722c9d>:0)
System.Net.Security.SslStream.AuthenticateAsClient (System.String targetHost, System.Security.Cryptography.X509Certificates.X509CertificateCollection clientCertificates, System.Security.Authentication.SslProtocols enabledSslProtocols, System.Boolean checkCertificateRevocation) (at <aa976c2104104b7ca9e1785715722c9d>:0)
MySql.Data.MySqlClient.NativeDriver.StartSSL () (at <5bcfdf23711c4d2fa921347752c12a65>:0)
MySql.Data.MySqlClient.NativeDriver.Open () (at <5bcfdf23711c4d2fa921347752c12a65>:0)
MySql.Data.MySqlClient.Driver.Open () (at <5bcfdf23711c4d2fa921347752c12a65>:0)
MySql.Data.MySqlClient.Driver.Create (MySql.Data.MySqlClient.MySqlConnectionStringBuilder settings) (at <5bcfdf23711c4d2fa921347752c12a65>:0)
MySql.Data.MySqlClient.MySqlPool.CreateNewPooledConnection () (at <5bcfdf23711c4d2fa921347752c12a65>:0)
MySql.Data.MySqlClient.MySqlPool.GetPooledConnection () (at <5bcfdf23711c4d2fa921347752c12a65>:0)
MySql.Data.MySqlClient.MySqlPool.TryToGetDriver () (at <5bcfdf23711c4d2fa921347752c12a65>:0)
MySql.Data.MySqlClient.MySqlPool.GetConnection () (at <5bcfdf23711c4d2fa921347752c12a65>:0)
MySql.Data.MySqlClient.MySqlConnection.Open () (at <5bcfdf23711c4d2fa921347752c12a65>:0)
SQLManager.SetupSQLConnection () (at Assets/Scripts/SQLManager.cs:24)
SQLManager.Start () (at Assets/Scripts/SQLManager.cs:11)
And here is the code of my SQLManager script:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using MySql.Data.MySqlClient;
public class SQLManager : MonoBehaviour
{
MySqlConnection connection;
void Start()
{
SetupSQLConnection();
}
private void SetupSQLConnection()
{
if (connection == null)
{
string connectionString = "SERVER=server;" + "DATABASE=database;" + "UID=uid;" + "PASSWORD=password;";
try
{
connection = new MySqlConnection(connectionString);
connection.Open();
}
catch (MySqlException ex)
{
Debug.LogError("MySQL Error: " + ex.ToString());
}
}
}
}
Any ideas to how to solve this? I am very unfamiliar to all of this certificate stuff. Thanks in advance.