QWebSocket не подключается по TLS - PullRequest
0 голосов
/ 20 апреля 2020

У меня есть WebSocket, который хорошо работает по протоколу WebSocket, но я не могу переключиться на протокол WebSocketSecure. Он не генерирует никаких ошибок на стороне сервера, говорит клиент error:141970DF:SSL routines:tls_construct_cke_psk_preamble:psk identity not found. Сертификат был сгенерирован certbot и используется для веб-сайта https на том же домене.

Код сервера:

    QSslConfiguration conf = server.sslConfiguration();
    QFile * privkey =
      new QFile{"/etc/letsencrypt/live/example.com/privkey.pem"};

    privkey->open(QFile::ReadOnly);

    conf.setCaCertificates(QSslCertificate::fromPath(
      "/etc/letsencrypt/live/example.com/fullchain.pem"));
    conf.setPrivateKey(QSslKey(privkey));
    conf.setProtocol(QSsl::TlsV1_0);

    server.setSslConfiguration(conf);

    if (server.listen(QHostAddress::Any, 54045)) {
        connect(
          &server, &QWebSocketServer::newConnection, this,
          &Server::onNewConnection);
        connect(&server, &QWebSocketServer::closed, this, &Server::closed);
        qDebug() << "server started";
    }

Код клиента:

import QtQuick 2.13
import QtWebSockets 1.13

WebSocket {
    active: true
    url: "wss://example.com:54045"
}

Вывод openSSL:

$ openssl s_client -connect example.com:54045
CONNECTED(00000003)
140623606740288:error:14095126:SSL routines:ssl3_read_n:unexpected eof while reading:ssl/record/rec_layer_s3.c:302:
---
no peer certificate available
---
No client certificate CA names sent
---
SSL handshake has read 0 bytes and written 325 bytes
Verification: OK
---
New, (NONE), Cipher is (NONE)
Secure Renegotiation IS NOT supported
Compression: NONE
Expansion: NONE
No ALPN negotiated
Early data was not sent
Verify return code: 0 (ok)
---

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...