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
ssl.qdoc
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
3
4/*!
5 \page ssl.html
6 \title Secure Sockets Layer (SSL) Classes
7 \brief Classes for secure communication over network sockets.
8
9 \keyword SSL
10
11 The classes below provide support for secure network communication using
12 the Secure Sockets Layer (SSL) protocol, using a native TLS backend,
13 the \l{OpenSSL Toolkit}, or any appropriate TLS plugin to perform encryption
14 and protocol handling.
15
16 \annotatedlist ssl
17
18 For Android applications see \l{Adding OpenSSL Support for Android}.
19
20 \section1 Using Encryption in Networked Applications
21
22 Use encryption when transporting data on any network whenever possible.
23 \e Plaintext, which is unencrypted data that is easily readable, exposes
24 sensitive data such as user information and information about network
25 systems.
26
27 Use QSslSocket::connectToHostEncrypted() to connect using encryption and
28 check for SSL issues using QSslSocket::sslHandshakeErrors(). Use
29 QSslSocket::ignoreSslErrors() with caution as it will create security risks
30 in your application.
31
32 Use QSslConfiguration to enforce strong security settings. The supported
33 protocols depend on the SSL backend and the risk level of a protocol could
34 change in the future. You can use a newer and more secure protocol using
35 QSslConfiguration::setProtocol(). For more information, refer to
36 QSsl::SslProtocol for the available protocols.
37
38
39 \section1 Enabling and Disabling SSL Support when Building Qt from Source
40
41 When building Qt from source, Qt builds plugins for native TLS libraries
42 that are supported for the operating system you are building for. For
43 Windows this means
44 \l{https://docs.microsoft.com/en-us/windows/win32/com/schannel}{Schannel},
45 while for macOS this is
46 \l{https://developer.apple.com/documentation/security/secure_transport}{Secure Transport}.
47
48 On all platforms, the configuration system checks for the presence of the
49 \c{openssl/opensslv.h} header provided by source or developer packages
50 of OpenSSL. If found, it will enable and build the OpenSSL backend for Qt.
51
52 \note While Qt can still support the older OpenSSL 1.1.1 version when built
53 from sources, the builds of Qt in the \l{Qt Online Installer} require
54 OpenSSL 3 at runtime.
55
56 By default, an OpenSSL-enabled Qt library dynamically loads any installed
57 OpenSSL library at run-time. However, it is possible to link against the
58 library at compile-time by configuring Qt with the \c{-openssl-linked}
59 option.
60
61 When building a version of Qt linked against OpenSSL, Qt's build system will
62 use CMake's \c{FindOpenSSL} command to find OpenSSL in several standard
63 locations. You can set the CMake variable OPENSSL_ROOT_DIR to force a
64 specific location.
65
66 For example:
67 \code
68 configure -openssl-linked -- -D OPENSSL_ROOT_DIR=<openssl_dir>
69 \endcode
70
71 To disable SSL support in a Qt build, configure Qt with the \c{-no-openssl}
72 option.
73
74 \section1 Considerations While Packaging Your Application
75
76 When you package your application, you may run a tool like \l{windeployqt}. This
77 copies all the plugins for the libraries you use to the \c{plugins/} folder.
78 However, for TLS you only need one backend, and you may delete the other
79 plugins before packaging your application. For example, if you're on Windows
80 and don't require any of the extra features the OpenSSL backend provides,
81 you can choose to forego shipping the \c{qopensslbackend} plugin as well as
82 the OpenSSL library, and simply ship the \c{qschannelbackend} plugin.
83
84 However, shipping multiple backends is not a problem. Qt will
85 attempt to load the backends in order (with OpenSSL attempted first) until
86 one is successfully loaded. The other backends are then unused.
87
88 \section1 Datagram Transport Layer Security
89
90 Datagram Transport Layer Security (DTLS) is a protocol that enables security
91 for datagram-based applications, providing them with protection against
92 eavesdropping, tampering, or message forgery. The DTLS protocol is based on the
93 stream-oriented Transport Layer Security (TLS) protocol. QtNetwork enables
94 the use of DTLS with User Datagram Protocol (UDP), as defined by
95 \l {RFC 6347}.
96
97 \section1 Import and Export Restrictions
98
99 Import and export restrictions apply for some types of software, and for
100 some parts of the world. Developers wishing to use SSL communication in
101 their deployed applications should either ensure that their users have the
102 appropriate libraries installed, or they should consult a suitably
103 qualified legal professional to ensure that applications using code from
104 the OpenSSL project are correctly certified for import and export in
105 relevant regions of the world.
106
107 Refer to \l{Export Control of Qt Framework and Tools} for more information.
108*/