Skip to content

Commit

Permalink
Use subdir to not pollute user default config dir
Browse files Browse the repository at this point in the history
  • Loading branch information
sourishkrout committed Aug 8, 2024
1 parent 51cacfd commit 452e0e5
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions internal/tls/tls.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,12 @@ func generateCertificate(certFile, keyFile string) (*tls.Config, error) {
return nil, errors.WithStack(err)
}

if _, err := os.Stat(filepath.Dir(certFile)); errors.Is(err, fs.ErrNotExist) {
if err := os.MkdirAll(filepath.Dir(certFile), tlsDirMode); err != nil {
return nil, errors.Wrap(err, "failed to create TLS directory")
}
}

if err := os.WriteFile(certFile, caPEM.Bytes(), tlsFileMode); err != nil {
return nil, errors.Wrap(err, "failed to write CA")
}
Expand Down

0 comments on commit 452e0e5

Please sign in to comment.