mirror of https://github.com/1Panel-dev/1Panel
fix: 解决远程数据库添加验证失败的问题 (#3942)
parent
50a83e7e11
commit
ef5e42cf0b
|
@ -9,6 +9,7 @@ import (
|
||||||
|
|
||||||
"github.com/1Panel-dev/1Panel/backend/buserr"
|
"github.com/1Panel-dev/1Panel/backend/buserr"
|
||||||
"github.com/1Panel-dev/1Panel/backend/constant"
|
"github.com/1Panel-dev/1Panel/backend/constant"
|
||||||
|
"github.com/1Panel-dev/1Panel/backend/global"
|
||||||
"github.com/1Panel-dev/1Panel/backend/utils/mysql/client"
|
"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)
|
ctx, cancel := context.WithTimeout(context.Background(), time.Duration(conn.Timeout)*time.Second)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
if err := db.PingContext(ctx); err != nil {
|
if err := db.PingContext(ctx); err != nil {
|
||||||
|
global.LOG.Errorf("test mysql conn failed, err: %v", err)
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
if ctx.Err() == context.DeadlineExceeded {
|
if ctx.Err() == context.DeadlineExceeded {
|
||||||
|
|
|
@ -135,7 +135,6 @@ func ConnWithSSL(ssl, skipVerify bool, clientKey, clientCert, rootCert string) (
|
||||||
return "", errors.New("unable to append root cert to pool")
|
return "", errors.New("unable to append root cert to pool")
|
||||||
}
|
}
|
||||||
tlsConfig.RootCAs = pool
|
tlsConfig.RootCAs = pool
|
||||||
tlsConfig.VerifyPeerCertificate = VerifyPeerCertFunc(pool)
|
|
||||||
}
|
}
|
||||||
if len(clientCert) != 0 && len(clientKey) != 0 {
|
if len(clientCert) != 0 && len(clientKey) != 0 {
|
||||||
cert, err := tls.X509KeyPair([]byte(clientCert), []byte(clientKey))
|
cert, err := tls.X509KeyPair([]byte(clientCert), []byte(clientKey))
|
||||||
|
|
Loading…
Reference in New Issue