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服务