首页 > 数据库 >在 .net core 3.1 的 docker 镜像生成的容器中,连接 sql server 2008 r2 版本的数据库,遇到错误

在 .net core 3.1 的 docker 镜像生成的容器中,连接 sql server 2008 r2 版本的数据库,遇到错误

时间:2024-04-30 18:44:13浏览次数:24  
标签:core HelpLink r2 error System server sql null Data

错误1:

{
    "ClassName": "System.Data.SqlClient.SqlException",
    "Message": "A connection was successfully established with the server, but then an error occurred during the pre-login handshake. (provider: TCP Provider, error: 35 - An internal exception was caught)",
    "Data": {
        "HelpLink.ProdName": "Microsoft SQL Server",
        "HelpLink.EvtSrc": "MSSQLServer",
        "HelpLink.EvtID": "0",
        "HelpLink.BaseHelpUrl": "https://go.microsoft.com/fwlink",
        "HelpLink.LinkId": "20476",
        "SqlError 1": "System.Data.SqlClient.SqlError: A connection was successfully established with the server, but then an error occurred during the pre-login handshake. (provider: TCP Provider, error: 35 - An internal exception was caught)"
    },
    "InnerException": {
        "ClassName": "System.Security.Authentication.AuthenticationException",
        "Message": "Authentication failed, see inner exception.",
        "Data": null,
        "InnerException": {
            "StackTrace": "   at Interop.OpenSsl.DoSslHandshake(SafeSslHandle context, Byte[] recvBuf, Int32 recvOffset, Int32 recvCount, Byte[]& sendBuf, Int32& sendCount)\n   at System.Net.Security.SslStreamPal.HandshakeInternal(SafeFreeCredentials credential, SafeDeleteContext& context, ArraySegment`1 inputBuffer, Byte[]& outputBuffer, SslAuthenticationOptions sslAuthenticationOptions)",
            "Message": "SSL Handshake failed with OpenSSL error - SSL_ERROR_SSL.",
            "Data": {},
            "InnerException": {
                "StackTrace": null,
                "Message": "error:1425F102:SSL routines:ssl_choose_client_version:unsupported protocol",
                "Data": {},
                "InnerException": null,
                "HelpLink": null,
                "Source": null,
                "HResult": 338030850
            },
            "HelpLink": null,
            "Source": "System.Net.Security",
            "HResult": -2146233088
        },

问题和解决方法:

应该是 SQL Server 2008 R2 或其所在服务器支持的加密协议版本过低(不再安全),新版客户端已不再支持。

修改容器中 openssl 文件配置的最低允许使用的协议版本即可:

sed -i -e "s|^MinProtocol = .*|MinProtocol = TLSv1.0|g" "/etc/ssl/openssl.cnf"

另附,查询当前系统支持的加密协议:

openssl ciphers -v | awk '{print $2}' | sort | uniq

参考链接:https://stackoverflow.com/questions/71527736/c-sharp-sslexception-ssl-handshake-failed-with-openssl-error-ssl-error-ssl

 

但解决了上一个问题,接下来就遇到了

错误2:

{
    "ClassName": "System.Data.SqlClient.SqlException",
    "Message": "Connection Timeout Expired.  The timeout period elapsed during the post-login phase.  The connection could have timed out while waiting for server to complete the login process and respond; Or it could have timed out while attempting to create multiple active connections.  The duration spent while attempting to connect to this server was - [Pre-Login] initialization=0; handshake=9; [Login] initialization=0; authentication=0; [Post-Login] complete=14454; ",
    "Data": {
        "HelpLink.ProdName": "Microsoft SQL Server",
        "HelpLink.EvtSrc": "MSSQLServer",
        "HelpLink.EvtID": "-2",
        "HelpLink.BaseHelpUrl": "https://go.microsoft.com/fwlink",
        "HelpLink.LinkId": "20476",
        "SqlError 1": "System.Data.SqlClient.SqlError: Connection Timeout Expired.  The timeout period elapsed during the post-login phase.  The connection could have timed out while waiting for server to complete the login process and respond; Or it could have timed out while attempting to create multiple active connections.  The duration spent while attempting to connect to this server was - [Pre-Login] initialization=0; handshake=9; [Login] initialization=0; authentication=0; [Post-Login] complete=14454; "
    },
    "InnerException": {
        "ClassName": "System.ComponentModel.Win32Exception",
        "Message": "Unknown error 258",
        "Data": null,
        "InnerException": null,
        "HelpURL": null,
        "StackTraceString": null,
        "RemoteStackTraceString": null,
        "RemoteStackIndex": 0,
        "ExceptionMethod": null,
        "HResult": -2147467259,
        "Source": null,
        "WatsonBuckets": null,
        "NativeErrorCode": 258
    },

问题和解决方法:

暂未找到,同样的程序在 windows 下暂未遇到此问题。

标签:core,HelpLink,r2,error,System,server,sql,null,Data
From: https://www.cnblogs.com/xwgli/p/18168562

相关文章

  • SQL查询优化
    当多表连接数据量只有几十万时还没有优化的必要,当数据量达到几百万或几千万时就有必要了,常见于日报,实时数据。最重要的优化是走索引。可以通过查询计划查看SQL语句中开销大的查询部分是不是全表扫描。但有时候根据业务逻辑写的SQL刚好避开了索引列。这时候需要走一些弯路。可以......
  • MySQL日志
    一条update的执行流程执行流程分为在server层和存储引擎层;server是MySQL都有的,其日志文件是binlog;存储引擎是不同的,undolog,redolog是innodb特有的。首先是客户端创建请求,然后去服务层请求;然后是server的连接器,连接器的作用是校验用户是否有权限进行查询等等。(在8.0版本之前有......
  • PHP mysql 大量批量insert或update数据出错问题
    UPDATEusersSETage=30WHEREname='Alice';UPDATEusersSETage=25WHEREname='Bob';UPDATEusersSETage=35WHEREname='Charlie';以上代码会导致并发性问题,因为多个更新语句可能会同时执行,导致数据错乱。解决办法:1、使用锁定LOCKTABLESusersWRIT......
  • PostgreSQL 简单使用
    切换到postgres用户:默认情况下,以postgres用户身份登录可以获得数据库的完全访问权限:sudosu-postgres登录到PostgreSQL:psql系统会提示您输入之前设置的postgres用户的密码。登录后,您可以创建新的数据库和用户,或者执行其他数据库操作。例如,创建一个名为mydatabas......
  • sql语句
    一、数据定义1.基本表定义:createtable<表名>(<列名><数据类型>[列级完整性约束条件],[<列名><数据类型>[列级完整性约束条件]]);示例:createtableCourse(Cnochar(4)primarykey,Cnamechar(40),Cpnochar(4),Ccreditsm......
  • MYSQL中Join的用法
    1、笛卡尔积(没有加筛选条件的内连接)两表关联,把左表的列和右表的列通过笛卡尔积的形式表达出来。mysql>select*fromt1joint2;或者mysql>select*fromt1innerjoint2;或者mysql>select*fromt1,t2;2、左连接两表关联,左表全部保留,右表关联不上用null表......
  • centos 7 下完全卸载 mysql 5.6
    centos下完全卸载mysql5.6 1查看已经安装的服务rpm-qa|grep-imysql-i作用是不区分大小写mysql-community-common-5.6.51-2.el7.x86_64mysql-community-libs-5.6.51-2.el7.x86_64mysql-community-server-5.6.51-2.el7.x86_64mysql-community-release-el7-5.noarchmy......
  • SQL实战(二)——数据类型
    MySQL数据类型MySQL中定义数据字段的类型对你数据库的优化是非常重要的。MySQL支持多种类型,大致可以分为三类:数值、日期/时间和字符串(字符)类型。数值类型MySQL支持所有标准SQL数值数据类型。这些类型包括严格数值数据类型(INTEGER、SMALLINT、DECIMAL和NUMERIC),以......
  • Babel与core-js
    1.Babel是把ES6的语法转成ES5比如:const、箭头函数、...(结构)、模板字符串等等Babel原理转译分为三阶段:解析(Parse),将代码解析⽣成抽象语法树AST,也就是词法分析与语法分析的过程转换(Transform),对语法树进⾏变换方面的⼀系列操作。通过babel-traverse,进⾏遍历并作添加、更新、......
  • mysql-B+树
    MySQL中的InnoDB存储引擎广泛使用了B+树作为索引的数据结构,这是因为它特别适合于磁盘I/O密集型操作,能够高效地处理大量的数据查询。B+树的基本特性有序性:B+树的所有叶子节点包含了全部的关键字以及对应的数据记录指针,并且这些叶子节点是按关键字的大小顺序链接在一起的。这使......