mirror of
https://github.com/dstotijn/hetty
synced 2024-11-10 06:04:19 +00:00
fix: close key files
This commit is contained in:
parent
f7def87d0f
commit
b6d74ec8a0
1 changed files with 2 additions and 0 deletions
|
@ -114,11 +114,13 @@ func LoadOrCreateCA(caKeyFile, caCertFile string) (*x509.Certificate, *rsa.Priva
|
|||
if err != nil {
|
||||
return nil, nil, fmt.Errorf("proxy: could not open cert file for writing: %w", err)
|
||||
}
|
||||
defer certOut.Close()
|
||||
|
||||
keyOut, err := os.OpenFile(caKeyFile, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0o600)
|
||||
if err != nil {
|
||||
return nil, nil, fmt.Errorf("proxy: could not open key file for writing: %w", err)
|
||||
}
|
||||
defer keyOut.Close()
|
||||
|
||||
// Write PEM blocks to CA certificate and key files.
|
||||
if err := pem.Encode(certOut, &pem.Block{Type: "CERTIFICATE", Bytes: caCert.Raw}); err != nil {
|
||||
|
|
Loading…
Reference in a new issue