mirror of
https://github.com/moparisthebest/curl
synced 2025-02-28 09:21:50 -05:00
SSH: public key can now be an empty string
If an empty string is passed to CURLOPT_SSH_PUBLIC_KEYFILE, libcurl will pass no public key to libssh2 which then tries to compute it from the private key. This is known to work when libssh2 1.4.0+ is linked against OpenSSL.
This commit is contained in:
parent
ebf315e6f3
commit
05a443adf2
@ -2380,6 +2380,9 @@ Pass a char * pointing to a file name for your public key. If not used,
|
|||||||
libcurl defaults to \fB$HOME/.ssh/id_dsa.pub\fP if the HOME environment
|
libcurl defaults to \fB$HOME/.ssh/id_dsa.pub\fP if the HOME environment
|
||||||
variable is set, and just "id_dsa.pub" in the current directory if HOME is not
|
variable is set, and just "id_dsa.pub" in the current directory if HOME is not
|
||||||
set. (Added in 7.16.1)
|
set. (Added in 7.16.1)
|
||||||
|
If an empty string is passed, libcurl will pass no public key to libssh2
|
||||||
|
which then tries to compute it from the private key, this is known to work
|
||||||
|
when libssh2 1.4.0+ is linked against OpenSSL. (Added in 7.25.1)
|
||||||
.IP CURLOPT_SSH_PRIVATE_KEYFILE
|
.IP CURLOPT_SSH_PRIVATE_KEYFILE
|
||||||
Pass a char * pointing to a file name for your private key. If not used,
|
Pass a char * pointing to a file name for your private key. If not used,
|
||||||
libcurl defaults to \fB$HOME/.ssh/id_dsa\fP if the HOME environment variable
|
libcurl defaults to \fB$HOME/.ssh/id_dsa\fP if the HOME environment variable
|
||||||
|
@ -770,6 +770,7 @@ static CURLcode ssh_statemach_act(struct connectdata *conn, bool *block)
|
|||||||
if((data->set.ssh_auth_types & CURLSSH_AUTH_PUBLICKEY) &&
|
if((data->set.ssh_auth_types & CURLSSH_AUTH_PUBLICKEY) &&
|
||||||
(strstr(sshc->authlist, "publickey") != NULL)) {
|
(strstr(sshc->authlist, "publickey") != NULL)) {
|
||||||
char *home = NULL;
|
char *home = NULL;
|
||||||
|
bool rsa_pub_empty_but_ok = FALSE;
|
||||||
|
|
||||||
sshc->rsa_pub = sshc->rsa = NULL;
|
sshc->rsa_pub = sshc->rsa = NULL;
|
||||||
|
|
||||||
@ -777,7 +778,10 @@ static CURLcode ssh_statemach_act(struct connectdata *conn, bool *block)
|
|||||||
HOME environment variable etc? */
|
HOME environment variable etc? */
|
||||||
home = curl_getenv("HOME");
|
home = curl_getenv("HOME");
|
||||||
|
|
||||||
if(data->set.str[STRING_SSH_PUBLIC_KEY])
|
if(data->set.str[STRING_SSH_PUBLIC_KEY] &&
|
||||||
|
!*data->set.str[STRING_SSH_PUBLIC_KEY])
|
||||||
|
rsa_pub_empty_but_ok = true;
|
||||||
|
else if(data->set.str[STRING_SSH_PUBLIC_KEY])
|
||||||
sshc->rsa_pub = aprintf("%s", data->set.str[STRING_SSH_PUBLIC_KEY]);
|
sshc->rsa_pub = aprintf("%s", data->set.str[STRING_SSH_PUBLIC_KEY]);
|
||||||
else if(home)
|
else if(home)
|
||||||
sshc->rsa_pub = aprintf("%s/.ssh/id_dsa.pub", home);
|
sshc->rsa_pub = aprintf("%s/.ssh/id_dsa.pub", home);
|
||||||
@ -785,7 +789,7 @@ static CURLcode ssh_statemach_act(struct connectdata *conn, bool *block)
|
|||||||
/* as a final resort, try current dir! */
|
/* as a final resort, try current dir! */
|
||||||
sshc->rsa_pub = strdup("id_dsa.pub");
|
sshc->rsa_pub = strdup("id_dsa.pub");
|
||||||
|
|
||||||
if(sshc->rsa_pub == NULL) {
|
if(!rsa_pub_empty_but_ok && (sshc->rsa_pub == NULL)) {
|
||||||
Curl_safefree(home);
|
Curl_safefree(home);
|
||||||
state(conn, SSH_SESSION_FREE);
|
state(conn, SSH_SESSION_FREE);
|
||||||
sshc->actualcode = CURLE_OUT_OF_MEMORY;
|
sshc->actualcode = CURLE_OUT_OF_MEMORY;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user