diff --git a/caddy/https/crypto.go b/caddy/https/crypto.go index bc0ff637..7971bda3 100644 --- a/caddy/https/crypto.go +++ b/caddy/https/crypto.go @@ -18,7 +18,7 @@ func loadPrivateKey(file string) (crypto.PrivateKey, error) { return nil, err } keyBlock, _ := pem.Decode(keyBytes) - + switch keyBlock.Type { case "RSA PRIVATE KEY": return x509.ParsePKCS1PrivateKey(keyBlock.Bytes) @@ -45,7 +45,7 @@ func savePrivateKey(key crypto.PrivateKey, file string) error { pemType = "RSA" keyBytes = x509.MarshalPKCS1PrivateKey(key) } - + pemKey := pem.Block{Type: pemType + " PRIVATE KEY", Bytes: keyBytes} keyOut, err := os.Create(file) if err != nil { diff --git a/caddy/https/crypto_test.go b/caddy/https/crypto_test.go index c1f32b27..07d2af5c 100644 --- a/caddy/https/crypto_test.go +++ b/caddy/https/crypto_test.go @@ -88,9 +88,9 @@ func TestSaveAndLoadECCPrivateKey(t *testing.T) { } // verify loaded key is correct - if !PrivateKeysSame(privateKey, loadedKey) { - t.Error("Expected key bytes to be the same, but they weren't") - } + if !PrivateKeysSame(privateKey, loadedKey) { + t.Error("Expected key bytes to be the same, but they weren't") + } } // PrivateKeysSame compares the bytes of a and b and returns true if they are the same.