NewCredentialSSHKey creates new ssh credentials reading the public and private keys from the file system.
(username string, publicKeyPath string, privateKeyPath string, passphrase string)
| 169 | // NewCredentialSSHKey creates new ssh credentials reading the public and private keys |
| 170 | // from the file system. |
| 171 | func NewCredentialSSHKey(username string, publicKeyPath string, privateKeyPath string, passphrase string) (*Credential, error) { |
| 172 | runtime.LockOSThread() |
| 173 | defer runtime.UnlockOSThread() |
| 174 | |
| 175 | cred := newCredential() |
| 176 | cusername := C.CString(username) |
| 177 | defer C.free(unsafe.Pointer(cusername)) |
| 178 | cpublickey := C.CString(publicKeyPath) |
| 179 | defer C.free(unsafe.Pointer(cpublickey)) |
| 180 | cprivatekey := C.CString(privateKeyPath) |
| 181 | defer C.free(unsafe.Pointer(cprivatekey)) |
| 182 | cpassphrase := C.CString(passphrase) |
| 183 | defer C.free(unsafe.Pointer(cpassphrase)) |
| 184 | ret := C.git_credential_ssh_key_new(&cred.ptr, cusername, cpublickey, cprivatekey, cpassphrase) |
| 185 | if ret != 0 { |
| 186 | cred.Free() |
| 187 | return nil, MakeGitError(ret) |
| 188 | } |
| 189 | return cred, nil |
| 190 | } |
| 191 | |
| 192 | // NewCredentialSSHKeyFromMemory creates new ssh credentials using the publicKey and privateKey |
| 193 | // arguments as the values for the public and private keys. |
no test coverage detected
searching dependent graphs…