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. How to make Secure WebSocket Server doesn't verify clients

How to make Secure WebSocket Server doesn't verify clients

Scheduled Pinned Locked Moved Unsolved General and Desktop
1 Posts 1 Posters 552 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.
  • I Offline
    I Offline
    igsk
    wrote on last edited by
    #1

    Hello,

    I have a trouble with verification via WSS on server side. I need server doesn't ask for certificate, as client can connect from different https domains.
    server code:

    m_pWebSocketServer(Q_NULLPTR)
    {
        m_pWebSocketServer = new QWebSocketServer(QStringLiteral("SSL Echo Server"),
                                                  QWebSocketServer::SecureMode,
                                                  this);
        QFile certFile(QStringLiteral("d:\\Qt\\test_proects\\build-SSLWebSocketServer-Desktop_Qt_5_9_1_MinGW_32bit-Debug\\debug\\localhost.cert"));
        QFile keyFile(QStringLiteral("d:\\Qt\\test_proects\\build-SSLWebSocketServer-Desktop_Qt_5_9_1_MinGW_32bit-Debug\\debug\\localhost.key"));
        certFile.open(QIODevice::ReadOnly);
        keyFile.open(QIODevice::ReadOnly);
        QSslCertificate certificate(&certFile, QSsl::Pem);
        QSslKey sslKey(&keyFile, QSsl::Rsa, QSsl::Pem);
        certFile.close();
        keyFile.close();
    
        QSslConfiguration sslConfiguration = QSslConfiguration::defaultConfiguration();
        sslConfiguration.setPeerVerifyMode(QSslSocket::VerifyNone);
        sslConfiguration.setLocalCertificate(certificate);
        sslConfiguration.setPrivateKey(sslKey);
        sslConfiguration.setProtocol(QSsl::AnyProtocol);
    
        m_pWebSocketServer->setSslConfiguration(sslConfiguration);
    
        if (m_pWebSocketServer->listen(QHostAddress::Any, port))
        {
            qDebug() << "SSL Echo Server listening on port" << port;
            connect(m_pWebSocketServer, &QWebSocketServer::newConnection,
                    this, &SslEchoServer::onNewConnection);
            connect(m_pWebSocketServer, &QWebSocketServer::sslErrors,
                    this, &SslEchoServer::onSslErrors);
            connect(m_pWebSocketServer, &QWebSocketServer::peerVerifyError,
                    this, &SslEchoServer::onPeerVerifyError);
            connect(m_pWebSocketServer, &QWebSocketServer::acceptError,
                    this, &SslEchoServer::onAcceptError);
        }
    

    On my client in the browser I get the error:
    WebSocket connection to 'wss://...' failed: Error in connection establishment: net::ERR_INSECURE_RESPONSE

    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