Skip to content

Commit 0096b36

Browse files
feat: support other ssh keys other than ed25519 for git (#1032) (#1033)
(cherry picked from commit 78779f5) Co-authored-by: Tanmoy Sarkar <57363826+tanmoysrt@users.noreply.github.com>
1 parent 2e2f32d commit 0096b36

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

swiftwave_service/graphql/graphql_object_mapper.go

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ func gitCredentialInputToDatabaseObject(record *model.GitCredentialInput, create
5656
sshPrivateKey = string(privateKeyPem) + "\n"
5757
publicKey, err := ssh.NewPublicKey(pub)
5858
if err == nil {
59-
sshPublicKey = "ssh-ed25519" + " " + base64.StdEncoding.EncodeToString(publicKey.Marshal()) + " swiftwave"
59+
sshPublicKey = "ssh-ed25519 " + base64.StdEncoding.EncodeToString(publicKey.Marshal()) + " swiftwave"
6060
}
6161
}
6262
}
@@ -68,8 +68,13 @@ func gitCredentialInputToDatabaseObject(record *model.GitCredentialInput, create
6868
}
6969
p, err := ssh.ParsePrivateKey([]byte(sshPrivateKey))
7070
if err == nil {
71-
if p.PublicKey().Type() == ssh.KeyAlgoED25519 {
72-
sshPublicKey = "ssh-ed25519" + " " + base64.StdEncoding.EncodeToString(p.PublicKey().Marshal()) + " swiftwave"
71+
if p.PublicKey().Type() == ssh.KeyAlgoRSA ||
72+
p.PublicKey().Type() == ssh.KeyAlgoDSA ||
73+
p.PublicKey().Type() == ssh.KeyAlgoECDSA256 || p.PublicKey().Type() == ssh.KeyAlgoECDSA384 || p.PublicKey().Type() == ssh.KeyAlgoECDSA521 ||
74+
p.PublicKey().Type() == ssh.KeyAlgoSKECDSA256 ||
75+
p.PublicKey().Type() == ssh.KeyAlgoED25519 ||
76+
p.PublicKey().Type() == ssh.KeyAlgoSKED25519 {
77+
sshPublicKey = p.PublicKey().Type() + " " + base64.StdEncoding.EncodeToString(p.PublicKey().Marshal()) + " swiftwave"
7378
}
7479
}
7580
}

0 commit comments

Comments
 (0)