Go: crypto/tls: failed to parse private key

Created on 3 Aug 2018  路  3Comments  路  Source: golang/go

Please answer these questions before submitting your issue. Thanks!

What version of Go are you using (go version)?

go1.10.3

Does this issue reproduce with the latest release?

considering this is the present release, yes.

What operating system and processor architecture are you using (go env)?

GOARCH="amd64"
GOOS="windows"
windows7

What did you do?

I use the following command to create two files.
openssl req -x509 -sha256 -nodes -newkey ec:<(openssl ecparam -name secp256k1) -keyout tls1.key -out tls1.crt -days 3650 -subj "/O=Bar/CN=Foo"
I test them with the following code.

package main

import (
    "fmt"
    "crypto/tls"
)

func main() {
    certFile := "e:/evan/goland/src/medichain/key/sdk.crt"
    keyFile := "e:/evan/goland/src/medichain/key/sdk.key"
    cert, err := tls.LoadX509KeyPair(certFile, keyFile)
    if err != nil {
        fmt.Println(err)
        return
    }
    fmt.Println(cert)
}

What did you expect to see?

Well, i hope it would be no error.

What did you see instead?

I got the error 'tls: failed to parse private key'

I need this curve .
Would you do some help?
Any help would be greatly appreciated

FrozenDueToAge NeedsInvestigation

Most helpful comment

Hey, support for that curve still needs to be added before golang's X.509 parser will be able to produce a keypair, as it's not a NIST curve, but a SEC Koblitz curve. I have a proposal which should address this:

https://github.com/golang/go/issues/26776

All 3 comments

CC @FiloSottile

Hey, support for that curve still needs to be added before golang's X.509 parser will be able to produce a keypair, as it's not a NIST curve, but a SEC Koblitz curve. I have a proposal which should address this:

https://github.com/golang/go/issues/26776

@cag This proposal is great.
I wonder if your go fork has this curve supported.

Was this page helpful?
0 / 5 - 0 ratings