centos下 连接sqlserver (provide:SSL Provider,error:31 – Encryption(ssl/tls) handshake failed)

Microsfot.Data.SqlClient.SqlException(0x80131904):A connection was successfully established with the server, but then an error occurred during the pre-login handshake.(provide:SSL Provider,error:31 – Encryption(ssl/tls) handshake failed)

一开始以为是服务器tsl版本问题,测试了下同样版本的其他服务器上却能连接上数据库。后来查资料发现此原因是因为Centos服务器默认使用的ssl为TLS1_2版本,而sqlserver需要的版本为TLSv1

修改方法如下:

vim /etc/pki/tls/openssl.cnf

#在oid_section=new_oids下增加
openssl_conf = default_conf

#在文件末尾增加
[default_conf]
ssl_conf = ssl_sect
[ssl_sect]
system_default = system_default_sect
[system_default_sect]
MinProtocol = TLSv1
CipherString = DEFAULT@SECLEVEL=1

重启sshd服务

关于笃志情缘

人尽其责,物尽其用,不成功,也无憾,毕竟奋斗过。走自己的路吧! 笃志建站:虚拟主机、域名注册、云主机、成品网站、企业邮局、CDN加速 http://www.duzhi.net QQ:3081689173
此条目发表在服务器相关分类目录。将固定链接加入收藏夹。