From eb6e4a982d6044147d7613875a4ccf5c0e3c3764 Mon Sep 17 00:00:00 2001 From: dalbodeule <11470513+dalbodeule@users.noreply.github.com> Date: Tue, 2 Dec 2025 23:33:42 +0900 Subject: [PATCH] [fix](client): ensure proper SNI hostname extraction in TLS config - Updated `tlsCfg.ServerName` logic to extract and set hostname (DNS) from `ServerAddr` to comply with SNI requirements. - Utilized `net.SplitHostPort` for accurate parsing of `host:port` format. --- cmd/client/main.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/cmd/client/main.go b/cmd/client/main.go index 60dfa13..86e2b2a 100644 --- a/cmd/client/main.go +++ b/cmd/client/main.go @@ -5,6 +5,7 @@ import ( "crypto/tls" "crypto/x509" "flag" + "net" "os" "strings" @@ -118,7 +119,13 @@ func main() { } // DTLS 서버 측은 SNI(ServerName)가 HOP_SERVER_DOMAIN(cfg.Domain)과 일치하는지 검사하므로, // 클라이언트 TLS 설정에도 반드시 도메인을 설정해준다. - tlsCfg.ServerName = finalCfg.Domain + // + // finalCfg.ServerAddr 가 "host:port" 형태이므로, SNI 에는 DNS(host) 부분만 넣어야 한다. + host := finalCfg.ServerAddr + if h, _, err := net.SplitHostPort(finalCfg.ServerAddr); err == nil && strings.TrimSpace(h) != "" { + host = h + } + tlsCfg.ServerName = host client := dtls.NewPionClient(dtls.PionClientConfig{ Addr: finalCfg.ServerAddr,