Browse Source

Fix permissions on newly generated private keys (#3)

Signed-off-by: Patrick Uiterwijk <patrick@puiterwijk.org>
Patrick Uiterwijk 6 years ago
parent
commit
3532f34209
1 changed files with 2 additions and 2 deletions
  1. 2 2
      main.go

+ 2 - 2
main.go

@@ -160,11 +160,11 @@ func (m *mkcert) makeCert(hosts []string) {
 	privDER, err := x509.MarshalPKCS8PrivateKey(priv)
 	fatalIfErr(err, "failed to encode certificate key")
 	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")
 
 	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")
 
 	log.Printf("\nCreated a new certificate valid for the following names 📜")