Help us shape the future of Go! Take the 2026 Go Developer Survey

gitsshsigning

package
v1.25.0-beta.8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 30, 2026 License: MPL-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	GPGFormatConfigKey       = "gpg.format"
	UsersSigningKeyConfigKey = "user.signingkey"
	GPGFormatSSH             = "ssh"
)
View Source
const (
	HelperScript = `#!/bin/bash

devsy internal agent git-ssh-signature "$@"
`
)

Variables

View Source
var (
	GitConfigTemplate = `
[gpg "ssh"]
	program = ` + pkgconfig.SSHSignatureHelperName + `
[gpg]
	format = ssh
[user]
	signingkey = %s
`
)

Functions

func ConfigureHelper

func ConfigureHelper(userName, gitSigningKey string) error

ConfigureHelper sets up the Git SSH signing helper script and updates the Git configuration for the specified user.

This function: - sets user.signingkey git config - creates a wrapper script for calling git-ssh-signature - users this script as gpg.ssh.program This is needed since git expects `gpg.ssh.program` to be an executable.

func ExpandSigningKeyPath

func ExpandSigningKeyPath(signingKey string) string

ExpandSigningKeyPath expands a leading ~ or ~user prefix in an SSH signing key path.

func ExtractGitConfiguration

func ExtractGitConfiguration(ctx context.Context, workingDir string) (string, string, error)

ExtractGitConfiguration reads gpg.format and user.signingkey from git config at workingDir.

func HandleGitSSHProgramCall

func HandleGitSSHProgramCall(certPath, namespace, bufferFile string) error

HandleGitSSHProgramCall implements logic handling call from git when signing a commit.

func IsLiteralSSHKey

func IsLiteralSSHKey(signingKey string) bool

IsLiteralSSHKey reports whether signingKey is an inline SSH public key rather than a file path.

func RemoveHelper

func RemoveHelper(userName string) error

RemoveHelper removes the git SSH signing helper script and any related configuration.

func ResolveSigningKey

func ResolveSigningKey(signingKey, workingDir string) string

ResolveSigningKey expands ~ prefixes and resolves relative SSH key paths against workingDir.

func SetSignatureServerURL

func SetSignatureServerURL(url string)

SetSignatureServerURL sets the server URL override for testing.

Types

type GitSSHSignatureRequest

type GitSSHSignatureRequest struct {
	Content   string
	KeyPath   string
	PublicKey string // Public key content; when set, written to a temp file for ssh-keygen.
	Namespace string `json:",omitempty"`
}

GitSSHSignatureRequest describes an SSH signature request forwarded from a workspace container.

func (*GitSSHSignatureRequest) SignWithHostKey

func (req *GitSSHSignatureRequest) SignWithHostKey(
	ctx context.Context,
	hostSigningKey string,
) (*GitSSHSignatureResponse, error)

SignWithHostKey signs the content, preferring a matching host signing key file when available.

type GitSSHSignatureResponse

type GitSSHSignatureResponse struct {
	Signature []byte
}

GitSSHSignatureResponse holds the raw SSH signature produced by ssh-keygen.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL