Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Installation and Deployment
  4. How to package OpenSSL libraries in an OS X package?

How to package OpenSSL libraries in an OS X package?

Scheduled Pinned Locked Moved Installation and Deployment
os xosxsslhttps
1 Posts 1 Posters 2.0k 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.
  • H Offline
    H Offline
    Hertzy
    wrote on last edited by
    #1

    I'm trying to create an application that works on both windows and OS X. This application accesses a REST service by QNetworkAccessManager over https. This means I need to include openssl in the application package.

    Currently, I'm using this bit of code (It's in main before initializing the QApplication) to get the application to look for libraries in the application package PlugIns directory:

        QDir dir(argv[0]); // e.g. appdir/Contents/MacOS/appname
        dir.cdUp();
        dir.cdUp();
        dir.cd("PlugIns"); // e.g. appdir/Contents/PlugIns
        QCoreApplication::setLibraryPaths(QStringList(dir.absolutePath()));
        qDebug()<<QApplication::libraryPaths();
        qDebug()<<dir.entryList();
    
        qDebug() << "Support SSL:  " << QSslSocket::supportsSsl()
                 << "\nLib Version Number: " << QSslSocket::sslLibraryVersionNumber()
                 << "\nLib Version String: " << QSslSocket::sslLibraryVersionString()
                 << "\nLib Build Version Number: " << QSslSocket::sslLibraryBuildVersionNumber()
                 << "\nLib Build Version String: " << QSslSocket::sslLibraryBuildVersionString();
    

    My .pro file contains these lines:

    macx: DEPENDPATH += $$PWD/MobileAccess/openssl_mac
    macx: DEPENDPATH += $$PWD/MobileAccess/openssl_mac
    macx: PRE_TARGETDEPS += $$PWD/MobileAccess/openssl_mac/libcrypto.a $$PWD/MobileAccess/openssl_mac/libssl.a
    macx: LIBS+= -L$$PWD/MobileAccess/openssl_mac/ -lssl -lcrypto
    

    I'm using a bash script to set the library link paths like this:

    install_name_tool -change /usr/local/ssl/lib/libcrypto.1.0.0.dylib @executable_path/../PlugIns/libcrypto.1.0.0.dylib Myapp;
    
    install_name_tool -change /usr/local/ssl/lib/libssl.1.0.0.dylib @executable_path/../PlugIns/libssl.1.0.0.dylib Myapp;
    
    cd ../PlugIns;
    
    install_name_tool -change /usr/local/ssl/lib/libssl.1.0.0.dylib @executable_path/../PlugIns/libssl.1.0.0.dylib libssl.1.0.0.dylib;
    
    install_name_tool -change /usr/local/ssl/lib/libcrypto.1.0.0.dylib @executable_path/../PlugIns/libcrypto.1.0.0.dylib libssl.1.0.0.dylib;
    
    install_name_tool -change /usr/local/ssl/lib/libcrypto.1.0.0.dylib @executable_path/../PlugIns/libcrypto.1.0.0.dylib libcrypto.1.0.0.dylib;
    

    The output when running the app from the command line is

    ("/Users/[.....]/Contents/PlugIns")
    (".", "..", "audio", "bearer", "imageformats", "libcrypto.1.0.0.dylib", "libssl.1.0.0.dylib", "mediaservice", "platforms", "printsupport", "sqldrivers")
    qt.network.ssl: QSslSocket: cannot resolve SSL_set_psk_client_callback
    qt.network.ssl: QSslSocket: cannot resolve TLSv1_1_client_method
    qt.network.ssl: QSslSocket: cannot resolve TLSv1_2_client_method
    qt.network.ssl: QSslSocket: cannot resolve TLSv1_1_server_method
    qt.network.ssl: QSslSocket: cannot resolve TLSv1_2_server_method
    qt.network.ssl: QSslSocket: cannot resolve SSL_select_next_proto
    qt.network.ssl: QSslSocket: cannot resolve SSL_CTX_set_next_proto_select_cb
    qt.network.ssl: QSslSocket: cannot resolve SSL_get0_next_proto_negotiated
    Support SSL:   true 
    Lib Version Number:  9470431 
    Lib Version String:  "OpenSSL 0.9.8zf 19 Mar 2015" 
    Lib Build Version Number:  268439727 
    Lib Build Version String:  "OpenSSL 1.0.1j 15 Oct 2014"
    

    So it is loading the outdated libraries shipped with OS X. Oddly enough, running from Qt creator, or in the directory MyApp.app/Contents/MacOs gives this output:

    ("/Users/[...]/Contents/PlugIns")
    (".", "..", "audio", "bearer", "imageformats", "libcrypto.1.0.0.dylib", "libssl.1.0.0.dylib", "mediaservice", "platforms", "printsupport", "sqldrivers")
    Support SSL:   true 
    Lib Version Number:  268443727 
    Lib Version String:  "OpenSSL 1.0.2d 9 Jul 2015" 
    Lib Build Version Number:  268439727 
    Lib Build Version String:  "OpenSSL 1.0.1j 15 Oct 2014"
    

    So it is loading the correct library. What am I missing here? Or is there some QNetworkAccessManager analogue in webengine that I could use to sidestep this issue?

    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