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. Delay when using SSL on Windows
Forum Update on Monday, May 27th 2025

Delay when using SSL on Windows

Scheduled Pinned Locked Moved General and Desktop
1 Posts 1 Posters 555 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.
  • B Offline
    B Offline
    bobnew
    wrote on 6 Aug 2014, 16:50 last edited by
    #1

    We were experiencing a very long delay (4 seconds) on the first access to the SSL libraries. The problem only occurs on Windows, where we are using ssleay32.dll and libeay32.dll which come from OpenSSL (version openssl-1.0.1g-bin-mingw48). We have a work around for the issue, but the work around is not obvious unless you know the root cause of the delay.

    This is not an issue for Qt to fix, but it does effect Qt developers.

    We found these two links to discussions that talk about the issue. These discussions mention that the open SSL libraries are traversing the heap to compute an entropy value.

    http://rt.openssl.org/Ticket/Display.html?id=2100&user=guest&pass=guest
    https://groups.google.com/forum/#!topic/mailing.openssl.users/s41yE12pOVE

    The work around we found that fixes the 4 second delay was to access the SSL library very early in the application startup. By accessing the SSL library early, the size of the heap is small and the library spends less time traversing the heap to compute the entropy value.

    Attached is a small program that demonstrates the issue. A compile switch is used to measure the time to access SSL on a very small heap, and on a heap that has 500,000 objects on it. When there are 500,000 objects on the heap, the first call to the SSL library takes about 4500 msec. When the heap is minimal, the first call to the SSL library takes about 100 msec. This is on Windows 7 X64 Core i5-3437 1.9Ghz. The app is compiled in 32 bit.

    To see the effect of the SSL delay, build the program in release mode and run it from the command line. The delay does not materialize when running in the QtCreator debugger.

    @
    #include <QCoreApplication>
    #include <QSslSocket>
    #include <QElapsedTimer>
    #include <QDebug>

    #define fillHeap
    int main(int argc, char *argv[])
    {
    qDebug() << "ShowSSLDelay";

    QCoreApplication a(argc, argv);
    QElapsedTimer myTimer;
    qint64 elapsed;
    

    #ifdef fillHeap
    myTimer.start();
    // Fill up the heap with objects.
    QList<QString> heapUser;
    int numToMake = 500 * 1000;
    for( int i=0; i<numToMake; i++ )
    {
    QString s = QString::number(i);
    heapUser.append(s);
    }
    elapsed = myTimer.elapsed();
    qDebug() << "elapsed time to make " << numToMake << " objects = " << elapsed << " msec.";
    #endif

    myTimer.start();
    bool supports = QSslSocket::supportsSsl();
    elapsed = myTimer.elapsed();
    
    qDebug() << "elapsed time to call supportsSSL = " << elapsed << " msec.";
    qDebug() << "Supports SSL = " <<  supports;
    
    myTimer.start();
    supports = QSslSocket::supportsSsl();
    elapsed = myTimer.elapsed();
    
    qDebug() << "elapsed time to call supportsSSL second time = " << elapsed << " msec.";
    
    return 0;
    

    }

    @

    Output:

    ShowSSLDelay
    elapsed time to make 500000 objects = 210 msec.
    elapsed time to call supportsSSL = 4491 msec.
    Supports SSL = true
    elapsed time to call supportsSSL second time = 0 msec.

    1 Reply Last reply
    0

    1/1

    6 Aug 2014, 16:50

    • Login

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