简体   繁体   中英

Parsing DSA key with golang into tls config object

I have a set of a DSA client private key, client- and and a CA certificate files, which I would like to use with the kafka-go library. I have been trying to parse the files but have been unsuccessful. The aformentioned key and certificate files are correct, as they are being used in other places, written in Javascript though. I have been trying to parse them in the following manner:

func NewTLSConfig(clientCertFile, clientKeyFile, caCertFile string) (*tls.Config, error) {
    tlsConfig := tls.Config{}
    cert, err := tls.LoadX509KeyPair(clientCertFile, clientKeyFile
    ...

Where the string inputs are correct file paths. At this point I get the following error:

tls: failed to parse private key

which is coming from the parsePrivateKey function of the tls library. When checking the the function's input, it seems to be fine.

cert.PrivateKey, err = parsePrivateKey(keyDERBlock.Bytes)

The keyDERBlock object is populated, it has a proper type and bytes. What could be the issue? Thank you!

I have created a small Github repo to illustrate the issue.

The issue has been solved by using RSA keys instead of DSA.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM