libssh2: show crypto backend in the verbose connect log

With libssh2 1.11.0 or newer.

Different crypto backends may offer different features, e.g. in the keys
and algos they support.

Examples:
```
*   Trying 127.0.0.1:22...
* Connected to localhost (127.0.0.1) port 22
* libssh2 crypto backend: openssl compatible
[or]
* libssh2 crypto backend: WinCNG
```

Also fix indentation and drop redundant curly braces.

Closes #16790
This commit is contained in:
Viktor Szakats 2025-03-22 00:47:07 +01:00
parent b4dc529fc4
commit 1dd361cde8
No known key found for this signature in database
GPG key ID: B5ABD165E2AEF201

View file

@ -2030,13 +2030,13 @@ static CURLcode ssh_statemachine(struct Curl_easy *data, bool *block)
break;
}
/* This is the last step in the SFTP connect phase. Do note that while
we get the homedir here, we get the "workingpath" in the DO action
since the homedir will remain the same between request but the
working path will not. */
DEBUGF(infof(data, "SSH CONNECT phase done"));
state(data, SSH_STOP);
break;
/* This is the last step in the SFTP connect phase. Do note that while
we get the homedir here, we get the "workingpath" in the DO action
since the homedir will remain the same between request but the
working path will not. */
DEBUGF(infof(data, "SSH CONNECT phase done"));
state(data, SSH_STOP);
break;
case SSH_SFTP_QUOTE_INIT:
@ -2299,7 +2299,6 @@ static CURLcode ssh_statemachine(struct Curl_easy *data, bool *block)
}
case SSH_SFTP_GETINFO:
{
if(data->set.get_filetime) {
state(data, SSH_SFTP_FILETIME);
}
@ -2307,7 +2306,6 @@ static CURLcode ssh_statemachine(struct Curl_easy *data, bool *block)
state(data, SSH_SFTP_TRANS_INIT);
}
break;
}
case SSH_SFTP_FILETIME:
{
@ -3110,6 +3108,34 @@ static CURLcode ssh_connect(struct Curl_easy *data, bool *done)
CURLcode result;
struct connectdata *conn = data->conn;
#if LIBSSH2_VERSION_NUM >= 0x010b00
{
const char *crypto_str;
switch(libssh2_crypto_engine()) {
case libssh2_gcrypt:
crypto_str = "libgcrypt";
break;
case libssh2_mbedtls:
crypto_str = "mbedTLS";
break;
case libssh2_openssl:
crypto_str = "openssl compatible";
break;
case libssh2_os400qc3:
crypto_str = "OS400QC3";
break;
case libssh2_wincng:
crypto_str = "WinCNG";
break;
default:
crypto_str = NULL;
break;
}
if(crypto_str)
infof(data, "libssh2 cryptography backend: %s", crypto_str);
}
#endif
/* initialize per-handle data if not already */
if(!data->req.p.ssh) {
result = ssh_setup_connection(data, conn);