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. Replacing subjectDisplayName() by issuerInfo, keeping the same behavior
Forum Updated to NodeBB v4.3 + New Features

Replacing subjectDisplayName() by issuerInfo, keeping the same behavior

Scheduled Pinned Locked Moved Unsolved General and Desktop
7 Posts 2 Posters 403 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.
  • P Offline
    P Offline
    Pantoufle
    wrote on last edited by
    #1

    Hello,

    I am currently porting code that was done in Qt 5.12 to Qt 5.9. In code 5.12 I have a method in the QSslCertificate, which does not exist in 5.9. This is a method used to retrieve the name of an SSL certificate, subjectDisplayName().

    For the moment I have replaced the calls to subjectDisplayName() by subjectInfo(QSslCertificate :: CommonName).

    My problem is that subjectDisplayName return a string, which is logic, cause it's the name of the subject. But subjectinfo(QSslCertificate::CommonName) return a QStringList, what does this mean?
    Does this mean that the subject can have several common name? If so then why does subjectDisplayName () only return one name?

    Thank you for your help, have a good day :)

    Pl45m4P 1 Reply Last reply
    0
    • P Pantoufle

      Hello,

      I am currently porting code that was done in Qt 5.12 to Qt 5.9. In code 5.12 I have a method in the QSslCertificate, which does not exist in 5.9. This is a method used to retrieve the name of an SSL certificate, subjectDisplayName().

      For the moment I have replaced the calls to subjectDisplayName() by subjectInfo(QSslCertificate :: CommonName).

      My problem is that subjectDisplayName return a string, which is logic, cause it's the name of the subject. But subjectinfo(QSslCertificate::CommonName) return a QStringList, what does this mean?
      Does this mean that the subject can have several common name? If so then why does subjectDisplayName () only return one name?

      Thank you for your help, have a good day :)

      Pl45m4P Offline
      Pl45m4P Offline
      Pl45m4
      wrote on last edited by Pl45m4
      #2

      @Pantoufle said in Replacing subjectDisplayName() by issuerInfo, keeping the same behavior:

      I am currently porting code that was done in Qt 5.12 to Qt 5.9

      Why would one move backwards?

      My problem is that subjectDisplayName return a string, which is logic, cause it's the name of the subject. But subjectinfo(QSslCertificate::CommonName) return a QStringList, what does this mean?

      It means that you still can get the name by parsing the stringList (if available) :)

      • https://doc.qt.io/qt-5/qsslcertificate.html#SubjectInfo-enum

      If debugging is the process of removing software bugs, then programming must be the process of putting them in.

      ~E. W. Dijkstra

      1 Reply Last reply
      2
      • P Offline
        P Offline
        Pantoufle
        wrote on last edited by
        #3

        Why would one move backwards?

        Because the original project is in 5.9 and I'm not the main maintainer of this project, so, I'm just dealing with it ^^.

        It means that you still can get the name by parsing the stringList (if available) :)

        Parsing? I was guessing that if I user the argument "QSslCertificate::CommonName" it would return me only the name.

        For example :

        QString name = cert.subjectinfo(QSslCertificate::CommonName)[0]
        

        This line don't return me the name?

        Thanks for your help.

        Pl45m4P 1 Reply Last reply
        0
        • P Pantoufle

          Why would one move backwards?

          Because the original project is in 5.9 and I'm not the main maintainer of this project, so, I'm just dealing with it ^^.

          It means that you still can get the name by parsing the stringList (if available) :)

          Parsing? I was guessing that if I user the argument "QSslCertificate::CommonName" it would return me only the name.

          For example :

          QString name = cert.subjectinfo(QSslCertificate::CommonName)[0]
          

          This line don't return me the name?

          Thanks for your help.

          Pl45m4P Offline
          Pl45m4P Offline
          Pl45m4
          wrote on last edited by
          #4

          @Pantoufle said in Replacing subjectDisplayName() by issuerInfo, keeping the same behavior:

          This line don't return me the name?

          What do you get?

          There is a stringList because there can be more than one entry. Each entry is a new string in your stringList.

          Returns the information for the subject, or an empty list if there is no information for subject in the certificate. There can be more than one entry of each type.
          (https://doc.qt.io/qt-5/qsslcertificate.html#subjectInfo)


          If debugging is the process of removing software bugs, then programming must be the process of putting them in.

          ~E. W. Dijkstra

          1 Reply Last reply
          0
          • P Offline
            P Offline
            Pantoufle
            wrote on last edited by
            #5

            What do you get?

            I'm on an embedded device and i cant have acces to it easily, so i can't really test it for now. It would be too simple :p.

            There is a stringList because there can be more than one entry. Each entry is a new string in your stringList.

            If I pass QSslCertificate :: CommonName in argument of the method, does this return me a list of name, or all the info? By all info I mean, name, locality, country ...

            Pl45m4P 1 Reply Last reply
            0
            • P Pantoufle

              What do you get?

              I'm on an embedded device and i cant have acces to it easily, so i can't really test it for now. It would be too simple :p.

              There is a stringList because there can be more than one entry. Each entry is a new string in your stringList.

              If I pass QSslCertificate :: CommonName in argument of the method, does this return me a list of name, or all the info? By all info I mean, name, locality, country ...

              Pl45m4P Offline
              Pl45m4P Offline
              Pl45m4
              wrote on last edited by
              #6

              @Pantoufle said in Replacing subjectDisplayName() by issuerInfo, keeping the same behavior:

              If I pass QSslCertificate :: CommonName in argument of the method, does this return me a list of name, or all the info? By all info I mean, name, locality, country ...

              Everything that is stored in "CN":

              QSslCertificate::CommonName ---- "CN" The common name; most often this is used to store the host name.

              Could be empty, could be more than 1 string. Depends on your certificate.

              Just try it when you can test it and see what you get.


              If debugging is the process of removing software bugs, then programming must be the process of putting them in.

              ~E. W. Dijkstra

              1 Reply Last reply
              1
              • P Offline
                P Offline
                Pantoufle
                wrote on last edited by
                #7

                Ok great, I'll keep you posted. Thanks for the help and have a nice day.

                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