cryptutil: generate certificates from deriveca

This commit is contained in:
Caleb Doxsey 2023-02-17 18:54:45 -07:00
parent b13afc7b0c
commit 91fca06397
8 changed files with 28 additions and 62 deletions

View file

@ -185,8 +185,13 @@ func (cfg *Config) GetCertificateForServerName(serverName string) (*tls.Certific
return &cert, nil
}
sharedKey, err := cfg.Options.GetSharedKey()
if err != nil {
return nil, fmt.Errorf("failed to generate cert, invalid shared key: %w", err)
}
// finally fall back to a generated, self-signed certificate
return cryptutil.GenerateSelfSignedCertificate(serverName)
return cryptutil.GenerateCertificate(sharedKey, serverName)
}
// WillHaveCertificateForServerName returns true if there will be a certificate for the given server name.