Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Undefined reference to ... QSslCertificate::fromData()
Forum Updated to NodeBB v4.3 + New Features

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

Scheduled Pinned Locked Moved Solved General and Desktop
7 Posts 2 Posters 2.2k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • O Offline
    O Offline
    Opa114
    wrote on last edited by Opa114
    #1

    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!

    O 1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      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 ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      O 1 Reply Last reply
      0
      • SGaistS SGaist

        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 ?

        O Offline
        O Offline
        Opa114
        wrote on last edited by
        #3

        @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.

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          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.

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • O Opa114

            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!

            O Offline
            O Offline
            Opa114
            wrote on last edited by
            #5

            @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.

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              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.

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              O 1 Reply Last reply
              0
              • SGaistS SGaist

                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.

                O Offline
                O Offline
                Opa114
                wrote on last edited by
                #7

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

                1 Reply Last reply
                0

                • Login

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • Users
                • Groups
                • Search
                • Get Qt Extensions
                • Unsolved