Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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