summaryrefslogtreecommitdiff
path: root/credentials.go
diff options
context:
space:
mode:
Diffstat (limited to 'credentials.go')
-rw-r--r--credentials.go15
1 files changed, 15 insertions, 0 deletions
diff --git a/credentials.go b/credentials.go
index 273de2f..2fb65d5 100644
--- a/credentials.go
+++ b/credentials.go
@@ -120,6 +120,21 @@ func (o *Credential) GetUserpassPlaintext() (username, password string, err erro
return
}
+// GetSSHKey returns the SSH-specific key information from the Cred object.
+func (o *Credential) GetSSHKey() (username, publickey, privatekey, passphrase string, err error) {
+ if o.Type() != CredentialTypeSSHKey && o.Type() != CredentialTypeSSHMemory {
+ err = fmt.Errorf("credential is not an SSH key: %v", o.Type())
+ return
+ }
+
+ sshKeyCredPtr := (*C.git_cred_ssh_key)(unsafe.Pointer(o.ptr))
+ username = C.GoString(sshKeyCredPtr.username)
+ publickey = C.GoString(sshKeyCredPtr.publickey)
+ privatekey = C.GoString(sshKeyCredPtr.privatekey)
+ passphrase = C.GoString(sshKeyCredPtr.passphrase)
+ return
+}
+
func NewCredentialUsername(username string) (*Credential, error) {
runtime.LockOSThread()
defer runtime.UnlockOSThread()