fix: 解决远程数据库添加验证失败的问题 (#3942)

pull/3946/head
ssongliu 2024-02-21 19:08:29 +08:00 committed by GitHub
parent 50a83e7e11
commit ef5e42cf0b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 2 additions and 1 deletions

View File

@ -9,6 +9,7 @@ import (
"github.com/1Panel-dev/1Panel/backend/buserr"
"github.com/1Panel-dev/1Panel/backend/constant"
"github.com/1Panel-dev/1Panel/backend/global"
"github.com/1Panel-dev/1Panel/backend/utils/mysql/client"
)
@ -50,6 +51,7 @@ func NewMysqlClient(conn client.DBInfo) (MysqlClient, error) {
ctx, cancel := context.WithTimeout(context.Background(), time.Duration(conn.Timeout)*time.Second)
defer cancel()
if err := db.PingContext(ctx); err != nil {
global.LOG.Errorf("test mysql conn failed, err: %v", err)
return nil, err
}
if ctx.Err() == context.DeadlineExceeded {

View File

@ -135,7 +135,6 @@ func ConnWithSSL(ssl, skipVerify bool, clientKey, clientCert, rootCert string) (
return "", errors.New("unable to append root cert to pool")
}
tlsConfig.RootCAs = pool
tlsConfig.VerifyPeerCertificate = VerifyPeerCertFunc(pool)
}
if len(clientCert) != 0 && len(clientKey) != 0 {
cert, err := tls.X509KeyPair([]byte(clientCert), []byte(clientKey))