Windows 7下連線SQL伺服器SSL安全錯誤的處理方法

問題描述:

客戶有一個EXCEL的表格,其中有部分資料是需要訪問SQL資料庫,把查詢結果匯入表格的。但是最近一週忽然發生了匯入資料的時候出錯。錯誤資訊如下:

SQLState:‘01000’

SQL Server 錯誤:1

[Microsoft] [ODBC SQL Server Driver][DBNETLIB]ConnectionOpen

(SECCreateCredentials())

連線失敗:

SQLState:‘08001’

SQL Server 錯誤:18

[Microsoft] [ODBC SQL Server Driver][DBNETLIB]SSL安全錯誤

Windows 7下連線SQL伺服器SSL安全錯誤的處理方法

同樣的檔案,在Windows 10的系統下就可以正常工作。但是Windows 7 系統就會有這個問題。

原因分析:

初步判斷是因為伺服器可能最近開啟了SSL驗證。而Windows 7的系統連線客戶端預設是沒有開啟SSL的。

解決方法:

1. 修改登錄檔,開啟登錄檔編輯器。

找到以下2個鍵值,把Enable的值從0修改為1.

對應於SSL2.0

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\SSL 2.0\Client]

"Enabled"=dword:00000001

對應於SSL3.0

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\SSL 3.0\Client]

"Enabled"=dword:00000001

Windows 7下連線SQL伺服器SSL安全錯誤的處理方法

2. 建立一個登錄檔檔案,把它匯入登錄檔。

2.1 新建一個文字檔案,把以下內容貼上進去:

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols]

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\SSL 2.0]

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\SSL 2.0\Client]

"DisabledByDefault"=dword:00000000

"Enabled"=dword:00000001

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\SSL 3.0]

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\SSL 3.0\Client]

"Enabled"=dword:00000001

2.2 把這個文字檔案儲存為 XXXX.REG 就可以直接雙擊匯入登錄檔了。也可以用於其他有同樣問題的電腦了。

至此問題解決。