removed setPassphraseCallback() function from ServerController and libssh::Client
This commit is contained in:
parent
a005ed2a84
commit
f8ef69b88a
5 changed files with 12 additions and 23 deletions
|
@ -735,13 +735,8 @@ ErrorCode ServerController::getAlreadyInstalledContainers(const ServerCredential
|
||||||
return ErrorCode::NoError;
|
return ErrorCode::NoError;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ServerController::setPassphraseCallback(const std::function<QString()> &callback)
|
ErrorCode ServerController::getDecryptedPrivateKey(const ServerCredentials &credentials, QString &decryptedPrivateKey, const std::function<QString()> &callback)
|
||||||
{
|
{
|
||||||
m_sshClient.setPassphraseCallback(callback);
|
auto error = m_sshClient.getDecryptedPrivateKey(credentials, decryptedPrivateKey, callback);
|
||||||
}
|
|
||||||
|
|
||||||
ErrorCode ServerController::getDecryptedPrivateKey(const ServerCredentials &credentials, QString &decryptedPrivateKey)
|
|
||||||
{
|
|
||||||
auto error = m_sshClient.getDecryptedPrivateKey(credentials, decryptedPrivateKey);
|
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,8 +55,7 @@ public:
|
||||||
|
|
||||||
void setCancelInstallation(const bool cancel);
|
void setCancelInstallation(const bool cancel);
|
||||||
|
|
||||||
void setPassphraseCallback(const std::function<QString()> &callback);
|
ErrorCode getDecryptedPrivateKey(const ServerCredentials &credentials, QString &decryptedPrivateKey, const std::function<QString()> &callback);
|
||||||
ErrorCode getDecryptedPrivateKey(const ServerCredentials &credentials, QString &decryptedPrivateKey);
|
|
||||||
private:
|
private:
|
||||||
ErrorCode installDockerWorker(const ServerCredentials &credentials, DockerContainer container);
|
ErrorCode installDockerWorker(const ServerCredentials &credentials, DockerContainer container);
|
||||||
ErrorCode prepareHostWorker(const ServerCredentials &credentials, DockerContainer container, const QJsonObject &config = QJsonObject());
|
ErrorCode prepareHostWorker(const ServerCredentials &credentials, DockerContainer container, const QJsonObject &config = QJsonObject());
|
||||||
|
|
|
@ -338,12 +338,13 @@ namespace libssh {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ErrorCode Client::getDecryptedPrivateKey(const ServerCredentials &credentials, QString &decryptedPrivateKey)
|
ErrorCode Client::getDecryptedPrivateKey(const ServerCredentials &credentials, QString &decryptedPrivateKey, const std::function<QString()> &passphraseCallback)
|
||||||
{
|
{
|
||||||
int authResult = SSH_ERROR;
|
int authResult = SSH_ERROR;
|
||||||
ErrorCode errorCode = ErrorCode::NoError;
|
ErrorCode errorCode = ErrorCode::NoError;
|
||||||
|
|
||||||
ssh_key privateKey;
|
ssh_key privateKey;
|
||||||
|
m_passphraseCallback = passphraseCallback;
|
||||||
authResult = ssh_pki_import_privkey_base64(credentials.password.toStdString().c_str(), nullptr, callback, nullptr, &privateKey);
|
authResult = ssh_pki_import_privkey_base64(credentials.password.toStdString().c_str(), nullptr, callback, nullptr, &privateKey);
|
||||||
if (authResult == SSH_OK) {
|
if (authResult == SSH_OK) {
|
||||||
char* key = new char[65535];
|
char* key = new char[65535];
|
||||||
|
@ -363,9 +364,4 @@ namespace libssh {
|
||||||
ssh_key_free(privateKey);
|
ssh_key_free(privateKey);
|
||||||
return errorCode;
|
return errorCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Client::setPassphraseCallback(const std::function<QString()> &callback)
|
|
||||||
{
|
|
||||||
m_passphraseCallback = callback;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,8 +36,7 @@ namespace libssh {
|
||||||
const std::string& localPath,
|
const std::string& localPath,
|
||||||
const std::string& remotePath,
|
const std::string& remotePath,
|
||||||
const std::string& fileDesc);
|
const std::string& fileDesc);
|
||||||
ErrorCode getDecryptedPrivateKey(const ServerCredentials &credentials, QString &decryptedPrivateKey);
|
ErrorCode getDecryptedPrivateKey(const ServerCredentials &credentials, QString &decryptedPrivateKey, const std::function<QString()> &passphraseCallback);
|
||||||
void setPassphraseCallback(const std::function<QString()> &callback);
|
|
||||||
private:
|
private:
|
||||||
ErrorCode closeChannel();
|
ErrorCode closeChannel();
|
||||||
ErrorCode closeSftpSession();
|
ErrorCode closeSftpSession();
|
||||||
|
|
|
@ -143,19 +143,19 @@ void StartPageLogic::onPushButtonConnect()
|
||||||
|
|
||||||
return m_privateKeyPassphrase;
|
return m_privateKeyPassphrase;
|
||||||
};
|
};
|
||||||
serverController.setPassphraseCallback(passphraseCallback);
|
|
||||||
}
|
|
||||||
|
|
||||||
QString output = serverController.checkSshConnection(serverCredentials, &errorCode);
|
|
||||||
|
|
||||||
if (pushButtonConnectKeyChecked()) {
|
|
||||||
QString decryptedPrivateKey;
|
QString decryptedPrivateKey;
|
||||||
errorCode = serverController.getDecryptedPrivateKey(serverCredentials, decryptedPrivateKey);
|
errorCode = serverController.getDecryptedPrivateKey(serverCredentials, decryptedPrivateKey, passphraseCallback);
|
||||||
if (errorCode == ErrorCode::NoError) {
|
if (errorCode == ErrorCode::NoError) {
|
||||||
serverCredentials.password = decryptedPrivateKey;
|
serverCredentials.password = decryptedPrivateKey;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString output;
|
||||||
|
if (errorCode == ErrorCode::NoError) {
|
||||||
|
output = serverController.checkSshConnection(serverCredentials, &errorCode);
|
||||||
|
}
|
||||||
|
|
||||||
bool ok = true;
|
bool ok = true;
|
||||||
if (errorCode) {
|
if (errorCode) {
|
||||||
set_labelWaitInfoVisible(true);
|
set_labelWaitInfoVisible(true);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue