support default certificate files
This commit is contained in:
parent
29a1c06b9f
commit
0e782085ae
@ -217,10 +217,7 @@ func serve(chain *gost.Chain) error {
|
|||||||
if node.User != nil {
|
if node.User != nil {
|
||||||
users = append(users, node.User)
|
users = append(users, node.User)
|
||||||
}
|
}
|
||||||
tlsCfg, err := tlsConfig(node.Values.Get("cert"), node.Values.Get("key"))
|
tlsCfg, _ := tlsConfig(node.Values.Get("cert"), node.Values.Get("key"))
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
var ln gost.Listener
|
var ln gost.Listener
|
||||||
switch node.Transport {
|
switch node.Transport {
|
||||||
@ -359,8 +356,11 @@ func serve(chain *gost.Chain) error {
|
|||||||
|
|
||||||
// Load the certificate from cert and key files, will use the default certificate if the provided info are invalid.
|
// Load the certificate from cert and key files, will use the default certificate if the provided info are invalid.
|
||||||
func tlsConfig(certFile, keyFile string) (*tls.Config, error) {
|
func tlsConfig(certFile, keyFile string) (*tls.Config, error) {
|
||||||
if certFile == "" || keyFile == "" {
|
if certFile == "" {
|
||||||
return nil, nil
|
certFile = "cert.pem"
|
||||||
|
}
|
||||||
|
if keyFile == "" {
|
||||||
|
keyFile = "key.pem"
|
||||||
}
|
}
|
||||||
cert, err := tls.LoadX509KeyPair(certFile, keyFile)
|
cert, err := tls.LoadX509KeyPair(certFile, keyFile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user