title: Qt error message "qt.network.ssl: QSslSocket::connectToHostEncrypted: TLS initialization failed"
body: <p>I get the following error when I try to run my Qt application:</p>
  
  <blockquote>
    <p>qt.network.ssl: QSslSocket::connectToHostEncrypted: TLS initialization failed<br/>
    qt.network.ssl: QSslSocket::connectToHostEncrypted: TLS initialization failed<br/>
    Error:  "TLS initialization failed"</p>
  </blockquote>
  
  <p>My application is really basic here is what it is look like:</p>
  
  <pre><code>#include "widget.h"
  #include "ui_widget.h"
  #include &lt;QNetworkReply&gt;
  
  #include &lt;QDebug&gt;
  
  
  Widget::Widget(QWidget *parent)
      : QWidget(parent)
      , ui(new Ui::Widget)
  {
      ui-&gt;setupUi(this);
  
      netManager  = new QNetworkAccessManager(this);
      netReply = nullptr;
      mDataBuffer = new QByteArray();
  
      //Define network request
      QNetworkRequest request;
      request.setUrl(QUrl("https://www.qt.io"));
  
      netReply = netManager-&gt;get(request);
      connect(netReply,&amp;QIODevice::readyRead,this,&amp;Widget::dataReadyToRead);
      connect(netReply,&amp;QNetworkReply::finished,this,&amp;Widget::dataReadFinished);
  
  }
  
  Widget::~Widget()
  {
      delete ui;
  }
  
  void Widget::dataReadyToRead()
  {
      qDebug() &lt;&lt; "Datas available to read";
      mDataBuffer-&gt;append(netReply-&gt;readAll());
  }
  
  void Widget::dataReadFinished()
  {
      if(netReply-&gt;error())
      {
          qDebug() &lt;&lt; "Error: " &lt;&lt; netReply-&gt;errorString();
      }
      else
      {
          ui-&gt;textEdit-&gt;setPlainText(QString(*mDataBuffer));
      }
  }
  
  </code></pre>
  
  <p>So I searched on stack overflow and find some answers (it seems that the error occurs because the openSSl librairies are not found) but it still doesn't work.<br/>
  So here is what I've done so far:</p>
  
  <ul>
  <li>I've downloaded OpenSSL for window 64 bit (Win64 OpenSSL v1.1.1d) on this website: 
      <a href="https://slproweb.com/products/Win32OpenSSL.html" rel="nofollow noreferrer">https://slproweb.com/products/Win32OpenSSL.html</a></li>
  <li>I've installed OpenSSL
  (- Try to set environment variables but I didn't manage to do it correctly)</li>
  <li>Try to run my app while running openSSL</li>
  </ul>
  
  <p>Did I miss something?</p>
  
  <p>Edit:</p>
  
  <p>Thanks for the reply:</p>
  
  <p>Here is what is get from the qDebugs:</p>
  
  <ul>
  <li><p>QSslSocket::sslLibraryBuildVersionString() returned: "OpenSSL 1.0.2p  14 Aug 2018"  </p></li>
  <li><p>QSslSocket::supportsSsl() returned: false  </p></li>
  <li><p>QSslSocket::sslLibraryVersionString() returned: an empty string</p></li>
  </ul>
  
  <p>So here is I've grab and install OpenSSL in 1.0.2 version, (unistall the other one), add to the PATH variable the install folder (which is simply C:\OpenSSL-Win64, also tried C:\OpenSSL-Win64\bin both of those file cotains dll)</p>
  
  <p>Unfortunately I still have the same problem.</p>
  
  <p>Installation folder content:</p>
  
  <ul>
  <li>bin </li>
  <li>exp</li>
  <li>include</li>
  <li>lib</li>
  <li>changes.txt</li>
  <li>faq.txt</li>
  <li>libeay32.dll</li>
  <li>libssl.dll</li>
  <li>license.txt</li>
  <li>news.txt</li>
  <li>readme.txt</li>
  <li>ssleay32.dll</li>
  <li>unins000.dat</li>
  <li>unins000.exe</li>
  </ul>
  
  <p>Now I've tried to do somethings after I've read Qt documentation:
  <a href="https://doc.qt.io/qt-5/windows-requirements.html" rel="nofollow noreferrer">https://doc.qt.io/qt-5/windows-requirements.html</a></p>
  
  <ul>
  <li>I copy/paste the directory OpenSSL-Win64 in C:\Windows\System32 (according to the documentation the openSSL libraries are looked first in this directory)-> didn't work</li>
  <li>I've created a PATH environment variable and give it the value of the openSSL installation folder (for now I've use the 'Path' environment variable created by default, it has override the default value but I've manage to restore it)-> didn't work   </li>
  </ul>