config: change certificates config key parsing to attempt Base64 decoding first. (#1055)

This commit is contained in:
Dmitri Farkov 2020-07-15 10:15:57 -04:00 committed by GitHub
parent a5db94434d
commit 253addcad6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 41 additions and 2 deletions

View file

@ -558,9 +558,12 @@ func (o *Options) Validate() error {
}
for _, c := range o.CertificateFiles {
cert, err := cryptutil.CertificateFromFile(c.CertFile, c.KeyFile)
cert, err := cryptutil.CertificateFromBase64(c.CertFile, c.KeyFile)
if err != nil {
return fmt.Errorf("config: bad cert file %w", err)
cert, err = cryptutil.CertificateFromFile(c.CertFile, c.KeyFile)
}
if err != nil {
return fmt.Errorf("config: bad cert entry, base64 or file reference invalid. %w", err)
}
o.Certificates = append(o.Certificates, *cert)
}