Commit 0e782085 authored by rui.zheng's avatar rui.zheng

support default certificate files

parent 29a1c06b
......@@ -217,10 +217,7 @@ func serve(chain *gost.Chain) error {
if node.User != nil {
users = append(users, node.User)
}
tlsCfg, err := tlsConfig(node.Values.Get("cert"), node.Values.Get("key"))
if err != nil {
return err
}
tlsCfg, _ := tlsConfig(node.Values.Get("cert"), node.Values.Get("key"))
var ln gost.Listener
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.
func tlsConfig(certFile, keyFile string) (*tls.Config, error) {
if certFile == "" || keyFile == "" {
return nil, nil
if certFile == "" {
certFile = "cert.pem"
}
if keyFile == "" {
keyFile = "key.pem"
}
cert, err := tls.LoadX509KeyPair(certFile, keyFile)
if err != nil {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment