MS-SQL Server의 Encryption(ssl/tls) handshake failed κ΄€ν•˜μ—¬

μ•ˆλ…•ν•˜μ„Έμš”, λ‹·λ„·μœΌλ‘œ κ°œλ°œμ€‘μΈ μž…λ¬Έμž μž…λ‹ˆλ‹€.

ν˜„μž¬ C# .NET 8.0 Avalonia UI λ₯Ό μ΄μš©ν•˜μ—¬
Windows 와 Linux (Ubuntu 22.04 / 24.04) μͺ½μ—μ„œ λ‘˜λ‹€ 싀행이 κ°€λŠ₯ν•œ
ν”„λ‘œκ·Έλž¨μ„ λ§Œλ“œλ € ν•˜λŠ”λ°,

MS SQL Serverμ™€μ˜ 연결을 μœ„ν•˜μ—¬ Microsoft.Data.SqlClient 의
SqlConnection 을 μ΄μš©ν•˜μ—¬ Open()을 ν•˜λ € ν–ˆμŠ΅λ‹ˆλ‹€.

μ ‘μ†ν•˜λ €κ³  ν…ŒμŠ€νŠΈν•œ SQL ServerλŠ” 총 3개 μž…λ‹ˆλ‹€.

  1. Microsoft SQL Server 2005 - 9.0.3077
  2. Microsoft SQL Server 2008 R2 (SP2) - 10.50.4042.0 (X64)
  3. Microsoft SQL Server 2022 - 16.0.1000

μ²˜μŒμ—λŠ”
"
Error: A connection was successfully established with the server, but then an error occurred during the pre-login handshake. (provider: SSL Provider, error: 31 - Encryption(ssl/tls/ handshake failed)
" 였λ₯˜κ°€ λ°œμƒν•˜μ˜€λŠ”λ°, 자료λ₯Ό 찾던 쀑

μœ„ 링크의 λ‚΄μš©μ„ μ°Έκ³ ν•˜λ©΄μ„œ ν…ŒμŠ€νŠΈλ₯Ό μ§„ν–‰ν•΄λ΄€μŠ΅λ‹ˆλ‹€.

2번과 3번의 κ²½μš°μ—λŠ” λ‹΅λ³€μ˜ λ‚΄μš©λŒ€λ‘œ openssl.cnf λ₯Ό μˆ˜μ •ν•˜λ‹ˆ
Connection O.K κ°€ λ˜μ—ˆλŠ”λ°,

1번 Server의 κ²½μš°μ—λŠ” 였λ₯˜ λ‚΄μš©μ΄
"
Error: Connection Timeout Expired. The timeout period elapsed during the post-login phase. The connection could have timed out while waiting for server to complete the login process and respond; Or it could have timed out while attempting to create multiple active connections. The duration spent while attempting to connect to this server was - [Pre-Login] initialization=0; handshake=9; [Login] initialization=0; authentication=0; [Post-Login] complete=14005;
"
둜 λ°”λ€Œμ—ˆμœΌλ‚˜ μ‹€μ œλ‘œ 연결이 λ˜μ§€λŠ” μ•ŠμŠ΅λ‹ˆλ‹€.

이것저것 찾아보닀 λ³΄λ‹ˆ,
Linux (ubuntu)의 경우 SSL 의 TLS 정책을 λ”°λΌκ°€λŠ”λ°
Microsoft.Data.SqlClientλ₯Ό Linux μ—μ„œ μ‚¬μš©ν•˜λ €λ©΄
μ΅œμ†Œ TLS v1.2 κ°€ ν•„μš”ν•œλ°

MS SQL Server 2005와 νŒ¨μΉ˜κ°€ μ•ˆ 된 2008의 κ²½μš°μ—λŠ”
TLS v1.0 만 μ§€μ›ν•˜λ―€λ‘œ μ‚¬μš©ν•  수 없닀라고 ν•˜λ„€μš”.

이 κ²½μš°μ—, λ§Œμ•½
MS SQL Server 2005 와 Microsoft.Data.SqlClient 간에
연결이 κ°€λŠ₯ν•œ λ‹€λ₯Έ 방법이 μžˆμ„κΉŒμš”?

μ•„λ‹ˆλ©΄ κ΅¬ν˜• μ„œλ²„λŠ”
System.Data.SqlClient λ₯Ό μ΄μš©ν•˜λŠ” 방법밖에 μ—†μ„κΉŒμš”?

2개의 μ’‹μ•„μš”

질문 닡변은 μžμœ κ²Œμ‹œνŒμ΄ μ•„λ‹Œ μ μ ˆν•œ 질문 λ‹΅λ³€ κ²Œμ‹œνŒμ— μ˜¬λ €μ£Όμ‹œλ©΄ κ°μ‚¬ν•˜κ² μŠ΅λ‹ˆλ‹€. μΉ΄ν…Œκ³ λ¦¬λŠ” λ³€κ²½ν•΄λ“œλ ΈμŠ΅λ‹ˆλ‹€.

2개의 μ’‹μ•„μš”

κ²°λ‘ λΆ€ν„° μ–˜κΈ°ν•˜λ©΄ System.Data.SqlClientλ₯Ό μ‚¬μš©ν•˜λŠ” λ°©λ²•μ΄λ‚˜ Encrypt=Optional;TrustServerCertificate=True λ₯Ό λ„£μ–΄μ„œ μ‚¬μš©ν•˜λŠ” 방법 밖에 없을 κ±° κ°™μŠ΅λ‹ˆλ‹€. λ³΄μ•ˆμ μœΌλ‘œ 보면 μ’‹μ§€ μ•Šμ€ 선택듀인데 2019 μ •λ„λ‘œλ§Œ 올리면 bestκΈ΄ 할텐데 여건이 μ–΄λ– μ‹ μ§€ λͺ°λΌ 적어도 2012 SP4 μ΄μƒμœΌλ‘œ μ˜¬λ¦¬μ‹œλŠ” 건 μ–΄λ–¨μ§€ μ˜κ²¬λ“œλ €λ΄μš”.

λ„€, κ°μ‚¬ν•©λ‹ˆλ‹€.

  1. Encrypt=False;
  2. Encrypt=False; TrustServerCertificate=True;
  3. Encrypt=True; TrustServerCertificate=True;
  4. Encrypt=Optional; TrustServerCertificate=True;

4κ°€μ§€λ₯Ό λͺ¨λ‘ ν•΄λ΄€λŠ”λ° Linux μ—μ„œλŠ”
Encrypt = True ; 일 λ•Œμ™€ Encrypt = Optional; 일 λ•Œλ„ λ§ˆμ°¬κ°€μ§€λ‘œ 접속이 μ•ˆ λ˜λ„€μš”.

확인해봀을 λ•Œ μƒˆλ‘œ λ°œκ²¬ν•œ 점은,

AMD64 기반 PC판 Ubuntu 24.04 μ—μ„œλŠ”
MS SQL Server 2008 SP2 λ₯Ό Encrypt=Falseλ‘œλ„ 접속이 λ˜λŠ”λ°

Arm64 (aarch64기반) Ubuntu 22.04 μ—μ„œλŠ”
같은 connection string 에 같은 쑰건으둜 λ§žμΆ°λ†“μ•„λ„
접속이 μ•ˆ 되고
Error: A connection was successfully establisehd with the server, but then an error occurred during the pre-login handshake. (provider: TCP Provider, error:35 - An internal exception was caught)
였λ₯˜κ°€ λ°œμƒν•˜λ„€μš”.

일단은 μƒˆ ν”„λ‘œκ·Έλž¨μ—μ„œλŠ” ꡬ 버전 지원을 μ•ˆ ν•˜λŠ”κ±Έλ‘œ κ³ λ €ν•΄λ³΄μ•„ν•˜κ² λ„€μš”.
κ°μ‚¬ν•©λ‹ˆλ‹€.

1개의 μ’‹μ•„μš”