summaryrefslogtreecommitdiffstats
path: root/pica-client
diff options
context:
space:
mode:
Diffstat (limited to 'pica-client')
-rw-r--r--pica-client/globals.h1
-rw-r--r--pica-client/main.cpp15
-rw-r--r--pica-client/nodethread.cpp2
-rw-r--r--pica-client/openssltool.cpp20
-rw-r--r--pica-client/openssltool.h2
5 files changed, 40 insertions, 0 deletions
diff --git a/pica-client/globals.h b/pica-client/globals.h
index d30305d..dcc4f8d 100644
--- a/pica-client/globals.h
+++ b/pica-client/globals.h
@@ -3,6 +3,7 @@
#define PICA_CLIENT_STORAGEDB "pica-client.sqlite"
#define PICA_CLIENT_CONFIGDIR ".pica-client"
+#define PICA_CLIENT_DHPARAMFILE "dhparam4096.pem"
#ifndef PICA_INSTALLPREFIX
diff --git a/pica-client/main.cpp b/pica-client/main.cpp
index 55dc10c..2cfa2d4 100644
--- a/pica-client/main.cpp
+++ b/pica-client/main.cpp
@@ -11,6 +11,7 @@
#include <QMessageBox>
#include <QString>
#include <QIcon>
+#include "openssltool.h"
//globals
QString config_dir;
@@ -239,6 +240,20 @@ static bool create_config_dir()
else
update_database();
+ if (!QFile::exists(config_dir + QDir::separator() + PICA_CLIENT_DHPARAMFILE))
+ {
+ OpenSSLTool osslt;
+ msgBox.setText(QString(QObject::tr("Diffie-Hellman parameters will be generated. Please wait. This process can take several minutes...")));
+ msgBox.exec();
+
+ if (!osslt.GenDHParam(4096, config_dir + QDir::separator() + PICA_CLIENT_DHPARAMFILE))
+ {
+ msgBox.setText(QString(QObject::tr("Failed to generate Diffie-Hellman parameters")));
+ msgBox.exec();
+ return false;
+ }
+ }
+
return true;
}
diff --git a/pica-client/nodethread.cpp b/pica-client/nodethread.cpp
index aa41b04..4065e79 100644
--- a/pica-client/nodethread.cpp
+++ b/pica-client/nodethread.cpp
@@ -1,6 +1,7 @@
#include "nodethread.h"
#include "mainwindow.h"
#include "../PICA_proto.h"
+#include "globals.h"
QMutex NodeThread::finished_mutex;
@@ -26,6 +27,7 @@ void NodeThread::run()
user_account.CA_file.toUtf8().constData(),
user_account.cert_file.toUtf8().constData(),
user_account.pkey_file.toUtf8().constData(),
+ (config_dir + QDir::separator() + PICA_CLIENT_DHPARAMFILE).toUtf8().constData(),
AskPassword::ask_password_cb,
&ci);
diff --git a/pica-client/openssltool.cpp b/pica-client/openssltool.cpp
index 1ee7a90..25640ca 100644
--- a/pica-client/openssltool.cpp
+++ b/pica-client/openssltool.cpp
@@ -158,5 +158,25 @@ QString OpenSSLTool::ReadStdOut()
return QString::fromUtf8(openssl_.readAllStandardOutput().constData());
}
+bool OpenSSLTool::GenDHParam(quint32 numbits, QString output_file)
+{//openssl dhparam -5 4096
+ openssl_.start("openssl",
+ QStringList()
+ <<"dhparam"
+ <<"-out"<<output_file
+ <<"-5"
+ <<QString::number(numbits));
+
+ if (!openssl_.waitForStarted())
+ return false;
+
+ if (!openssl_.waitForFinished(-1))
+ return false;
+
+ if (openssl_.exitCode() != 0)
+ return false;
+
+ return true;
+}
diff --git a/pica-client/openssltool.h b/pica-client/openssltool.h
index b2711bb..cafc291 100644
--- a/pica-client/openssltool.h
+++ b/pica-client/openssltool.h
@@ -17,6 +17,8 @@ public:
QString password, QObject *receiver, const char *finished_slot);
bool GenCertSignal(QString cert_file, QString keyfile, QString keypassword, QString subject, QObject *receiver, const char *finished_slot);
+ bool GenDHParam(quint32 numbits, QString output_file);
+
QString ReadStdErr();
QString ReadStdOut();