Merge pull request #284 from amnezia-vpn/bugfix/sshclient_fix

Fix issue with SSH keys support
This commit is contained in:
pokamest 2023-08-13 03:51:58 -07:00 committed by GitHub
commit 2f897c9c98
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -352,16 +352,18 @@ namespace libssh {
m_passphraseCallback = passphraseCallback;
authResult = ssh_pki_import_privkey_base64(credentials.password.toStdString().c_str(), nullptr, callback, nullptr, &privateKey);
if (authResult == SSH_OK) {
char* key = new char[65535];
char *b64 = nullptr;
authResult = ssh_pki_export_privkey_base64(privateKey, nullptr, nullptr, nullptr, &key);
decryptedPrivateKey = key;
delete[] key;
authResult = ssh_pki_export_privkey_base64(privateKey, nullptr, nullptr, nullptr, &b64);
decryptedPrivateKey = QString(b64);
if (authResult != SSH_OK) {
qDebug() << "failed to export private key";
errorCode = ErrorCode::InternalError;
}
else {
ssh_string_free_char(b64);
}
} else {
errorCode = ErrorCode::SshPrivateKeyError;
}