Fix permissions on newly generated private keys (#3)

Signed-off-by: Patrick Uiterwijk <patrick@puiterwijk.org>
This commit is contained in:
Patrick Uiterwijk
2018-06-28 04:18:33 +02:00
committed by Filippo Valsorda
parent 6eb6ca5d60
commit 3532f34209

View File

@@ -160,11 +160,11 @@ func (m *mkcert) makeCert(hosts []string) {
privDER, err := x509.MarshalPKCS8PrivateKey(priv) privDER, err := x509.MarshalPKCS8PrivateKey(priv)
fatalIfErr(err, "failed to encode certificate key") fatalIfErr(err, "failed to encode certificate key")
err = ioutil.WriteFile(filename+"-key.pem", pem.EncodeToMemory( err = ioutil.WriteFile(filename+"-key.pem", pem.EncodeToMemory(
&pem.Block{Type: "PRIVATE KEY", Bytes: privDER}), 0644) &pem.Block{Type: "PRIVATE KEY", Bytes: privDER}), 0400)
fatalIfErr(err, "failed to save certificate key") fatalIfErr(err, "failed to save certificate key")
err = ioutil.WriteFile(filename+".pem", pem.EncodeToMemory( err = ioutil.WriteFile(filename+".pem", pem.EncodeToMemory(
&pem.Block{Type: "CERTIFICATE", Bytes: cert}), 0600) &pem.Block{Type: "CERTIFICATE", Bytes: cert}), 0644)
fatalIfErr(err, "failed to save certificate key") fatalIfErr(err, "failed to save certificate key")
log.Printf("\nCreated a new certificate valid for the following names 📜") log.Printf("\nCreated a new certificate valid for the following names 📜")