fix: hy2/tuic inbound cert isn't path
Co-authored-by: wwqgtxx <wwqgtxx@gmail.com>
This commit is contained in:
parent
8253bfe2e0
commit
dbaee284e4
4 changed files with 10 additions and 10 deletions
|
@ -10,7 +10,11 @@ import (
|
|||
"math/big"
|
||||
)
|
||||
|
||||
func ParseCert(certificate, privateKey string) (tls.Certificate, error) {
|
||||
type Path interface {
|
||||
Resolve(path string) string
|
||||
}
|
||||
|
||||
func ParseCert(certificate, privateKey string, path Path) (tls.Certificate, error) {
|
||||
if certificate == "" && privateKey == "" {
|
||||
return newRandomTLSKeyPair()
|
||||
}
|
||||
|
@ -19,6 +23,8 @@ func ParseCert(certificate, privateKey string) (tls.Certificate, error) {
|
|||
return cert, nil
|
||||
}
|
||||
|
||||
certificate = path.Resolve(certificate)
|
||||
privateKey = path.Resolve(privateKey)
|
||||
cert, loadErr := tls.LoadX509KeyPair(certificate, privateKey)
|
||||
if loadErr != nil {
|
||||
return tls.Certificate{}, fmt.Errorf("parse certificate failed, maybe format error:%s, or path error: %s", painTextErr.Error(), loadErr.Error())
|
||||
|
|
|
@ -112,7 +112,7 @@ func Start(addr string, tlsAddr string, secret string,
|
|||
|
||||
if len(tlsAddr) > 0 {
|
||||
go func() {
|
||||
c, err := CN.ParseCert(certificat, privateKey)
|
||||
c, err := CN.ParseCert(certificat, privateKey, C.Path)
|
||||
if err != nil {
|
||||
log.Errorln("External controller tls listen error: %s", err)
|
||||
return
|
||||
|
|
|
@ -50,10 +50,7 @@ func New(config LC.Hysteria2Server, tunnel C.Tunnel, additions ...inbound.Additi
|
|||
|
||||
sl = &Listener{false, config, nil, nil}
|
||||
|
||||
config.Certificate = C.Path.Resolve(config.Certificate)
|
||||
config.PrivateKey = C.Path.Resolve(config.PrivateKey)
|
||||
|
||||
cert, err := CN.ParseCert(config.Certificate, config.PrivateKey)
|
||||
cert, err := CN.ParseCert(config.Certificate, config.PrivateKey, C.Path)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
|
@ -44,10 +44,7 @@ func New(config LC.TuicServer, tunnel C.Tunnel, additions ...inbound.Addition) (
|
|||
Additions: additions,
|
||||
}
|
||||
|
||||
config.Certificate = C.Path.Resolve(config.Certificate)
|
||||
config.PrivateKey = C.Path.Resolve(config.PrivateKey)
|
||||
|
||||
cert, err := CN.ParseCert(config.Certificate, config.PrivateKey)
|
||||
cert, err := CN.ParseCert(config.Certificate, config.PrivateKey, C.Path)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue