Skip to content

Commit 700eec6

Browse files
committed
Merge branch 'master' of https://github.com/iterative/terraform-provider-iterative into hotfix/nvidia-reboot
2 parents 65dbfa4 + 6eaff43 commit 700eec6

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

iterative/utils/ssh.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"crypto/rsa"
66
"crypto/x509"
77
"encoding/pem"
8+
"fmt"
89
"strings"
910
"time"
1011

@@ -27,7 +28,11 @@ func PrivatePEM() (string, error) {
2728
}
2829

2930
func PublicFromPrivatePEM(privateKey string) (string, error) {
30-
block, _ := pem.Decode([]byte(privateKey))
31+
block, rest := pem.Decode([]byte(privateKey))
32+
if block == nil {
33+
return "", fmt.Errorf("Invalid PEM on the SSH private key: %#v", rest)
34+
}
35+
3136
key, err := x509.ParsePKCS1PrivateKey(block.Bytes)
3237
if err != nil {
3338
return "", err

0 commit comments

Comments
 (0)