@@ -44,20 +44,38 @@ func NewCredUserpassPlaintext(username string, password string) (int, Cred) {
44
44
return int (ret ), cred
45
45
}
46
46
47
- func NewCredSshKey (username string , publickey string , privatekey string , passphrase string ) (int , Cred ) {
47
+ // NewCredSshKey creates new ssh credentials reading the public and private keys
48
+ // from the file system.
49
+ func NewCredSshKey (username string , publicKeyPath string , privateKeyPath string , passphrase string ) (int , Cred ) {
48
50
cred := Cred {}
49
51
cusername := C .CString (username )
50
52
defer C .free (unsafe .Pointer (cusername ))
51
- cpublickey := C .CString (publickey )
53
+ cpublickey := C .CString (publicKeyPath )
52
54
defer C .free (unsafe .Pointer (cpublickey ))
53
- cprivatekey := C .CString (privatekey )
55
+ cprivatekey := C .CString (privateKeyPath )
54
56
defer C .free (unsafe .Pointer (cprivatekey ))
55
57
cpassphrase := C .CString (passphrase )
56
58
defer C .free (unsafe .Pointer (cpassphrase ))
57
59
ret := C .git_cred_ssh_key_new (& cred .ptr , cusername , cpublickey , cprivatekey , cpassphrase )
58
60
return int (ret ), cred
59
61
}
60
62
63
+ // NewCredSshKeyFromMemory creates new ssh credentials using the publicKey and privateKey
64
+ // arguments as the values for the public and private keys.
65
+ func NewCredSshKeyFromMemory (username string , publicKey string , privateKey string , passphrase string ) (int , Cred ) {
66
+ cred := Cred {}
67
+ cusername := C .CString (username )
68
+ defer C .free (unsafe .Pointer (cusername ))
69
+ cpublickey := C .CString (publicKey )
70
+ defer C .free (unsafe .Pointer (cpublickey ))
71
+ cprivatekey := C .CString (privateKey )
72
+ defer C .free (unsafe .Pointer (cprivatekey ))
73
+ cpassphrase := C .CString (passphrase )
74
+ defer C .free (unsafe .Pointer (cpassphrase ))
75
+ ret := C .git_cred_ssh_key_memory_new (& cred .ptr , cusername , cpublickey , cprivatekey , cpassphrase )
76
+ return int (ret ), cred
77
+ }
78
+
61
79
func NewCredSshKeyFromAgent (username string ) (int , Cred ) {
62
80
cred := Cred {}
63
81
cusername := C .CString (username )
0 commit comments