failed to initialize database, got error TLS Handshake failed: cannot read handshake packet: read tcp 172.16.1.79:40338->172.16.1.49:1433: read: connection reset The server is SQL Server 2008 The clinet is windows server 2008

Comment From: github-actions[bot]

The issue has been automatically marked as stale as it missing playground pull request link, which is important to help others understand your issue effectively and make sure the issue hasn't been fixed on latest master, checkout https://github.com/go-gorm/playground for details. it will be closed in 30 days if no further activity occurs. if you are asking question, please use the Question template, most likely your question already answered https://github.com/go-gorm/gorm/issues or described in the document https://gorm.io ✨ Search Before Asking

Comment From: jinzhu

Checkout github.com/microsoft/go-mssqldb's DSN part for how to

Comment From: LZkCrown

If I use github.com/microsoft/go-mssqldb, the same string is successfully connected

Comment From: LZkCrown

package main

import ( "database/sql" "encoding/base64" "fmt" "github.com/go-ini/ini" _ "github.com/microsoft/go-mssqldb" )

func main() { cfg, err := ini.Load("db.ini") if err != nil { fmt.Println("读取配置文件错误") return } dsn, _ := base64.StdEncoding.DecodeString(cfg.Section("").Key("dsn").String()) _, err1 := sql.Open("mssql", string(dsn)) if err1 != nil { fmt.Println(err1.Error()) } else { fmt.Println("连接成功") } } this is success

Comment From: LZkCrown

package main

import ( "encoding/base64" "fmt" "github.com/go-ini/ini" "gorm.io/driver/sqlserver" "gorm.io/gorm" )

func main() { cfg, err := ini.Load("db.ini") if err != nil { fmt.Println("读取配置文件错误") return } dsn, _ := base64.StdEncoding.DecodeString(cfg.Section("").Key("dsn").String()) _, err1 := gorm.Open(sqlserver.Open(string(dsn)), &gorm.Config{}) if err1 != nil { fmt.Println(err1.Error()) } else { fmt.Println("连接成功") } } this is fail

Comment From: LZkCrown

I analyzed the problem,The problem occurred in gorm.Open if err == nil && !config.DisableAutomaticPing { if pinger, ok := db.ConnPool.(interface{ Ping() error }); ok { err = pinger.Ping() } }

Comment From: LZkCrown

Thank you very much! We have found a solution and added tlsmin=1.0 to the dsn to solve it. The reason is that go1.18 has disabled tls 1.0 and 1.1