NewCredentialSSHKeyFromSigner creates new SSH credentials using the provided signer.
(username string, signer ssh.Signer)
| 264 | |
| 265 | // NewCredentialSSHKeyFromSigner creates new SSH credentials using the provided signer. |
| 266 | func 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 | |
| 287 | func NewCredentialDefault() (*Credential, error) { |
| 288 | runtime.LockOSThread() |
searching dependent graphs…