mirror of
https://github.com/status-im/consul.git
synced 2025-01-10 22:06:20 +00:00
Reuse Connect.parseSigner.Adds change from #8898
Co-authored-by: Aliaksandr Mianzhynski <amenzhinsky@gmail.com>
This commit is contained in:
parent
e9630ea263
commit
3a1bbf93af
@ -4,8 +4,8 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
"crypto"
|
"crypto"
|
||||||
"crypto/ecdsa"
|
"crypto/ecdsa"
|
||||||
"crypto/rsa"
|
|
||||||
"crypto/rand"
|
"crypto/rand"
|
||||||
|
"crypto/rsa"
|
||||||
"crypto/sha256"
|
"crypto/sha256"
|
||||||
"crypto/x509"
|
"crypto/x509"
|
||||||
"crypto/x509/pkix"
|
"crypto/x509/pkix"
|
||||||
@ -179,6 +179,18 @@ func ParseSigner(pemValue string) (crypto.Signer, error) {
|
|||||||
case "RSA PRIVATE KEY":
|
case "RSA PRIVATE KEY":
|
||||||
return x509.ParsePKCS1PrivateKey(block.Bytes)
|
return x509.ParsePKCS1PrivateKey(block.Bytes)
|
||||||
|
|
||||||
|
case "PRIVATE KEY":
|
||||||
|
signer, err := x509.ParsePKCS8PrivateKey(block.Bytes)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
pk, ok := signer.(crypto.Signer)
|
||||||
|
if !ok {
|
||||||
|
return nil, fmt.Errorf("private key is not a valid format")
|
||||||
|
}
|
||||||
|
|
||||||
|
return pk, nil
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return nil, fmt.Errorf("unknown PEM block type for signing key: %s", block.Type)
|
return nil, fmt.Errorf("unknown PEM block type for signing key: %s", block.Type)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user