我正在尝试使用ssl从c#app连接到mysql。以下是我的连接字符串:
server = "xxx.xxx.xxx.xxx";
database = "sqlserver";
uid = "sqlserver";
password = "password";
cert_file = "client-cert.pfx";
string connectionString;
connectionString = "SERVER=" + server + ";" + "DATABASE=" + database + ";" + "UID=" + uid + "; CertificateFile=" + cert_file + "; CertificatePassword=admin; SslMode=Required";
这是错误:
System.IO.IOException:收到了 来自传输流的意外EOF或0字节。在 System.Net.FixedSizeReader.ReadPacket(Byte []缓冲区,Int32偏移量, 在System.Net.Security.SslState.StartReadFrame(Byte []的Int32计数) 缓冲区,Int32 readBytes,AsyncProtocolRequest asyncRequest)at System.Net.Security.SslState.StartReceiveBlob(Byte []缓冲区, AsyncProtocolRequest asyncRequest)at System.Net.Security.SslState.ForceAuthentication(Boolean receiveFirst, Byte [] buffer,AsyncProtocolRequest asyncRequest)at System.Net.Security.SslState.ProcessAuthentication(LazyAsyncResult lazyResult)在MySql.Data.MySqlClient.NativeDriver.StartSSL()at MySql.Data.MySqlClient.NativeDriver.Open()at MySql.Data.MySqlClient.Driver.Open()at MySql.Data.MySqlClient.Driver.Create(MySqlConnectionStringBuilder 设置) 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()
我认为问题是我的档案,但现在我知道它不是......所以我迷失了
答案 0 :(得分:0)
server = "xxx.xxx.xxx.xxx";
大多数情况下,SSL证书定义主机名模式(例如* .google.com)。在SSL身份验证期间,主机名将被验证为来自正确的域。使用服务器的IP地址将导致此检查失败。
我会尝试将主机名设置为服务器,看看你是否得到不同的结果。