Undefined reference to ... QSslCertificate::fromData()



  • I want to create a QSslCertificate from pure Certificate Data i read from windows certificate store. My Little piece of code looks like:

        HCERTSTORE hCertStore = NULL;
        PCCERT_CONTEXT pCertContext = NULL;
        hCertStore = CertOpenSystemStore(NULL, L"My");
    
        if (! hCertStore) {
            qWarning("Failed to open store %s", qPrintable("My"));
            continue;
        }
    
        while (pCertContext = CertEnumCertificatesInStore(hCertStore, pCertContext)) {
            QByteArray qba(reinterpret_cast<const char *>(pCertContext->pbCertEncoded), pCertContext->cbCertEncoded);
    
            QSslCertificate::fromData(qba, QSsl::Pem);
        }
    

    When i run my Code i get the following error msg:
    undefined reference to `_imp___ZN15QSslCertificate8fromDataERK10QByteArrayN4QSsl14EncodingFormatE'

    So to me it seems that there is a Problem with the Format / Encoding of the Input data? i changed QSsl::Pem to QSsl::Der, but same error. So where is the probelm? thanks!

    EDIT:
    Solved. See third comment for solution!


  • Lifetime Qt Champion

    Hi and welcome to devnet,

    That kind of error generally comes from a library not linked to your application/library. Are you doing this from a Qt project ?

    On a side note, why don't you store the certificate(s) return from QSslCertificate::fromData ?



  • @SGaist

    yes i did it in a Qt Console Project.

    Did i need a library for using QSslCertificate? I thought it comes with Qt and did not need external libraries. So if yes, what library did i need? OpenSSL?

    The problem is here: QSslCertificate::fromData(qba, QSsl::Pem); so i can't store anything.


  • Lifetime Qt Champion

    No OpenSSL is not provided because of current international regulation about cryptographic software. So yes you need to have OpenSSL installed.

    Did you build Qt yourself ? Because the prebuilt package come with the support for OpenSSL enabled.



  • @Opa114

    i solved it. I had to add Qt += network in my *.pro file. So it work's without a third party library like OpenSSL.


  • Lifetime Qt Champion

    Good !

    The Qt SSL classes are using OpenSSL under the hood, except on OS X where there is now a new backend for OS X's Cryptographic Framework.



  • @SGaist thanks for the hint. i will keep it in mind if i compile for OS X :)


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.