create root ca directory if does not exist

This commit is contained in:
gaelle 2025-04-01 16:52:09 +02:00
parent 3a080ea801
commit f59f88a688

View file

@ -26,6 +26,7 @@
#include "config.h"
#include "tool/Constants.hpp"
#include "tool/Utils.hpp"
#include "Paths.hpp"
@ -163,9 +164,21 @@ static inline QString getAppRootCaFilePath() {
if (Paths::filePathExists(rootca)) { // Packaged
return rootca;
} else {
qDebug() << "Root ca path does not exist. Create it";
QFileInfo rootcaInfo(rootca);
if (!rootcaInfo.absoluteDir().exists()) {
QDir dataDir(getAppPackageDataDirPath());
if (!dataDir.mkpath(Constants::PathRootCa)) {
lCritical() << "ERROR : COULD NOT CREATE DIRECTORY WITH PATH" << Constants::PathRootCa;
return "";
}
}
QFile rootCaFile(rootca);
if (rootCaFile.open(QIODevice::ReadWrite))
return rootca;
else {
lCritical() << "ERROR : COULD NOT CREATE ROOTCA WITH PATH" << rootca;
}
}
return "";
}