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. QSslCertificate::importPkcs12() not implemented on macosx
Forum Update on Monday, May 27th 2025

QSslCertificate::importPkcs12() not implemented on macosx

Scheduled Pinned Locked Moved Solved General and Desktop
16 Posts 3 Posters 1.6k Views
  • 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.
  • P Offline
    P Offline
    Princein
    wrote on last edited by
    #1

    Hi:
    I developed a cross-platform qt app which can work on both mac and windows, I need to import the .p12 file, so I use the QSslCertificate::importPkcs12() method, it can work fine on windows, but when I run my app on mac, it shows error 'Unimplemented code.'
    here is my code about load .p12 file

    	QDir temDir3(QString::fromLocal8Bit(g_license_dir.c_str()));
    	QString abs_license_path = temDir3.absolutePath();
    	QFile license_file(abs_license_path);
    	//Q_ASSERT(license_file.open(QIODevice::ReadOnly));
    	license_file.open(QIODevice::ReadOnly);
    	QSslCertificate certificate;
    	QSslKey key;
    	QList<QSslCertificate> importedCerts;
    	std::string passphrase = "";//123456
    	bool imported = QSslCertificate::importPkcs12(&license_file, &key, &certificate, &importedCerts, QByteArray::fromStdString(passphrase));
    
    

    I certain the 'license_file' file path is right, and after large search, I found it is similar to the bug https://bugreports.qt.io/browse/QTBUG-56596,but it seems the bug is not solved,
    what should I do for import the .p12 file success on macosx? thanks a lot!

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

      Hi,

      Did you try to use the patch linked to the bug report ?

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

      P 1 Reply Last reply
      0
      • SGaistS SGaist

        Hi,

        Did you try to use the patch linked to the bug report ?

        P Offline
        P Offline
        Princein
        wrote on last edited by
        #3

        @SGaist yes, I had try, but it still can not solve this question!

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

          This patch implements the missing method. Are you sure you are using your self build version of Qt that added this method ?

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

          P 1 Reply Last reply
          0
          • SGaistS SGaist

            This patch implements the missing method. Are you sure you are using your self build version of Qt that added this method ?

            P Offline
            P Offline
            Princein
            wrote on last edited by
            #5

            @SGaist but how use the patch to fix the bug?

            jsulmJ 1 Reply Last reply
            0
            • P Princein

              @SGaist but how use the patch to fix the bug?

              jsulmJ Offline
              jsulmJ Offline
              jsulm
              Lifetime Qt Champion
              wrote on last edited by
              #6

              @Princein If you're on Linux/MacOS then enter "man patch" in a terminal and read.
              Also there is a lot information about applying patches on the Internet.
              You need Qt source code, then you apply the patch and build Qt.

              https://forum.qt.io/topic/113070/qt-code-of-conduct

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

                To add to @jsulm, there's also no need to rebuild all of Qt, qtbase will be enough for your test.

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

                P 1 Reply Last reply
                1
                • SGaistS SGaist

                  To add to @jsulm, there's also no need to rebuild all of Qt, qtbase will be enough for your test.

                  P Offline
                  P Offline
                  Princein
                  wrote on last edited by
                  #8

                  @SGaist, yes, I had download the qtbase directory, It seems the QSslCertificate::importPkcs12 method is implemented in the QtNetwork.framework, I will the change qsslsocket_mac.cpp file in the '~/Desktop/qt5/qtbase/src/network/ssl/' use the patch, after I fixed the code in network sub directory , how to build the qtbase directory to get the QtNetwork.framework? there is a network.pro file in the network sub directory , can I use QtCreator IDE open it to build and get the QtNetwork.framework?

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

                    I always build the full qtbase module when testing such changes.

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

                    P 1 Reply Last reply
                    0
                    • SGaistS SGaist

                      I always build the full qtbase module when testing such changes.

                      P Offline
                      P Offline
                      Princein
                      wrote on last edited by
                      #10

                      @SGaist I must use the 5.6.1 qt framework because the history reason, so in my project, I use the QtNetwork.framework which version is 5.6.1 when I use the QSslCertificate::importPkcs12 method, it shows me error 'Unimplemented code.' I had read the document 'Qt for macOS - Building from Source' https://doc.qt.io/qt-5/macos-building.html and can build the QtNetwork.framework which version is 5.6.1 on my mac successfully as I expect;
                      I see the patch on https://codereview.qt-project.org/#/c/199128/, it seems the patch only changes the 'src/network/ssl/qsslsocket_mac.cpp' file, so I use the qsslsocket_mac.cpp file in the patch instead of the qsslsocket_mac.cpp in the qt-everywhere-opensource-src-5.6.1 which I had download, when I rebuild qtbase in the the qt-everywhere-opensource-src-5.6.1 directory, it's show errors which tip me lack some method,
                      now I wonder whether the patch suitable for qt5.6.1 source code qt-everywhere-opensource-src-5.6.1?
                      how can I use the patch correct?
                      thanks a lot!

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

                        @Princein said in QSslCertificate::importPkcs12() not implemented on macosx:

                        so I use the qsslsocket_mac.cpp file in the patch instead of the qsslsocket_mac.cpp in the qt-everywhere-opensource-src-5.6.1

                        What do you mean by that ? A patch is meant to be applied on a file, not replace it.

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

                        P 2 Replies Last reply
                        0
                        • SGaistS SGaist

                          @Princein said in QSslCertificate::importPkcs12() not implemented on macosx:

                          so I use the qsslsocket_mac.cpp file in the patch instead of the qsslsocket_mac.cpp in the qt-everywhere-opensource-src-5.6.1

                          What do you mean by that ? A patch is meant to be applied on a file, not replace it.

                          P Offline
                          P Offline
                          Princein
                          wrote on last edited by
                          #12

                          @SGaist, the patch has Dependencies source code
                          alt text
                          is that means I must check out the dev branch on the git://code.qt.io/qt/qt5.git or other right git repository, after that using the patch for the dev branch? and then rebuild the qtbase subdirectory to get the fixed QtNetwork.framework?

                          1 Reply Last reply
                          0
                          • SGaistS SGaist

                            @Princein said in QSslCertificate::importPkcs12() not implemented on macosx:

                            so I use the qsslsocket_mac.cpp file in the patch instead of the qsslsocket_mac.cpp in the qt-everywhere-opensource-src-5.6.1

                            What do you mean by that ? A patch is meant to be applied on a file, not replace it.

                            P Offline
                            P Offline
                            Princein
                            wrote on last edited by
                            #13

                            @SGaist I had download the whole source code which includes the patch https://bugreports.qt.io/browse/QTBUG-56596 using 'git pull https://codereview.qt-project.org/qt/qtbase refs/changes/28/199128/11', and I build it successfully,I get the QtNetwork.framework after build,but the QtNetwork.framework which had the patch fix the bug version is 5.10.0, now in my qt project, the qt frameworks version is 5.6.1,can I change the QtNetwork.framework version from 5.10.0 to 5.6.1 by changing the source code config file? and how change the source code which includes the patch https://bugreports.qt.io/browse/QTBUG-56596 config file to generate 5.6.1 QtNetwork.framework? thanks a lot!

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

                              What you should do is get the 5.6.1 sources, and then apply the patch on top of the file of that version. You may have to do some adaptation by hand (maybe not)

                              Don't try to mix and match stuff.

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

                              P 1 Reply Last reply
                              0
                              • SGaistS SGaist

                                What you should do is get the 5.6.1 sources, and then apply the patch on top of the file of that version. You may have to do some adaptation by hand (maybe not)

                                Don't try to mix and match stuff.

                                P Offline
                                P Offline
                                Princein
                                wrote on last edited by
                                #15

                                @SGaist hahaha, I had solved this problem by changing the 5.6.1 version qtbase/network source code file by hand, thank you!

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

                                  You're welcome !

                                  Since you have it working now, pleas mark the thread as solved using the "Topic Tools" button so that other forum users may know a solution has been found.

                                  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

                                  • Login

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