Skip to content
This repository has been archived by the owner on Jun 29, 2024. It is now read-only.

Commit

Permalink
Fix write
Browse files Browse the repository at this point in the history
  • Loading branch information
DerAndereAndi committed Apr 9, 2024
1 parent 5f68512 commit 9ac5268
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,20 @@ func main() {
Type: "CERTIFICATE",
Bytes: certificate.Certificate[0],
})
os.WriteFile("cert.crt", pemdata, 0666)
err := os.WriteFile("cert.crt", pemdata, 0600)
if err != nil {
log.Fatal(err)
}

b, err := x509.MarshalECPrivateKey(certificate.PrivateKey.(*ecdsa.PrivateKey))
if err != nil {
log.Fatal(err)
}
pemdata = pem.EncodeToMemory(&pem.Block{Type: "EC PRIVATE KEY", Bytes: b})
os.WriteFile("cert.key", pemdata, 0666)
err = os.WriteFile("cert.key", pemdata, 0600)
if err != nil {
log.Fatal(err)
}
} else {
fmt.Println("Using certificate file", *crt, "and key file", *key)
}
Expand Down

0 comments on commit 9ac5268

Please sign in to comment.