Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. I always get "SSL Handshake Failed" in Android phone, same code working in iOS and OSx desktop
QtWS25 Last Chance

I always get "SSL Handshake Failed" in Android phone, same code working in iOS and OSx desktop

Scheduled Pinned Locked Moved Mobile and Embedded
4 Posts 2 Posters 4.9k 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.
  • A Offline
    A Offline
    agiovacchini
    wrote on last edited by p3c0
    #1

    With some support I've succesfully built QT 5.3.1 for Android and deployed an app in my smartphone using it: https://qt-project.org/forums/viewthread/44762/, but now the problem is that when accessing an https site I always get “SSL Handshake failed”; I get the error only in Android, not iOS or OSx desktop, having the same code which is someting like that:

       ...
        QSslConfiguration ssl = QSslConfiguration::defaultConfiguration();
        ssl.setProtocol(QSsl::AnyProtocol);
        QNetworkAccessManager *managerWl;
        QUrl myUrl = QUrl(pUrl) ;
        qDebug() << myUrl ;
        QNetworkRequest request;
        request.setUrl(myUrl);
        request.setSslConfiguration(ssl);
        QNetworkReply *netReply = managerWl->get(request);
        QEventLoop loop;
        connect(netReply, SIGNAL(finished()), &loop, SLOT(quit()));
        loop.exec&#40;&#41;;
    
        if (netReply->error() == QNetworkReply::NoError) {
           ....
        }
        ....
    
    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      Which version of OpenSSL are you using ?

      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
      • A Offline
        A Offline
        agiovacchini
        wrote on last edited by p3c0
        #3

        It is openssl-1.0.1h

        I tried curl to download the page and it was telling:
        TLS 1.2 connection using TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384

        So I tought it was good to use:
        ssl.setProtocol(QSsl::TlsV1_2);
        And I did also try this, which was suggested by many people:
        ssl.setProtocol(QSsl::AnyProtocol);

        I've also tryed downloading the certificates chain with Firefox and putting it inside my deployed app, but no way:

        QUrl myUrl = QUrl(pUrl) ;
            qDebug() << myUrl ;
            QNetworkRequest request;
        #ifdef Q_OS_ANDROID
            QSslConfiguration ssl = QSslConfiguration::defaultConfiguration();
        
            QSslCertificate *sslCert = new QSslCertificate();
            QList<QSslCertificate> sslCertList = sslCert->fromPath("assets:/certs/*", QSsl::Pem,QRegExp::Wildcard);
        
            ssl.setCaCertificates(sslCertList);
            ssl.setProtocol(QSsl::SslV3);
            request.setSslConfiguration(ssl);
        
            QList<QSslCertificate> sslCertListBis = request.sslConfiguration().caCertificates() ;
            for (QSslCertificate cert: sslCertListBis) {
                qDebug() << "toText: " << cert.toText();
            }
        
        #endif
        

        But finally after hours of searching and trying in a post I found someone else having my same problem that solved like these:
        ssl.setProtocol(QSsl::SslV3);

        And it worked for me too, so it's ok. But I can't understand why

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

          OpenSSL on your device that is not the same ?

          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