Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-73391

QSslKey constructor confused by leading whitespace

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P4: Low
    • None
    • 5.12.0
    • Network: SSL
    • None
    • Windows 10
    • Windows

    Description

      We have code of the following form:

      QSslKey key( QByteArray(keyString.toUtf8()), QSsl::Rsa, QSsl::Pem);

      if (key.isNull()) return false;

      if (key.algorithm() != QSsl::Rsa || key.type() != QSsl::PrivateKey) return false;

      return true;

      When supplied a private key string of the form 

      ----BEGIN RSA PRIVATE KEY---\nMIIEowIBAAKCAQEA07/x1AEc2<redacted>jyJ9Utc24jNpRWsAq\n---END RSA PRIVATE KEY----

      it returns true.

      When supplied the same key, but with a leading space 

       ----BEGIN RSA PRIVATE KEY---\nMIIEowIBAAKCAQEA07/x1AEc2<redacted>jyJ9Utc24jNpRWsAq\n---END RSA PRIVATE KEY----

      The code still succeeds under macOS Mojave.

      It fails under Windows with Qt 5.10, with the algorithm/type not being correct.

      It fails under Windows with Qt 5.12, with the key being null.

      This appeared due to a customer doing a copy/paste of a valid key, and ending up with an invalid key.

      Workaround: our code now trims keyString before using it.

      Suggested fix: the QSslKey constructor should do the trim (or moral equivalent)

      Note: QSslCertificate does not suffer from this, nor does QSslKey appear to suffer with trailing whitespace instead

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            cnn Qt Core & Network
            bellinghman Alan Bellingham
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes