]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
libssh2: provide error message when setting host key type fails
authorDaniel Stenberg <daniel@haxx.se>
Fri, 2 Jun 2023 16:08:23 +0000 (18:08 +0200)
committerDaniel Stenberg <daniel@haxx.se>
Fri, 2 Jun 2023 21:00:27 +0000 (23:00 +0200)
Ref: https://curl.se/mail/archive-2023-06/0001.html

Closes #11240

lib/vssh/libssh2.c

index 0b11fde63cac6fdd3a0ff1f0cd8f5aa587f1fb06..98fce5177f2eeb1f88367f2e7000420a1d03b97e 100644 (file)
@@ -889,6 +889,7 @@ static CURLcode ssh_force_knownhost_key_type(struct Curl_easy *data)
     }
 
     if(found) {
+      int rc;
       infof(data, "Found host %s in %s",
             conn->host.name, data->set.str[STRING_SSH_KNOWNHOSTS]);
 
@@ -938,9 +939,15 @@ static CURLcode ssh_force_knownhost_key_type(struct Curl_easy *data)
       }
 
       infof(data, "Set \"%s\" as SSH hostkey type", hostkey_method);
-      result = libssh2_session_error_to_CURLE(
-        libssh2_session_method_pref(
-          sshc->ssh_session, LIBSSH2_METHOD_HOSTKEY, hostkey_method));
+      rc = libssh2_session_method_pref(sshc->ssh_session,
+                                       LIBSSH2_METHOD_HOSTKEY, hostkey_method);
+      if(rc) {
+        char *errmsg = NULL;
+        int errlen;
+        libssh2_session_last_error(sshc->ssh_session, &errmsg, &errlen, 0);
+        failf(data, "libssh2: %s", errmsg);
+        result = libssh2_session_error_to_CURLE(rc);
+      }
     }
     else {
       infof(data, "Did not find host %s in %s",