Allow hsm to use relative paths
This commit is contained in:
parent
0d69a9013d
commit
c2b987fd31
1 changed files with 6 additions and 12 deletions
|
@ -69,21 +69,18 @@ func NewAccess(infoLog *log.Logger, options ...ConfigOption) (*Access, error) {
|
|||
return access, nil
|
||||
}
|
||||
|
||||
func (c *caFile) buildCertificatePath(caDirectory string) (string, error) {
|
||||
func (c *caFile) buildCertificatePath(caDirectory string) string {
|
||||
fileName := c.sc.CertificateFileName(c.label)
|
||||
|
||||
if caDirectory == "" {
|
||||
return "", errors.New("CA directory is not set")
|
||||
return fileName
|
||||
}
|
||||
|
||||
return path.Join(caDirectory, fileName), nil
|
||||
return path.Join(caDirectory, fileName)
|
||||
}
|
||||
|
||||
func (c *caFile) loadCertificate(caDirectory string) (*x509.Certificate, error) {
|
||||
certFile, err := c.buildCertificatePath(caDirectory)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
certFile := c.buildCertificatePath(caDirectory)
|
||||
|
||||
certFileInfo, err := os.Stat(certFile)
|
||||
if err != nil {
|
||||
|
@ -121,12 +118,9 @@ func (c *caFile) loadCertificate(caDirectory string) (*x509.Certificate, error)
|
|||
}
|
||||
|
||||
func (c *caFile) storeCertificate(caDirectory string, certificate []byte) error {
|
||||
certFile, err := c.buildCertificatePath(caDirectory)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
certFile := c.buildCertificatePath(caDirectory)
|
||||
|
||||
err = os.WriteFile(certFile, certificate, 0o600)
|
||||
err := os.WriteFile(certFile, certificate, 0o600)
|
||||
if err != nil {
|
||||
return fmt.Errorf("could not write certificate file %s: %w", certFile, err)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue