mysql 无法通过SSL将Visual Basic应用程序连接到AWS RDS示例

brc7rcf0  于 2023-03-07  发布在  Mysql
关注(0)|答案(1)|浏览(137)

我最近创建了一个新的RDS示例,并试图编辑一个Visual Basic应用程序以使用SSL连接访问MySQL 8.0数据库。
服务器端,一切似乎都很好。我已经启用了require_secure_transport,并确认我可以通过命令行连接时提供证书文件:

mysql -h database.server.123b234.ap-southeast-2.rds.amazonaws.com -u user --ssl-ca=rds-combined-ca-bundle.pem --ssl-mode=REQUIRED -P 3306 -p

我正在修改的Visual Basic应用程序在Visual Studio 2010中使用了带有.NET framework的MySql.Data.dll库包,网址为6.7.4.0。我一直在处理连接字符串,但似乎总是收到异常"A call to SSPI failed, see inner exception"和内部异常:"The function requested is not supported"
我的连接字符串是:

myConnStr = "Server=database.server.123b234.ap-southeast-2.rds.amazonaws.com;" _
                & "uid=user;" _
                & "pwd=password;" _
                & "Port=3306;" _
                & "Allow Zero Datetime=true;" _
                & "CharSet=" & "utf8" _
                & "SSL Mode=Required"

// add to conn object
conn.ConnectionString = myConnStr
conn.Open()

// exception called on next step through code

我一直在尝试找出如何将rds-combined-ca-bundle.pem证书添加到连接字符串中,但是每次尝试将ssl-casslca添加到指定了RDS证书的连接字符串中时,都会收到一个异常,指出该选项不存在。
SSPI异常的堆栈跟踪:

{System.Security.Authentication.AuthenticationException: 
A call to SSPI failed, see inner exception. ---> System.ComponentModel.Win32Exception: 
The function requested is not supported" & vbCrLf & "   
--- End of inner exception stack trace ---"

以及

at System.Net.Security.SslState.StartSendAuthResetSignal(ProtocolToken message, AsyncProtocolRequest asyncRequest, Exception exception)
   at System.Net.Security.SslState.CheckCompletionBeforeNextReceive(ProtocolToken message, AsyncProtocolRequest asyncRequest)
   at System.Net.Security.SslState.StartSendBlob(Byte[] incoming, Int32 count, AsyncProtocolRequest asyncRequest, Boolean renegotiation)
   at System.Net.Security.SslState.ProcessReceivedBlob(Byte[] buffer, Int32 count, AsyncProtocolRequest asyncRequest)
   at System.Net.Security.SslState.StartReadFrame(Byte[] buffer, Int32 readBytes, AsyncProtocolRequest asyncRequest)
   at System.Net.Security.SslState.StartReceiveBlob(Byte[] buffer, AsyncProtocolRequest asyncRequest)
   at System.Net.Security.SslState.CheckCompletionBeforeNextReceive(ProtocolToken message, AsyncProtocolRequest asyncRequest)
   at System.Net.Security.SslState.StartSendBlob(Byte[] incoming, Int32 count, AsyncProtocolRequest asyncRequest, Boolean renegotiation)
   at System.Net.Security.SslState.ForceAuthentication(Boolean receiveFirst, Byte[] buffer, AsyncProtocolRequest asyncRequest, Boolean renegotiation)
   at System.Net.Security.SslState.ProcessAuthentication(LazyAsyncResult lazyResult)
   at System.Net.Security.SslStream.AuthenticateAsClient(String targetHost, X509CertificateCollection clientCertificates, SslProtocols enabledSslProtocols, Boolean checkCertificateRevocation)
   at MySql.Data.MySqlClient.NativeDriver.StartSSL()
   at MySql.Data.MySqlClient.NativeDriver.Open()
   at MySql.Data.MySqlClient.Driver.Open()
   at MySql.Data.MySqlClient.Driver.Create(MySqlConnectionStringBuilder settings)
   at MySql.Data.MySqlClient.MySqlPool.CreateNewPooledConnection()
   at MySql.Data.MySqlClient.MySqlPool.GetPooledConnection()
   at MySql.Data.MySqlClient.MySqlPool.TryToGetDriver()
   at MySql.Data.MySqlClient.MySqlPool.GetConnection()
   at MySql.Data.MySqlClient.MySqlConnection.Open()
eivnm1vs

eivnm1vs1#

解决了。
我最终将项目. NET Framework升级到了V4. 8,更新了MYSQL连接器版本(这很痛苦)和Visual Studio 2022。现在一切都运行良好。希望这也能对未来的人有所帮助。

相关问题