Download and extract OpenSSL dependencies #4313
This commit is contained in:
parent
c181d5f480
commit
b8a5abc19f
|
@ -42,7 +42,8 @@ static QString kUnixOpenSslCommand = "openssl";
|
||||||
|
|
||||||
#if defined(Q_OS_WIN)
|
#if defined(Q_OS_WIN)
|
||||||
static const char kWinPluginExt[] = ".dll";
|
static const char kWinPluginExt[] = ".dll";
|
||||||
static const char kWinOpenSslBinary[] = "openssl.exe";
|
static const char kWinOpenSslSetup[] = "openssl-1.0.2-Windows-x86.exe";
|
||||||
|
static const char kWinOpenSslBinary[] = "OpenSSL\\openssl.exe";
|
||||||
|
|
||||||
#elif defined(Q_OS_MAC)
|
#elif defined(Q_OS_MAC)
|
||||||
static const char kMacPluginPrefix[] = "lib";
|
static const char kMacPluginPrefix[] = "lib";
|
||||||
|
@ -100,7 +101,7 @@ void PluginManager::downloadPlugins()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PluginManager::saveOpenSslBinary()
|
void PluginManager::saveOpenSslSetup()
|
||||||
{
|
{
|
||||||
QDir dir(m_ProfileDir);
|
QDir dir(m_ProfileDir);
|
||||||
if (!dir.exists()) {
|
if (!dir.exists()) {
|
||||||
|
@ -109,7 +110,7 @@ void PluginManager::saveOpenSslBinary()
|
||||||
|
|
||||||
QString filename = m_ProfileDir;
|
QString filename = m_ProfileDir;
|
||||||
#if defined(Q_OS_WIN)
|
#if defined(Q_OS_WIN)
|
||||||
filename.append("\\").append(kWinOpenSslBinary);
|
filename.append("\\").append(kWinOpenSslSetup);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
@ -124,6 +125,20 @@ void PluginManager::saveOpenSslBinary()
|
||||||
file.write(m_DataDownloader.data());
|
file.write(m_DataDownloader.data());
|
||||||
file.close();
|
file.close();
|
||||||
|
|
||||||
|
QString openSslSetupFile = m_ProfileDir;
|
||||||
|
openSslSetupFile.append("\\").append(kWinOpenSslSetup);
|
||||||
|
|
||||||
|
QStringList installArgs;
|
||||||
|
installArgs.append("-s");
|
||||||
|
installArgs.append("-y");
|
||||||
|
|
||||||
|
if (!runProgram(openSslSetupFile, installArgs, QStringList())) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// openssl installer no longer needed
|
||||||
|
QFile::remove(openSslSetupFile);
|
||||||
|
|
||||||
emit openSslBinaryReady();
|
emit openSslBinaryReady();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -135,7 +150,7 @@ void PluginManager::generateCertificate()
|
||||||
this,
|
this,
|
||||||
SLOT(doGenerateCertificate()));
|
SLOT(doGenerateCertificate()));
|
||||||
|
|
||||||
downloadOpenSslBinary();
|
downloadOpenSslSetup();
|
||||||
}
|
}
|
||||||
|
|
||||||
void PluginManager::savePlugin()
|
void PluginManager::savePlugin()
|
||||||
|
@ -148,7 +163,7 @@ void PluginManager::savePlugin()
|
||||||
|
|
||||||
QString filename = m_PluginDir;
|
QString filename = m_PluginDir;
|
||||||
QString pluginName = m_PluginList.at(m_DownloadIndex);
|
QString pluginName = m_PluginList.at(m_DownloadIndex);
|
||||||
pluginName = getPluginOSSpecificName(pluginName);
|
pluginName = getPluginOsSpecificName(pluginName);
|
||||||
filename.append(QDir::separator()).append(pluginName);
|
filename.append(QDir::separator()).append(pluginName);
|
||||||
|
|
||||||
QFile file(filename);
|
QFile file(filename);
|
||||||
|
@ -216,25 +231,25 @@ QString PluginManager::getPluginUrl(const QString& pluginName)
|
||||||
result.append(pluginName).append("/1.0/");
|
result.append(pluginName).append("/1.0/");
|
||||||
result.append(archName);
|
result.append(archName);
|
||||||
result.append("/");
|
result.append("/");
|
||||||
result.append(getPluginOSSpecificName(pluginName));
|
result.append(getPluginOsSpecificName(pluginName));
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString PluginManager::getOpenSslBinaryUrl()
|
QString PluginManager::getOpenSslSetupUrl()
|
||||||
{
|
{
|
||||||
QString result;
|
QString result;
|
||||||
|
|
||||||
#if defined(Q_OS_WIN)
|
#if defined(Q_OS_WIN)
|
||||||
result = kBaseUrl;
|
result = kBaseUrl;
|
||||||
result.append("/tools/");
|
result.append("/tools/");
|
||||||
result.append(kWinOpenSslBinary);
|
result.append(kWinOpenSslSetup);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString PluginManager::getPluginOSSpecificName(const QString& pluginName)
|
QString PluginManager::getPluginOsSpecificName(const QString& pluginName)
|
||||||
{
|
{
|
||||||
QString result = pluginName;
|
QString result = pluginName;
|
||||||
#if defined(Q_OS_WIN)
|
#if defined(Q_OS_WIN)
|
||||||
|
@ -258,16 +273,17 @@ bool PluginManager::checkOpenSslBinary()
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void PluginManager::downloadOpenSslBinary()
|
void PluginManager::downloadOpenSslSetup()
|
||||||
{
|
{
|
||||||
if (checkOpenSslBinary()) {
|
if (checkOpenSslBinary()) {
|
||||||
emit openSslBinaryReady();
|
emit openSslBinaryReady();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString urlString = getOpenSslSetupUrl();
|
||||||
|
|
||||||
QUrl url;
|
QUrl url;
|
||||||
QString openSslUrl = getOpenSslBinaryUrl();
|
url.setUrl(urlString);
|
||||||
url.setUrl(openSslUrl);
|
|
||||||
|
|
||||||
disconnect(
|
disconnect(
|
||||||
&m_DataDownloader,
|
&m_DataDownloader,
|
||||||
|
@ -279,18 +295,20 @@ void PluginManager::downloadOpenSslBinary()
|
||||||
&m_DataDownloader,
|
&m_DataDownloader,
|
||||||
SIGNAL(isComplete()),
|
SIGNAL(isComplete()),
|
||||||
this,
|
this,
|
||||||
SLOT(saveOpenSslBinary()));
|
SLOT(saveOpenSslSetup()));
|
||||||
|
|
||||||
m_DataDownloader.download(url);
|
m_DataDownloader.download(url);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PluginManager::doGenerateCertificate()
|
void PluginManager::doGenerateCertificate()
|
||||||
{
|
{
|
||||||
QString openSslFilename = m_ProfileDir;
|
QString openSslProgramFile;
|
||||||
|
|
||||||
#if defined(Q_OS_WIN)
|
#if defined(Q_OS_WIN)
|
||||||
openSslFilename.append("\\").append(kWinOpenSslBinary);
|
openSslProgramFile = m_ProfileDir;
|
||||||
|
openSslProgramFile.append("\\").append(kWinOpenSslBinary);
|
||||||
#else
|
#else
|
||||||
openSslFilename = kUnixOpenSslCommand;
|
openSslProgramFile = kUnixOpenSslCommand;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
QStringList arguments;
|
QStringList arguments;
|
||||||
|
@ -324,8 +342,24 @@ void PluginManager::doGenerateCertificate()
|
||||||
arguments.append("-out");
|
arguments.append("-out");
|
||||||
arguments.append(filename);
|
arguments.append(filename);
|
||||||
|
|
||||||
|
QStringList environment;
|
||||||
|
environment << QString("OPENSSL_CONF=%1\\OpenSSL\\synergy.conf")
|
||||||
|
.arg(m_ProfileDir);
|
||||||
|
|
||||||
|
if (!runProgram(openSslProgramFile, arguments, environment)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
emit generateCertificateFinished();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool PluginManager::runProgram(
|
||||||
|
const QString& program, const QStringList& args, const QStringList& env)
|
||||||
|
{
|
||||||
QProcess process;
|
QProcess process;
|
||||||
process.start(openSslFilename, arguments);
|
process.setEnvironment(env);
|
||||||
|
process.start(program, args);
|
||||||
|
|
||||||
bool success = process.waitForStarted();
|
bool success = process.waitForStarted();
|
||||||
|
|
||||||
QString standardOutput, standardError;
|
QString standardOutput, standardError;
|
||||||
|
@ -336,14 +370,15 @@ void PluginManager::doGenerateCertificate()
|
||||||
}
|
}
|
||||||
|
|
||||||
int code = process.exitCode();
|
int code = process.exitCode();
|
||||||
if (!standardError.isEmpty() || !success || code != 0)
|
if (!success || code != 0)
|
||||||
{
|
{
|
||||||
emit error(
|
emit error(
|
||||||
QString("Failed to generate certificate.\n\nCode: %1\nError: %2")
|
QString("Program failed: %1\n\nCode: %2\nError: %3")
|
||||||
.arg(process.exitCode())
|
.arg(program)
|
||||||
.arg(standardError.isEmpty() ? "Unknown" : standardError));
|
.arg(process.exitCode())
|
||||||
return;
|
.arg(standardError.isEmpty() ? "Unknown" : standardError));
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
emit generateCertificateFinished();
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,17 +37,21 @@ public:
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void downloadPlugins();
|
void downloadPlugins();
|
||||||
void saveOpenSslBinary();
|
void saveOpenSslSetup();
|
||||||
void generateCertificate();
|
void generateCertificate();
|
||||||
void doGenerateCertificate();
|
void doGenerateCertificate();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void savePlugin();
|
void savePlugin();
|
||||||
QString getPluginUrl(const QString& pluginName);
|
QString getPluginUrl(const QString& pluginName);
|
||||||
QString getOpenSslBinaryUrl();
|
QString getOpenSslSetupUrl();
|
||||||
QString getPluginOSSpecificName(const QString& pluginName);
|
QString getPluginOsSpecificName(const QString& pluginName);
|
||||||
bool checkOpenSslBinary();
|
bool checkOpenSslBinary();
|
||||||
void downloadOpenSslBinary();
|
void downloadOpenSslSetup();
|
||||||
|
bool runProgram(
|
||||||
|
const QString& program,
|
||||||
|
const QStringList& args,
|
||||||
|
const QStringList& env);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void error(QString e);
|
void error(QString e);
|
||||||
|
|
|
@ -84,7 +84,7 @@ void PluginWizardPage::updateDownloadStatus()
|
||||||
QStringList pluginList = m_pWebClient->getPluginList();
|
QStringList pluginList = m_pWebClient->getPluginList();
|
||||||
int index = m_pPluginManager->downloadIndex();
|
int index = m_pPluginManager->downloadIndex();
|
||||||
updateStatus(
|
updateStatus(
|
||||||
tr("Downloading plugin: %1 (%2/%3)")
|
tr("Downloading '%1' plugin (%2/%3)...")
|
||||||
.arg(pluginList.at(index + 1))
|
.arg(pluginList.at(index + 1))
|
||||||
.arg(index + 2)
|
.arg(index + 2)
|
||||||
.arg(pluginList.size()));
|
.arg(pluginList.size()));
|
||||||
|
@ -111,6 +111,8 @@ void PluginWizardPage::generateCertificate()
|
||||||
m_pPluginManagerThread,
|
m_pPluginManagerThread,
|
||||||
SLOT(quit()));
|
SLOT(quit()));
|
||||||
|
|
||||||
|
updateStatus(tr("Generating SSL certificate..."));
|
||||||
|
|
||||||
QMetaObject::invokeMethod(
|
QMetaObject::invokeMethod(
|
||||||
m_pPluginManager,
|
m_pPluginManager,
|
||||||
"generateCertificate",
|
"generateCertificate",
|
||||||
|
|
Loading…
Reference in New Issue