Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
src_network_ssl_qsslsocket.cpp
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
3
4using namespace Qt::StringLiterals;
5
6//! [0]
7QSslSocket *socket = new QSslSocket(this);
8connect(socket, &QSslSocket::encrypted, this, &Receiver::ready);
9
10socket->connectToHostEncrypted("imap.example.com", 993);
11//! [0]
12
13
14//! [1]
15void SslServer::incomingConnection(qintptr socketDescriptor)
16{
17 QSslSocket *serverSocket = new QSslSocket;
18 if (serverSocket->setSocketDescriptor(socketDescriptor)) {
19 addPendingConnection(serverSocket);
20 connect(serverSocket, &QSslSocket::encrypted, this, &SslServer::ready);
21 serverSocket->startServerEncryption();
22 } else {
23 delete serverSocket;
24 }
25}
26//! [1]
27
28
29//! [2]
31socket.connectToHostEncrypted("http.example.com", 443);
32if (!socket.waitForEncrypted()) {
33 qDebug() << socket.errorString();
34 return false;
35}
36
37socket.write("GET / HTTP/1.0\r\n\r\n");
38while (socket.waitForReadyRead())
39 qDebug() << socket.readAll().data();
40//! [2]
41
42
43//! [3]
45connect(&socket, &QSslSocket::encrypted, receiver, &Receiver::socketEncrypted);
46
47socket.connectToHostEncrypted("imap", 993);
48socket->write("1 CAPABILITY\r\n");
49//! [3]
50
51
52//! [5]
53socket->connectToHostEncrypted("imap", 993);
54if (socket->waitForEncrypted(1000))
55 qDebug("Encrypted!");
56//! [5]
57
58//! [6]
59QList<QSslCertificate> cert = QSslCertificate::fromPath("server-certificate.pem"_L1);
60QSslError error(QSslError::SelfSignedCertificate, cert.at(0));
62expectedSslErrors.append(error);
63
65socket.ignoreSslErrors(expectedSslErrors);
66socket.connectToHostEncrypted("server.tld", 443);
67//! [6]
QJSValue error
connect(manager, &QNetworkAccessManager::finished, this, &MyClass::replyFinished)
QList< QSslCertificate > cert
[0]
QList< QSslError > expectedSslErrors
QSctpSocket * socket
[0]