QSslUtils is a collection high level functions for creating RSA keys, CA certificates, certificate signing requests and signing CSRs.
QSslUtils can be built directly into your project if your project is LGPL3 compatible. If your project is closed source, you can build QSslUtils as a dynamic library and link against it.
-
Clone as a git submodule or download QSslUtils. If you download, unzip as a directory to be under your project's directory.
-
Include the qtsslutils.pri file in your projects .pro file
include(QtSslUtils/qtsslutils.pri)
INCLUDEPATH=+ QSslUtils
-
Add QZEROCONF_STATIC define in your projects .pro file
DEFINES= QSSLUTILS_STATIC
- Clone or download QSslUtils. If you download, unzip.
- Enter the QtSslUtils directory, run qmake, then make, then (sudo) make install
- Include header
#include "qsslutils.h"
- Create an super secret key and then pass that key to the createCA function. The last two parameters to createCA are serial number and days the cert should be valid for.
QSslEvpKey superSecretKey = QSslUtils::generateRSAKey(2048);
QSslX509 ca = QSslUtils::createCA(superSecretKey, "US", "MD", "Fort Meade", "FooBar NSA", "IT", 1, 30);
QSslEvpKey and QSslX509 are smart pointers with custom deleters so they will call the correct ssl free function when their reference count goes to 0.
- Include header
#include "qsslutils.h"
-
Create a RSA key to be used for the intermediate or local certificate.
-
Create a Certificate Signing Request.
-
Then use the created CA from above "Creating a CA" and it's super secret key to sign the CSR. The last two parameters to signCSR are serial number and days the cert should be valid for.
QSslEvpKey reqKey = QSslUtils::generateRSAKey(2048);
QSslX509Req req = QSslUtils::createCSR(reqKey, "CA", "Ontario", "Ottawa", "FooBar CSIS", "IT");
QSslX509 cert = QSslUtils::signCSR(ca, superSecretKey, req, 1, 30);
QSslEvpKey, QSslX509Req and QSslX509 are smart pointers with custom deleters so they will call the correct ssl free function when their reference count goes to 0.