I have a Go code to generate an ECDSA key and write it to a file:
priv, err := ecdsa.GenerateKey(elliptic.P256(), rand.Reader) ecder, err := x509.MarshalECPrivateKey(priv) keypem, err := os.OpenFile("ec-key.pem", os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0600) pem.Encode(keypem, &pem.Block{Type: "EC PRIVATE KEY", Bytes: ecder})
This works and generates a BEGIN EC PRIVATE KEY block. But when you write the key in openssl, you also get the "BEGIN EC PARAMETERS" block that defines the curve used. Is there a way to write EU PARAMETERS to a pem file in Go?
Aaron source share