Skip to content

Commit 5508a24

Browse files
bkneispascalbreuninger
authored andcommitted
Base 64 encode and decode signing key
1 parent 5b60aa5 commit 5508a24

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

cmd/agent/container/credentials_server.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package container
33
import (
44
"bytes"
55
"context"
6+
"encoding/base64"
67
"encoding/json"
78
"fmt"
89
"net"
@@ -147,7 +148,11 @@ func (cmd *CredentialsServerCmd) Run(ctx context.Context, port int, runnerPort i
147148

148149
// configure git ssh signature helper
149150
if cmd.GitUserSigningKey != "" {
150-
err = gitsshsigning.ConfigureHelper(cmd.User, cmd.GitUserSigningKey, log)
151+
decodedKey, err := base64.StdEncoding.DecodeString(cmd.GitUserSigningKey)
152+
if err != nil {
153+
return fmt.Errorf("decode git ssh signature key: %w", err)
154+
}
155+
err = gitsshsigning.ConfigureHelper(cmd.User, string(decodedKey), log)
151156
if err != nil {
152157
return fmt.Errorf("configure git ssh signature helper: %w", err)
153158
}

pkg/tunnel/services.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package tunnel
33
import (
44
"bytes"
55
"context"
6+
"encoding/base64"
67
"encoding/json"
78
"fmt"
89
"math"
@@ -121,7 +122,8 @@ func RunInContainer(
121122
if configureGitSSHSignatureHelper {
122123
format, userSigningKey, err := gitsshsigning.ExtractGitConfiguration()
123124
if err == nil && format == gitsshsigning.GPGFormatSSH && userSigningKey != "" {
124-
command += fmt.Sprintf(" --git-user-signing-key %s", userSigningKey)
125+
encodedKey := base64.StdEncoding.EncodeToString([]byte(userSigningKey))
126+
command += fmt.Sprintf(" --git-user-signing-key %s", encodedKey)
125127
}
126128
}
127129
if configureDockerCredentials {

0 commit comments

Comments
 (0)