-
Notifications
You must be signed in to change notification settings - Fork 398
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support for in-memory SSH keys is missing #320
Comments
I this the corresponding PR was merged 7 days ago. Yet I still get the following error message:
|
@promethe42 can you share snippets for how to reproduce to poke around? |
@alexcrichton here you go: pub fn git_credentials_callback(
_user: &str,
_user_from_url: Option<&str>,
_cred: git2::CredentialType,
) -> Result<git2::Cred, git2::Error> {
let user = _user_from_url.unwrap_or("git");
if _cred.contains(git2::CredentialType::USERNAME) {
return git2::Cred::username(user);
}
match env::var("GPM_SSH_KEY") {
Ok(k) => {
let key_path = path::Path::new(&k);
if key_path.exists() {
debug!("authenticate with user {} and private key located in {}", user, k);
git2::Cred::ssh_key(user, None, key_path, None)
} else {
debug!("authenticate with user {} and private key stored in the GPM_SSH_KEY env var", user);
git2::Cred::ssh_key_from_memory(user, None, &k, None)
}
},
_ => Err(git2::Error::from_str("unable to get private key from GPM_SSH_KEY")),
}
} |
@alexcrichton The issue comes from cfg.define("GIT_SSH_MEMORY_CREDENTIALS", "ON"); |
@alexcrichton here is a PR that makes this feature actually usable: https://github.com/alexcrichton/git2-rs/pull/331 |
@alexcrichton thanks for merging the PR! Any chance we can get a 0.7.4 with this fix anytime soon? |
sure thing, should be done now! |
libgit2
has support for in-memory SSH keys. There is alreadygit2::SSH_MEMORY
to indicate that the credentials type is allowed, but a wrapper forgit_cred_ssh_key_memory_new
is missing.The text was updated successfully, but these errors were encountered: