我已经看过几次这个问题的部分内容,但对我来说还没有什么效果。
我有一个在Windows服务器上运行的server 2012实例。在我的Ubuntu20.10服务器上,我在apache服务器上运行PHP 7.4.12。我已经安装了openssl版本1.1.1。
我遵循了microsoft文档中的大多数说明:
但是在下载msodbcsql17驱动程序时遇到了一些问题。我不得不从这里下载它:
https://packages.microsoft.com/ubuntu/20.04/prod/pool/main/m/msodbcsql17/
我的PHP脚本:
<?php
try {
// Sensitive info is replaced by temporary strings.
$serverName = "<ip_addr>,<port>";
$options = array("Database" => "<db_name>", "UID" => "<user_name>", "PWD" => "<password>");
$conn = sqlsrv_connect($serverName, $options);
if ($conn == false) {
var_dump(sqlsrv_errors());
die();
}
} catch(Exception $e) {
echo("Error!");
}
下面是上面代码中从var_dump(sqlsrv_errors());
打印出来的错误:
array(2) {
[0]=>
array(6) {
[0]=>
string(5) "08001"
["SQLSTATE"]=>
string(5) "08001"
[1]=>
int(10054)
["code"]=>
int(10054)
[2]=>
string(73) "[Microsoft][ODBC Driver 17 for SQL Server]TCP Provider: Error code 0x2746"
["message"]=>
string(73) "[Microsoft][ODBC Driver 17 for SQL Server]TCP Provider: Error code 0x2746"
}
[1]=>
array(6) {
[0]=>
string(5) "08001"
["SQLSTATE"]=>
string(5) "08001"
[1]=>
int(10054)
["code"]=>
int(10054)
[2]=>
string(79) "[Microsoft][ODBC Driver 17 for SQL Server]Client unable to establish connection"
["message"]=>
string(79) "[Microsoft][ODBC Driver 17 for SQL Server]Client unable to establish connection"
}
}
我在这里看到了这个潜在的解决方案:https://github.com/microsoft/msphpsql/issues/1021#issuecomment-520943561,但是在/etc/ssl/openssl.cnf
文件中没有行CipherString = DEFAULT@SECLEVEL-2
,因为答案状态。无论如何,我尝试将CipherString = DEFAULT@SECLEVEL=1
添加到文件的末尾,但是没有什么改变。
我能做些什么来修复连接中的错误?是降低openssl版本的唯一其他选择吗?我读到过,它可以破坏许多包并引起问题。我也不能将Server脱机升级到更新的SQL版本。
我已经确保Server接受远程连接,因为我可以使用Crystal Reports从另一台计算机向Server建立ODBC连接。
编辑: openssl命令结果
以下是运行后立即打印的结果:
openssl s_client -host <ip_addr> -port <port> -tls1
CONNECTED(00000003)
139710250579264:error:141E70BF:SSL routines:tls_construct_client_hello:no protoc ols available:../ssl/statem/statem_clnt.c:1112:
---
no peer certificate available
---
No client certificate CA names sent
---
SSL handshake has read 0 bytes and written 7 bytes
Verification: OK
---
New, (NONE), Cipher is (NONE)
Secure Renegotiation IS NOT supported
Compression: NONE
Expansion: NONE
No ALPN negotiated
Early data was not sent
Verify return code: 0 (ok)
---
以下是运行后的结果:
openssl s_client -host <ip_addr> -port <port> -tls1_2
它打开了一段时间,最后,在没有输入任何东西之后,它打印了如下:
CONNECTED(00000003)
write:errno=104
---
no peer certificate available
---
No client certificate CA names sent
---
SSL handshake has read 0 bytes and written 188 bytes
Verification: OK
---
New, (NONE), Cipher is (NONE)
Secure Renegotiation IS NOT supported
Compression: NONE
Expansion: NONE
No ALPN negotiated
SSL-Session:
Protocol : TLSv1.2
Cipher : 0000
Session-ID:
Session-ID-ctx:
Master-Key:
PSK identity: None
PSK identity hint: None
SRP username: None
Start Time: 1605916005
Timeout : 7200 (sec)
Verify return code: 0 (ok)
Extended master secret: no
---
发布于 2021-03-30 13:20:48
现在有点晚了。试试MinProtocol = TLSv1.0
in /etc/ssl/openssl.cnf
。这对我来说很好(https://github.com/microsoft/msphpsql/issues/1023#issuecomment-523214695)
https://stackoverflow.com/questions/64922870
复制相似问题