added processing of private ssh keys
This commit is contained in:
parent
925fd9f268
commit
ebcca0c3b8
10 changed files with 137 additions and 8 deletions
|
|
@ -1,6 +1,7 @@
|
|||
#include "installController.h"
|
||||
|
||||
#include <QDesktopServices>
|
||||
#include <QEventLoop>
|
||||
#include <QJsonObject>
|
||||
#include <QStandardPaths>
|
||||
|
||||
|
|
@ -396,8 +397,31 @@ void InstallController::mountSftpDrive(const QString &port, const QString &passw
|
|||
bool InstallController::checkSshConnection()
|
||||
{
|
||||
ServerController serverController(m_settings);
|
||||
|
||||
ErrorCode errorCode = ErrorCode::NoError;
|
||||
m_privateKeyPassphrase = "";
|
||||
|
||||
if (m_currentlyInstalledServerCredentials.secretData.contains("BEGIN")
|
||||
&& m_currentlyInstalledServerCredentials.secretData.contains("PRIVATE KEY")) {
|
||||
auto passphraseCallback = [this]() {
|
||||
emit passphraseRequestStarted();
|
||||
QEventLoop loop;
|
||||
QObject::connect(this, &InstallController::passphraseRequestFinished, &loop, &QEventLoop::quit);
|
||||
loop.exec();
|
||||
|
||||
return m_privateKeyPassphrase;
|
||||
};
|
||||
|
||||
QString decryptedPrivateKey;
|
||||
errorCode = serverController.getDecryptedPrivateKey(m_currentlyInstalledServerCredentials, decryptedPrivateKey,
|
||||
passphraseCallback);
|
||||
if (errorCode == ErrorCode::NoError) {
|
||||
m_currentlyInstalledServerCredentials.secretData = decryptedPrivateKey;
|
||||
} else {
|
||||
emit installationErrorOccurred(errorString(errorCode));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
QString output;
|
||||
output = serverController.checkSshConnection(m_currentlyInstalledServerCredentials, &errorCode);
|
||||
|
||||
|
|
@ -413,3 +437,9 @@ bool InstallController::checkSshConnection()
|
|||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void InstallController::setEncryptedPassphrase(QString passphrase)
|
||||
{
|
||||
m_privateKeyPassphrase = passphrase;
|
||||
emit passphraseRequestFinished();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -39,6 +39,8 @@ public slots:
|
|||
|
||||
bool checkSshConnection();
|
||||
|
||||
void setEncryptedPassphrase(QString passphrase);
|
||||
|
||||
signals:
|
||||
void installContainerFinished(QString finishMessage);
|
||||
void installServerFinished(QString finishMessage);
|
||||
|
|
@ -55,6 +57,9 @@ signals:
|
|||
|
||||
void serverAlreadyExists(int serverIndex);
|
||||
|
||||
void passphraseRequestStarted();
|
||||
void passphraseRequestFinished();
|
||||
|
||||
private:
|
||||
void installServer(DockerContainer container, QJsonObject &config);
|
||||
void installContainer(DockerContainer container, QJsonObject &config);
|
||||
|
|
@ -68,6 +73,8 @@ private:
|
|||
|
||||
bool m_shouldCreateServer;
|
||||
|
||||
QString m_privateKeyPassphrase;
|
||||
|
||||
#ifndef Q_OS_IOS
|
||||
QList<QSharedPointer<QProcess>> m_sftpMountProcesses;
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -91,6 +91,9 @@ signals:
|
|||
void hideMainWindow();
|
||||
void raiseMainWindow();
|
||||
|
||||
void showPassphraseRequestDrawer();
|
||||
void passphraseRequestDrawerClosed(QString passphrase);
|
||||
|
||||
private:
|
||||
QSharedPointer<ServersModel> m_serversModel;
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue