Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd: replace newline in HTTP_TLS #331

Merged
merged 1 commit into from
Dec 19, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion cmd/server/helper_cert.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
"github.com/spf13/cobra"
"github.com/spf13/viper"
"github.com/square/go-jose"
"strings"
)

const (
Expand Down Expand Up @@ -49,10 +50,13 @@ func loadCertificateFromEnv() *tls.Certificate {
return nil
}

keyString = strings.Replace(keyString, "\\n", "\n", -1)
certString = strings.Replace(certString, "\\n", "\n", -1)

var cert tls.Certificate
var err error
if cert, err = tls.X509KeyPair([]byte(certString), []byte(keyString)); err != nil {
logrus.Warn("Could not parse x509 key pair from env: %s", cert)
logrus.Warningf("Could not parse x509 key pair from env: %s", cert)
return nil
}

Expand All @@ -61,8 +65,10 @@ func loadCertificateFromEnv() *tls.Certificate {

func getOrCreateTLSCertificate(cmd *cobra.Command, c *config.Config) tls.Certificate {
if cert := loadCertificateFromFile(cmd); cert != nil {
logrus.Info("Loaded tls certificate from file")
return *cert
} else if cert := loadCertificateFromEnv(); cert != nil {
logrus.Info("Loaded certificate from environment variable")
return *cert
}

Expand Down