summaryrefslogtreecommitdiffstats
path: root/client
diff options
context:
space:
mode:
authorMartin Polden <mpolden@mpolden.no>2022-03-06 16:34:04 +0100
committerMartin Polden <mpolden@mpolden.no>2022-03-06 16:34:04 +0100
commit37463cf408c22f5306a7107f38f09b36da49ec96 (patch)
tree735aa56554fe780acecb5b0f3bcf9155adbdfa47 /client
parent761e2bfdcdeb7a3647b54000d147c15bf03736ee (diff)
Add more context to private key decoding errors
Diffstat (limited to 'client')
-rw-r--r--client/go/vespa/crypto.go8
1 files changed, 6 insertions, 2 deletions
diff --git a/client/go/vespa/crypto.go b/client/go/vespa/crypto.go
index 25d3a937f4b..6f07df47b33 100644
--- a/client/go/vespa/crypto.go
+++ b/client/go/vespa/crypto.go
@@ -160,11 +160,15 @@ func ECPrivateKeyFrom(pemPrivateKey []byte) (*ecdsa.PrivateKey, error) {
return nil, fmt.Errorf("invalid pem private key")
}
if privateKeyBlock.Type == "EC PRIVATE KEY" {
- return x509.ParseECPrivateKey(privateKeyBlock.Bytes) // Raw EC private key
+ privateKey, err := x509.ParseECPrivateKey(privateKeyBlock.Bytes) // Raw EC private key
+ if err != nil {
+ return nil, fmt.Errorf("invalid raw ec private key: %w", err)
+ }
+ return privateKey, nil
}
privateKey, err := x509.ParsePKCS8PrivateKey(privateKeyBlock.Bytes) // Try PKCS8 format
if err != nil {
- return nil, err
+ return nil, fmt.Errorf("invalid pkcs8 private key: %w", err)
}
ecKey, ok := privateKey.(*ecdsa.PrivateKey)
if !ok {