MCPcopy Create free account
hub / github.com/libgit2/git2go / NewCredentialSSHKeyFromSigner

Function NewCredentialSSHKeyFromSigner

credentials.go:266–285  ·  view source on GitHub ↗

NewCredentialSSHKeyFromSigner creates new SSH credentials using the provided signer.

(username string, signer ssh.Signer)

Source from the content-addressed store, hash-verified

264
265// NewCredentialSSHKeyFromSigner creates new SSH credentials using the provided signer.
266func NewCredentialSSHKeyFromSigner(username string, signer ssh.Signer) (*Credential, error) {
267 publicKey := signer.PublicKey().Marshal()
268
269 ccred := (*C.git_credential_ssh_custom)(C.calloc(1, C.size_t(unsafe.Sizeof(C.git_credential_ssh_custom{}))))
270 ccred.parent.credtype = C.GIT_CREDENTIAL_SSH_CUSTOM
271 ccred.username = C.CString(username)
272 ccred.publickey = (*C.char)(C.CBytes(publicKey))
273 ccred.publickey_len = C.size_t(len(publicKey))
274 C._go_git_populate_credential_ssh_custom(ccred)
275
276 data := credentialSSHCustomData{
277 signer: signer,
278 }
279 ccred.payload = pointerHandles.Track(&data)
280
281 cred := newCredential()
282 cred.ptr = &ccred.parent
283
284 return cred, nil
285}
286
287func NewCredentialDefault() (*Credential, error) {
288 runtime.LockOSThread()

Callers 1

TestRemoteSSHFunction · 0.85

Calls 2

newCredentialFunction · 0.85
TrackMethod · 0.80

Tested by 1

TestRemoteSSHFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…