Microsoft MVP성태의 닷넷 이야기
개발 환경 구성: 254. SQL 서버 역시 SSL 3.0/TLS 1.0만을 지원하는 듯! [링크 복사], [링크+제목 복사]
조회: 18817
글쓴 사람
정성태 (techsharer at outlook.com)
홈페이지
첨부 파일
 
(연관된 글이 2개 있습니다.)
(시리즈 글이 6개 있습니다.)
.NET Framework: 490. System.Data.SqlClient는 SSL 3.0/TLS 1.0만 지원하는 듯!
; https://www.sysnet.pe.kr/2/0/1833

개발 환경 구성: 254. SQL 서버 역시 SSL 3.0/TLS 1.0만을 지원하는 듯!
; https://www.sysnet.pe.kr/2/0/1835

.NET Framework: 2127. C# - Ubuntu + Microsoft.Data.SqlClient + SQL Server 2008 R2 연결 방법
; https://www.sysnet.pe.kr/2/0/13364

개발 환경 구성: 678. openssl로 생성한 인증서를 SQL Server의 암호화 인증서로 설정하는 방법
; https://www.sysnet.pe.kr/2/0/13368

개발 환경 구성: 680. C# - Ubuntu + Microsoft.Data.SqlClient + SQL Server 2008 R2 연결 방법 - TLS 1.2 지원
; https://www.sysnet.pe.kr/2/0/13370

개발 환경 구성: 682. SQL Server TLS 통신을 위해 사용되는 키 길이 확인 방법
; https://www.sysnet.pe.kr/2/0/13372




SQL 서버 역시 SSL 3.0/TLS 1.0만을 지원하는 듯!

지난 글에서 살펴본 것처럼,

System.Data.SqlClient는 SSL 3.0/TLS 1.0만 지원하는 듯!
; https://www.sysnet.pe.kr/2/0/1833

클라이언트가 이미 TLS 1.1/1.2를 지원하지 않고 있기 때문에 서버에서의 설정은 사실 무의미합니다. 그래도 한번 현상을 재현이나 해볼까요? ^^

우선, SQL 서버 측에 보안 통신을 위한 인증서를 등록해 보겠습니다.

"시작" / "Microsoft SQL Server 2008 R2" / "Configuration Tools" / "SQL Server Configuration Manager"를 실행하고 "SQL Server Network Configuration" / "Protocols for [YOUR_SQL_SERVER_INSTANCE]" 노드를 선택하고 마우스 우클릭을 해 "Properties" 메뉴를 선택해 다음의 설정을 해줍니다.

"Flags" 탭
  - "Force Encryption" 옵션을 Yes로 설정

"Certificate"
  - "Certiciate" 목록 상자에서 원하는 인증서를 선택

그런데, 받아 두었던 인증서가 "Certificate" 항목에 나타나지 않는 경우도 있습니다. 왜냐하면, 여기에 인증서가 나타나려면 2가지 조건을 만족해야 하기 때문입니다. (참조: Enabling Certificate for SSL on a SQL Server 2005 Clustered Installation)

  1. Certificates (Local Computer) 영역의 "Personal" 폴더에 위치
  2. 컴퓨터의 FQDN 이름과 일치하는 인증서(AD 참여 서버의 경우 도메인 이름까지 명시)

다행히 "Certificate" 목록 상자에 나오지 않아도 레지스트리를 통한 수작업 설정 방법이 제공되고 있으니 걱정하지 않아도 됩니다. 다음의 글에 따라,

Enabling Certificate for SSL on a SQL Server 2005 Clustered Installation
; http://blogs.msdn.com/b/jorgepc/archive/2008/02/19/enabling-certificates-for-ssl-connection-on-sql-server-2005-clustered-installation.aspx

Setting up SSL encryption for SQL Server using certificates ? Issues, tips & tricks
; http://thesqldude.com/2012/04/21/setting-up-ssl-encryption-for-sql-server-using-certificates-issues-tips-tricks/

"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL Server\MSSQL10.MSSQLSERVER\MSSQLServer\SuperSocketNetLib" 레지스트리 경로에 해당 인증서의 "Thumbprint" 값을 직접 입력하면 됩니다.

Name: Certificate
Type: REG_SZ
Data: ...[Your Certificate's Thumbprint]... (예: 1e385500fc7415f7843d83796b36b83450758c9e)

Thumbprint 값은 인증서 관리 콘솔에서 해당 인증서의 속성 창을 통해 구할 수 있는데, "공백 문자"가 포함되어 있기 때문에 메모장 등을 이용해 공백을 제거한 후 레지스트리에 설정해야 합니다.

결국, 다음의 2가지 처리를 해주시면 SQL 서버는 보안 통신을 할 수 있게 됩니다.

  1. "Force Encryption" 옵션을 Yes로 설정
  2. ...\SuperSocketNetLib 레지스트리 키의 "Certificate" 값에 인증서의 Thumbprint 값 입력

이 외에 주의 사항으로 해당 인증서의 개인 키 파일에 대해 SQL Server 프로세스의 실행 계정이 접근 가능해야 한다는 것입니다. 예를 들어, 제 경우에 SQL Server를 "Network Service" 계정으로 구동하는데 이로 인해 다음과 같이 (인증서 우클릭, "All Tasks" / "Manage Private Keys..." 메뉴 선택) 인증서의 개인키에 대한 접근 권한에 "Read"를 부여해야 합니다.

tls12_sql_1.png

모든 것이 정상적으로 설정되었다면 이제 SQL Service를 재시작합니다. 정상적으로 설정한 경우, 이벤트 로그에 "Event ID == 26013"으로 다음과 같은 항목을 볼 수 있습니다.

Log Name:      Application
Source:        MSSQLSERVER
Date:          2015-01-03 오후 4:33:09
Event ID:      26013
Task Category: Server
Level:         Information
Keywords:      Classic
User:          N/A
Computer:      win2008r2.testad.com
Description:
The certificate [Cert Hash(sha1) "1CB297B8F148FB061E43B3A09D0C524B75151457"] was successfully loaded for encryption.




자, 그럼 이제 TLS 제약을 좀 해볼까요? ^^

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:00000001

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\SSL 2.0\Server]
"Enabled"=dword:00000000
"DisabledByDefault"=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]
"DisabledByDefault"=dword:00000001

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\SSL 3.0\Server]
"Enabled"=dword:00000000
"DisabledByDefault"=dword:00000001

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

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.0\Client]
"DisabledByDefault"=dword:00000001

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.0\Server]
"Enabled"=dword:00000000
"DisabledByDefault"=dword:00000001

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

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.1\Client]
"DisabledByDefault"=dword:00000001

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.1\Server]
"Enabled"=dword:00000000
"DisabledByDefault"=dword:00000001

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

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.2\Client]
"DisabledByDefault"=dword:00000000
"Enabled"=dword:00000001

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.2\Server]
"Enabled"=dword:00000001
"DisabledByDefault"=dword:00000000

위의 레지스트리 등록은 SSL 2.0/3.0, TLS 1.0/1.1을 비활성화하고 TLS 1.2만을 활성화시킵니다. 이렇게 하고 SQL 서비스를 재시작하면 이제 Event ID == 17182, 26014 등의 오류 항목이 이벤트 로그에 남는 것을 보게 됩니다.

Log Name:      Application
Source:        MSSQLSERVER
Date:          2015-01-03 오전 7:55:44
Event ID:      17182
Task Category: Server
Level:         Error
Keywords:      Classic
User:          N/A
Computer:      win2008r2.testad.com
Description:
TDSSNIClient initialization failed with error 0x80092004, status code 0x80. Reason: Unable to initialize SSL support. Cannot find object or property.

Log Name:      Application
Source:        MSSQLSERVER
Date:          2015-01-03 오전 7:55:44
Event ID:      26014
Task Category: Server
Level:         Error
Keywords:      Classic
User:          N/A
Computer:      win2008r2.testad.com
Description:
Unable to load user-specified certificate [Cert Hash(sha1) "1E385500FC7415F7843D83796B36B83450758C9E"]. The server will not accept a connection. You should verify that the certificate is correctly installed. See "Configuring Certificate for Use by SSL" in Books Online

이 상태에서 SSL 3.0이나,

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 3.0]

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\SSL 3.0\Server]
"Enabled"=dword:00000001

TLS 1.0에 대해,

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

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

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.0\Server]
"Enabled"=dword:00000001

둘 중의 하나라도 Server 레지스트리 키를 Enabled == 1로 설정하면 다시 SQL Server는 정상적으로 서비스가 됩니다.




어찌 보면, 자연스러운 것이 아닐까 생각됩니다. 클라이언트 측에서 SSL 3.0/TLS 1.0만을 사용해 접속하는 데 SQL 서버 측에서 그 프로토콜들을 모두 막아버리면 통신할 방법이 없으니까요.

검색을 해보니, 누군가도 TLS 1.0, SSL 3.0 관련한 문제를 결국 그 중 하나를 살려두는 것으로 해결(?)했다고 합니다.

Sql server service wont start after disabling TLS 1.0 and SSL 3.0 on windows
; http://answers.flyppdevportal.com/categories/sqlserver/sqlsecurity.aspx?ID=5f543d1f-9483-49bb-9c65-999f287eaefa

여기서 문제는? IIS 서버와 SQL 서버를 함께 설치한 경우입니다. IIS 서버를 위해 TLS 1.2 강제 설정을 했는데, 그것이 SQL 서버까지 영향을 미친 것입니다.

제가 몇몇 조합을 해보니, 이런 경우는 TLS 1.0은 살려두면서 "DisableByDefault" 설정을 1로 해두면 IIS의 TLS 1.2 접속은 강제하면서 SQL 서버는 정상적으로 TLS 1.0 서비스를 했습니다.

Windows Registry Editor Version 5.00

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

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.0\Client]
"DisabledByDefault"=dword:00000000

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.0\Server]
"Enabled"=dword:00000001
"DisabledByDefault"=dword:00000001

아쉽게도 DisabledByDefault 옵션에 대해 Microsoft의 공식 문서가 없어서 정확히 어떤 차이점으로 인해 그렇게 되는지는 알 수 없었습니다.

마지막으로, 테스트를 하다 보니 Client 역할에 대해서도 제법 많은 서비스들이 TLS 1.2만 강제한 경우 문제가 발생했습니다. 따라서, 기존 서비스들에 영향을 최소화하면서 IIS TLS 1.2 강제를 위해 다음과 같은 정도로 레지스트리 구성을 하면 좋을 것 같습니다.

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:00000001

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\SSL 2.0\Server]
"Enabled"=dword:00000000
"DisabledByDefault"=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\Server]
"Enabled"=dword:00000001
"DisabledByDefault"=dword:00000001

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

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.0\Server]
"Enabled"=dword:00000001
"DisabledByDefault"=dword:00000001

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

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.1\Server]
"Enabled"=dword:00000001
"DisabledByDefault"=dword:00000001

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

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.2\Server]
"Enabled"=dword:00000001
"DisabledByDefault"=dword:00000000

그런데, 아직도 의아스러운 점이 있다면? 마이크로소프트 직원에 의하면,

SSL Cipher Suites used with SQL Server
; https://techcommunity.microsoft.com/t5/sql-server-blog/ssl-cipher-suites-used-with-sql-server/ba-p/383303

"
What the best cipher suite to use is negotiated by SSL/TLS and depends upon the cipher suites supported by the OS on the client and the server
...[생략]...
Determine the highest level protocol mutually supported by the client and the server.
The currently recognised protocols are, from highest to lowest: TLS1.1, TLS1.0, SSL3.0, SSL2.0
"


라고 하는 것으로 봐서 SQL Server/Client 레벨에서가 아닌 운영체제 지원 여부에 따라 TLS/SSL을 자유롭게 선택할 수 있는 듯 싶은데, 왜 SQL 서버가 SSL 3.0/TLS 1.0을 막았을 때 서비스가 안되는 것인지... 그 부분은 여전히 설명이 안되는 것 같습니다.




[이 글에 대해서 여러분들과 의견을 공유하고 싶습니다. 틀리거나 미흡한 부분 또는 의문 사항이 있으시면 언제든 댓글 남겨주십시오.]

[연관 글]






[최초 등록일: ]
[최종 수정일: 6/13/2023]

Creative Commons License
이 저작물은 크리에이티브 커먼즈 코리아 저작자표시-비영리-변경금지 2.0 대한민국 라이센스에 따라 이용하실 수 있습니다.
by SeongTae Jeong, mailto:techsharer at outlook.com

비밀번호

댓글 작성자
 




1  2  3  4  5  [6]  7  8  9  10  11  12  13  14  15  ...
NoWriterDateCnt.TitleFile(s)
13475정성태12/7/20232279닷넷: 2180. .NET 8 - 함수 포인터에 대한 Reflection 정보 조회파일 다운로드1
13474정성태12/6/20232133개발 환경 구성: 690. 닷넷 코어/5+ 버전의 ilasm/ildasm 실행 파일 구하는 방법 - 두 번째 이야기
13473정성태12/5/20232326닷넷: 2179. C# - 값 형식(Blittable)을 메모리 복사를 이용해 바이트 배열로 직렬화/역직렬화파일 다운로드1
13472정성태12/4/20232155C/C++: 164. Visual C++ - InterlockedCompareExchange128 사용 방법
13471정성태12/4/20232183Copilot - To enable GitHub Copilot, authorize this extension using GitHub's device flow
13470정성태12/2/20232484닷넷: 2178. C# - .NET 8부터 COM Interop에 대한 자동 소스 코드 생성 도입파일 다운로드1
13469정성태12/1/20232193닷넷: 2177. C# - (Interop DLL 없이) CoClass를 이용한 COM 개체 생성 방법파일 다운로드1
13468정성태12/1/20232176닷넷: 2176. C# - .NET Core/5+부터 달라진 RCW(Runtime Callable Wrapper) 대응 방식파일 다운로드1
13467정성태11/30/20232170오류 유형: 882. C# - Unhandled exception. System.Runtime.InteropServices.COMException (0x800080A5)파일 다운로드1
13466정성태11/29/20232376닷넷: 2175. C# - DllImport 메서드의 AOT 지원을 위한 LibraryImport 옵션
13465정성태11/28/20232111개발 환경 구성: 689. MSBuild - CopyToOutputDirectory가 "dotnet publish" 시에는 적용되지 않는 문제파일 다운로드1
13464정성태11/28/20232233닷넷: 2174. C# - .NET 7부터 UnmanagedCallersOnly 함수 export 기능을 AOT 빌드에 통합파일 다운로드1
13463정성태11/27/20232144오류 유형: 881. Visual Studio - NU1605: Warning As Error: Detected package downgrade
13462정성태11/27/20232210오류 유형: 880. Visual Studio - error CS0246: The type or namespace name '...' could not be found
13461정성태11/26/20232258닷넷: 2173. .NET Core 3/5+ 기반의 COM Server를 registry 등록 없이 사용하는 방법파일 다운로드1
13460정성태11/26/20232225닷넷: 2172. .NET 6+ 기반의 COM Server 내에 Type Library를 내장하는 방법파일 다운로드1
13459정성태11/26/20232207닷넷: 2171. .NET Core 3/5+ 기반의 COM Server를 기존의 regasm처럼 등록하는 방법파일 다운로드1
13458정성태11/26/20232212닷넷: 2170. .NET Core/5+ 기반의 COM Server를 tlb 파일을 생성하는 방법(tlbexp)
13457정성태11/25/20232164VS.NET IDE: 187. Visual Studio - 16.9 버전부터 추가된 "Display inline type hints" 옵션
13456정성태11/25/20232459닷넷: 2169. C# - OpenAI를 사용해 PDF 데이터를 대상으로 OpenAI 챗봇 작성 [1]파일 다운로드1
13455정성태11/25/20232339닷넷: 2168. C# - Azure.AI.OpenAI 패키지로 OpenAI 사용파일 다운로드1
13454정성태11/23/20232682닷넷: 2167. C# - Qdrant Vector DB를 이용한 Embedding 벡터 값 보관/조회 (Azure OpenAI) [1]파일 다운로드1
13453정성태11/23/20232218오류 유형: 879. docker desktop 설치 시 "Invalid JSON string. (Exception from HRESULT: 0x83750007)"
13452정성태11/22/20232296닷넷: 2166. C# - Azure OpenAI API를 이용해 사용자가 제공하는 정보를 대상으로 검색하는 방법파일 다운로드1
13451정성태11/21/20232431닷넷: 2165. C# - Azure OpenAI API를 이용해 ChatGPT처럼 동작하는 콘솔 응용 프로그램 제작파일 다운로드1
13450정성태11/21/20232254닷넷: 2164. C# - Octokit을 이용한 GitHub Issue 검색파일 다운로드1
1  2  3  4  5  [6]  7  8  9  10  11  12  13  14  15  ...