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

Function NewCredentialSSHKeyFromMemory

credentials.go:194–213  ·  view source on GitHub ↗

NewCredentialSSHKeyFromMemory creates new ssh credentials using the publicKey and privateKey arguments as the values for the public and private keys.

(username string, publicKey string, privateKey string, passphrase string)

Source from the content-addressed store, hash-verified

192// NewCredentialSSHKeyFromMemory creates new ssh credentials using the publicKey and privateKey
193// arguments as the values for the public and private keys.
194func NewCredentialSSHKeyFromMemory(username string, publicKey string, privateKey string, passphrase string) (*Credential, error) {
195 runtime.LockOSThread()
196 defer runtime.UnlockOSThread()
197
198 cred := newCredential()
199 cusername := C.CString(username)
200 defer C.free(unsafe.Pointer(cusername))
201 cpublickey := C.CString(publicKey)
202 defer C.free(unsafe.Pointer(cpublickey))
203 cprivatekey := C.CString(privateKey)
204 defer C.free(unsafe.Pointer(cprivatekey))
205 cpassphrase := C.CString(passphrase)
206 defer C.free(unsafe.Pointer(cpassphrase))
207 ret := C.git_credential_ssh_key_memory_new(&cred.ptr, cusername, cpublickey, cprivatekey, cpassphrase)
208 if ret != 0 {
209 cred.Free()
210 return nil, MakeGitError(ret)
211 }
212 return cred, nil
213}
214
215func NewCredentialSSHKeyFromAgent(username string) (*Credential, error) {
216 runtime.LockOSThread()

Callers 1

NewCredSshKeyFromMemoryFunction · 0.85

Calls 4

newCredentialFunction · 0.85
MakeGitErrorFunction · 0.85
freeMethod · 0.80
FreeMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…