Skip to content

Instantly share code, notes, and snippets.

@seyedmmousavi
Created October 3, 2021 17:08
Show Gist options
  • Save seyedmmousavi/d5faec3fb2efc3696eb30a119825096a to your computer and use it in GitHub Desktop.
Save seyedmmousavi/d5faec3fb2efc3696eb30a119825096a to your computer and use it in GitHub Desktop.
Embedding Let's Encrypt CA root certificate into Qt application
#include <QtNetwork/QSslConfiguration>
#include <QtNetwork/QSslSocket>
#include <QtGlobal>
//more includes...
int main(int argc, char *argv[])
{
//Adding CA root certificate of the Let'sEncrypt into default CA DB
//for Qt 5.15+
#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)
qDebug() << "loading embedded \"ISRG Root X1\" CA cert:"
<< QSslConfiguration::defaultConfiguration().addCaCertificates(":/ca_certs/isrg_root_x1.pem");
#else
qDebug() << "loading embedded \"ISRG Root X1\" CA cert:"
<< QSslSocket::addDefaultCaCertificates(":/ca_certs/isrg_root_x1.pem");
#endif
//more codes...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment