mirror of
https://github.com/QuasarApp/qca.git
synced 2025-04-28 04:24:32 +00:00
91 lines
1.7 KiB
Plaintext
91 lines
1.7 KiB
Plaintext
/*
|
|
-----BEGIN QCMOD-----
|
|
name: certstore
|
|
arg: certstore-path=[path],Path to the SSL/X509 Certificate store
|
|
-----END QCMOD-----
|
|
*/
|
|
|
|
class qc_certstore : public ConfObj
|
|
{
|
|
public:
|
|
qc_certstore(Conf *c) : ConfObj(c) {}
|
|
QString name() const { return "certstore"; }
|
|
QString shortname() const { return "certstore"; }
|
|
|
|
bool exec()
|
|
{
|
|
bundled = false;
|
|
|
|
#if defined(Q_OS_WIN) || defined(Q_OS_MAC)
|
|
// use built-in
|
|
return true;
|
|
#else
|
|
QStringList pathsToTry;
|
|
|
|
path = conf->getenv("QC_CERTSTORE_PATH");
|
|
if(!path.isEmpty())
|
|
{
|
|
if(QFile::exists(path))
|
|
return true;
|
|
return false;
|
|
}
|
|
|
|
// This is from Debian
|
|
pathsToTry.append( QString("/etc/ssl/certs/ca-certificates.crt") );
|
|
|
|
// Fedora Core 2 uses these
|
|
pathsToTry.append( QString("/usr/share/ssl/cert.pem") );
|
|
pathsToTry.append( QString("/usr/share/ssl/certs/ca-bundle.crt") );
|
|
|
|
for(int n = 0; n < pathsToTry.count(); ++n)
|
|
{
|
|
if(QFile::exists(pathsToTry[n]))
|
|
{
|
|
path = pathsToTry[n];
|
|
break;
|
|
}
|
|
}
|
|
|
|
// fall back to bundled
|
|
if(path.isEmpty())
|
|
{
|
|
path = "$$DATADIR/qca/certs/rootcerts.pem";
|
|
QString extra =
|
|
"sharedfiles.path = $$DATADIR/qca\n"
|
|
"sharedfiles.files = certs\n"
|
|
"INSTALLS += sharedfiles\n";
|
|
conf->addExtra(extra);
|
|
bundled = true;
|
|
}
|
|
|
|
QString certPathString = "QCA_SYSTEMSTORE_PATH='\"" + path + "\"'";
|
|
conf->addDefine(certPathString);
|
|
|
|
return true;
|
|
#endif
|
|
}
|
|
|
|
QString resultString() const
|
|
{
|
|
#if defined(Q_OS_WIN)
|
|
return "using Windows built-in";
|
|
#elif defined(Q_OS_MAC)
|
|
return "using Mac built-in";
|
|
#else
|
|
if(success)
|
|
{
|
|
if(bundled)
|
|
return "using bundled";
|
|
else
|
|
return path;
|
|
}
|
|
else
|
|
return ConfObj::resultString();
|
|
#endif
|
|
}
|
|
|
|
private:
|
|
QString path;
|
|
bool bundled;
|
|
};
|