Skip to content

Commit 3548f84

Browse files
Merge pull request #94 from fosrl/dev
Remove cert validation check
2 parents c1b5b11 + 8872706 commit 3548f84

1 file changed

Lines changed: 0 additions & 41 deletions

File tree

cmd/ssh/jit.go

Lines changed: 0 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
11
package ssh
22

33
import (
4-
"bytes"
54
"fmt"
6-
"strings"
75
"time"
86

97
"github.com/fosrl/cli/internal/api"
108
"github.com/fosrl/cli/internal/sshkeys"
11-
"golang.org/x/crypto/ssh"
129
)
1310

1411
const (
@@ -17,34 +14,6 @@ const (
1714
pollBackoffSteps = 6
1815
)
1916

20-
func validateSignedCert(pubKey, cert string) error {
21-
cert = strings.TrimSpace(cert)
22-
if cert == "" {
23-
return fmt.Errorf("API returned an empty SSH certificate")
24-
}
25-
26-
pubParsed, _, _, _, err := ssh.ParseAuthorizedKey([]byte(pubKey))
27-
if err != nil {
28-
return fmt.Errorf("parse generated public key: %w", err)
29-
}
30-
31-
certParsed, _, _, _, err := ssh.ParseAuthorizedKey([]byte(cert))
32-
if err != nil {
33-
return fmt.Errorf("parse returned certificate: %w", err)
34-
}
35-
36-
certKey, ok := certParsed.(*ssh.Certificate)
37-
if !ok {
38-
return fmt.Errorf("API returned %q instead of an SSH certificate", certParsed.Type())
39-
}
40-
41-
if !bytes.Equal(certKey.Key.Marshal(), pubParsed.Marshal()) {
42-
return fmt.Errorf("returned certificate does not match generated key")
43-
}
44-
45-
return nil
46-
}
47-
4817
// GenerateAndSignKey generates an Ed25519 key pair and signs the public key via the API.
4918
func GenerateAndSignKey(client *api.Client, orgID string, resourceID string, username string) (privPEM, pubKey, cert string, signData *api.SignSSHKeyData, err error) {
5019
privPEM, pubKey, err = sshkeys.GenerateKeyPair()
@@ -68,11 +37,6 @@ func GenerateAndSignKey(client *api.Client, orgID string, resourceID string, use
6837
} else if initResp.MessageID != 0 {
6938
messageIDs = []int64{initResp.MessageID}
7039
} else {
71-
if initResp.AuthDaemonMode != "native" {
72-
if err := validateSignedCert(pubKey, initResp.Certificate); err != nil {
73-
return "", "", "", nil, fmt.Errorf("SSH error: invalid certificate: %w", err)
74-
}
75-
}
7640
// return the data as this is okay
7741
return privPEM, pubKey, initResp.Certificate, initResp, nil
7842
}
@@ -90,11 +54,6 @@ func GenerateAndSignKey(client *api.Client, orgID string, resourceID string, use
9054
if msg.Error != nil && *msg.Error != "" {
9155
return "", "", "", nil, fmt.Errorf("SSH error: %s", *msg.Error)
9256
}
93-
if initResp.AuthDaemonMode != "native" {
94-
if err := validateSignedCert(pubKey, initResp.Certificate); err != nil {
95-
return "", "", "", nil, fmt.Errorf("SSH error: invalid certificate: %w", err)
96-
}
97-
}
9857
return privPEM, pubKey, initResp.Certificate, initResp, nil
9958
}
10059
}

0 commit comments

Comments
 (0)