Skip to content

Commit b4cbb99

Browse files
Merge pull request #25 from misha-ssh/fix-fule-privatekey
fix: add new verify on private key ssh
2 parents cd7c9a5 + 0f27727 commit b4cbb99

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

internal/store/private_key.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,12 @@ import (
55
"crypto/x509"
66
"encoding/pem"
77
"errors"
8+
"reflect"
9+
810
"github.com/misha-ssh/kernel/internal/logger"
911
"github.com/misha-ssh/kernel/internal/storage"
1012
"github.com/misha-ssh/kernel/pkg/connect"
11-
"reflect"
13+
"golang.org/x/crypto/ssh"
1214
)
1315

1416
var (
@@ -26,6 +28,10 @@ func validatePrivateKey(privateKey string) error {
2628
return ErrNotValidPrivateKey
2729
}
2830

31+
if _, err := ssh.ParseRawPrivateKey([]byte(privateKey)); err == nil {
32+
return nil
33+
}
34+
2935
_, err := x509.ParsePKCS1PrivateKey(block.Bytes)
3036
if err != nil {
3137
key, err := x509.ParsePKCS8PrivateKey(block.Bytes)

0 commit comments

Comments
 (0)