Qt 6.x
The Qt SDK
Loading...
Searching...
No Matches
qsslsocket_openssl_symbols.cpp
Go to the documentation of this file.
1// Copyright (C) 2017 The Qt Company Ltd.
2// Copyright (C) 2014 BlackBerry Limited. All rights reserved.
3// Copyright (C) 2016 Richard J. Moore <rich@kde.org>
4// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
5
6/****************************************************************************
7**
8** In addition, as a special exception, the copyright holders listed above give
9** permission to link the code of its release of Qt with the OpenSSL project's
10** "OpenSSL" library (or modified versions of the "OpenSSL" library that use the
11** same license as the original version), and distribute the linked executables.
12**
13** You must comply with the GNU General Public License version 2 in all
14** respects for all of the code used other than the "OpenSSL" code. If you
15** modify this file, you may extend this exception to your version of the file,
16** but you are not obligated to do so. If you do not wish to do so, delete
17** this exception statement from your version of this file.
18**
19****************************************************************************/
20
23
24#include <QtNetwork/private/qssl_p.h>
25
26#ifdef Q_OS_WIN
27# include <QtCore/private/qsystemlibrary_p.h>
28#elif QT_CONFIG(library)
29# include <QtCore/qlibrary.h>
30#endif
31#include <QtCore/qdatetime.h>
32#if defined(Q_OS_UNIX)
33#include <QtCore/qdir.h>
34#endif
35#include <QtCore/private/qduplicatetracker_p.h>
36#if defined(Q_OS_LINUX) && !defined(Q_OS_ANDROID)
37#include <link.h>
38#endif
39#ifdef Q_OS_DARWIN
40#include <QtCore/private/qcore_mac_p.h>
41#endif
42
43#include <algorithm>
44
46
47using namespace Qt::StringLiterals;
48
49/*
50 Note to maintainer:
51 -------------------
52
53 We load OpenSSL symbols dynamically. Because symbols are known to
54 disappear, and signatures sometimes change, between releases, we need to
55 be careful about how this is done. To ensure we don't end up dereferencing
56 null function pointers, and continue running even if certain functions are
57 missing, we define helper functions for each of the symbols we load from
58 OpenSSL, all prefixed with "q_" (declared in
59 qsslsocket_openssl_symbols_p.h). So instead of calling SSL_connect
60 directly, we call q_SSL_connect, which is a function that checks if the
61 actual SSL_connect fptr is null, and returns a failure if it is, or calls
62 SSL_connect if it isn't.
63
64 This requires a somewhat tedious process of declaring each function we
65 want to call in OpenSSL thrice: once with the q_, in _p.h, once using the
66 DEFINEFUNC macros below, and once in the function that actually resolves
67 the symbols, below the DEFINEFUNC declarations below.
68
69 There's one DEFINEFUNC macro declared for every number of arguments
70 exposed by OpenSSL (feel free to extend when needed). The easiest thing to
71 do is to find an existing entry that matches the arg count of the function
72 you want to import, and do the same.
73
74 The first macro arg is the function return type. The second is the
75 verbatim name of the function/symbol. Then follows a list of N pairs of
76 argument types with a variable name, and just the variable name (char *a,
77 a, char *b, b, etc). Finally there's two arguments - a suitable return
78 statement for the error case (for an int function, return 0 or return -1
79 is usually right). Then either just "return" or DUMMYARG, the latter being
80 for void functions.
81
82 Note: Take into account that these macros and declarations are processed
83 at compile-time, and the result depends on the OpenSSL headers the
84 compiling host has installed, but the symbols are resolved at run-time,
85 possibly with a different version of OpenSSL.
86*/
87
88#ifndef QT_LINKED_OPENSSL
89
90namespace {
91void qsslSocketUnresolvedSymbolWarning(const char *functionName)
92{
93 qCWarning(lcTlsBackend, "QSslSocket: cannot call unresolved function %s", functionName);
94}
95
96#if QT_CONFIG(library)
97void qsslSocketCannotResolveSymbolWarning(const char *functionName)
98{
99 qCWarning(lcTlsBackend, "QSslSocket: cannot resolve %s", functionName);
100}
101#endif
102
103}
104
105#endif // QT_LINKED_OPENSSL
106
107DEFINEFUNC(const unsigned char *, ASN1_STRING_get0_data, const ASN1_STRING *a, a, return nullptr, return)
108DEFINEFUNC2(int, OPENSSL_init_ssl, uint64_t opts, opts, const OPENSSL_INIT_SETTINGS *settings, settings, return 0, return)
109DEFINEFUNC2(int, OPENSSL_init_crypto, uint64_t opts, opts, const OPENSSL_INIT_SETTINGS *settings, settings, return 0, return)
110DEFINEFUNC(BIO *, BIO_new, const BIO_METHOD *a, a, return nullptr, return)
111DEFINEFUNC(const BIO_METHOD *, BIO_s_mem, void, DUMMYARG, return nullptr, return)
112DEFINEFUNC2(int, BN_is_word, BIGNUM *a, a, BN_ULONG w, w, return 0, return)
113DEFINEFUNC(int, EVP_CIPHER_CTX_reset, EVP_CIPHER_CTX *c, c, return 0, return)
114DEFINEFUNC(int, EVP_PKEY_up_ref, EVP_PKEY *a, a, return 0, return)
115DEFINEFUNC2(EVP_PKEY_CTX *, EVP_PKEY_CTX_new, EVP_PKEY *pkey, pkey, ENGINE *e, e, return nullptr, return)
116DEFINEFUNC(int, EVP_PKEY_param_check, EVP_PKEY_CTX *ctx, ctx, return 0, return)
117DEFINEFUNC(void, EVP_PKEY_CTX_free, EVP_PKEY_CTX *ctx, ctx, return, return)
118DEFINEFUNC(int, OPENSSL_sk_num, OPENSSL_STACK *a, a, return -1, return)
119DEFINEFUNC2(void, OPENSSL_sk_pop_free, OPENSSL_STACK *a, a, void (*b)(void*), b, return, DUMMYARG)
120DEFINEFUNC(OPENSSL_STACK *, OPENSSL_sk_new_null, DUMMYARG, DUMMYARG, return nullptr, return)
121DEFINEFUNC2(void, OPENSSL_sk_push, OPENSSL_STACK *a, a, void *b, b, return, DUMMYARG)
122DEFINEFUNC(void, OPENSSL_sk_free, OPENSSL_STACK *a, a, return, DUMMYARG)
123DEFINEFUNC2(void *, OPENSSL_sk_value, OPENSSL_STACK *a, a, int b, b, return nullptr, return)
124DEFINEFUNC(int, SSL_session_reused, SSL *a, a, return 0, return)
125DEFINEFUNC2(qssloptions, SSL_CTX_set_options, SSL_CTX *ctx, ctx, qssloptions op, op, return 0, return)
126using info_callback = void (*) (const SSL *ssl, int type, int val);
127DEFINEFUNC2(void, SSL_set_info_callback, SSL *ssl, ssl, info_callback cb, cb, return, return)
128DEFINEFUNC(const char *, SSL_alert_type_string, int value, value, return nullptr, return)
129DEFINEFUNC(const char *, SSL_alert_desc_string_long, int value, value, return nullptr, return)
130DEFINEFUNC(int, SSL_CTX_get_security_level, const SSL_CTX *ctx, ctx, return -1, return)
131DEFINEFUNC2(void, SSL_CTX_set_security_level, SSL_CTX *ctx, ctx, int level, level, return, return)
132#ifdef TLS1_3_VERSION
133DEFINEFUNC2(int, SSL_CTX_set_ciphersuites, SSL_CTX *ctx, ctx, const char *str, str, return 0, return)
134DEFINEFUNC2(void, SSL_set_psk_use_session_callback, SSL *ssl, ssl, q_SSL_psk_use_session_cb_func_t callback, callback, return, DUMMYARG)
135DEFINEFUNC2(void, SSL_CTX_sess_set_new_cb, SSL_CTX *ctx, ctx, NewSessionCallback cb, cb, return, return)
136DEFINEFUNC(int, SSL_SESSION_is_resumable, const SSL_SESSION *s, s, return 0, return)
137#endif
138DEFINEFUNC3(size_t, SSL_get_client_random, SSL *a, a, unsigned char *out, out, size_t outlen, outlen, return 0, return)
139DEFINEFUNC3(size_t, SSL_SESSION_get_master_key, const SSL_SESSION *ses, ses, unsigned char *out, out, size_t outlen, outlen, return 0, return)
140DEFINEFUNC6(int, CRYPTO_get_ex_new_index, int class_index, class_index, long argl, argl, void *argp, argp, CRYPTO_EX_new *new_func, new_func, CRYPTO_EX_dup *dup_func, dup_func, CRYPTO_EX_free *free_func, free_func, return -1, return)
141DEFINEFUNC2(unsigned long, SSL_set_options, SSL *ssl, ssl, unsigned long op, op, return 0, return)
142
143DEFINEFUNC(const SSL_METHOD *, TLS_method, DUMMYARG, DUMMYARG, return nullptr, return)
144DEFINEFUNC(const SSL_METHOD *, TLS_client_method, DUMMYARG, DUMMYARG, return nullptr, return)
145DEFINEFUNC(const SSL_METHOD *, TLS_server_method, DUMMYARG, DUMMYARG, return nullptr, return)
146DEFINEFUNC(void, X509_up_ref, X509 *a, a, return, DUMMYARG)
147DEFINEFUNC(ASN1_TIME *, X509_getm_notBefore, X509 *a, a, return nullptr, return)
148DEFINEFUNC(ASN1_TIME *, X509_getm_notAfter, X509 *a, a, return nullptr, return)
149DEFINEFUNC2(void, ASN1_item_free, ASN1_VALUE *val, val, const ASN1_ITEM *it, it, return, return)
150DEFINEFUNC(void, X509V3_conf_free, CONF_VALUE *val, val, return, return)
151DEFINEFUNC(long, X509_get_version, X509 *a, a, return -1, return)
152DEFINEFUNC(EVP_PKEY *, X509_get_pubkey, X509 *a, a, return nullptr, return)
153DEFINEFUNC2(void, X509_STORE_set_verify_cb, X509_STORE *a, a, X509_STORE_CTX_verify_cb verify_cb, verify_cb, return, DUMMYARG)
154DEFINEFUNC3(int, X509_STORE_set_ex_data, X509_STORE *a, a, int idx, idx, void *data, data, return 0, return)
155DEFINEFUNC2(void *, X509_STORE_get_ex_data, X509_STORE *r, r, int idx, idx, return nullptr, return)
156DEFINEFUNC(STACK_OF(X509) *, X509_STORE_CTX_get0_chain, X509_STORE_CTX *a, a, return nullptr, return)
157DEFINEFUNC3(void, CRYPTO_free, void *str, str, const char *file, file, int line, line, return, DUMMYARG)
158DEFINEFUNC3(int, CRYPTO_memcmp, const void * in_a, in_a, const void * in_b, in_b, size_t len, len, return 1, return);
159DEFINEFUNC(long, OpenSSL_version_num, void, DUMMYARG, return 0, return)
160DEFINEFUNC(const char *, OpenSSL_version, int a, a, return nullptr, return)
161DEFINEFUNC(unsigned long, SSL_SESSION_get_ticket_lifetime_hint, const SSL_SESSION *session, session, return 0, return)
162DEFINEFUNC4(void, DH_get0_pqg, const DH *dh, dh, const BIGNUM **p, p, const BIGNUM **q, q, const BIGNUM **g, g, return, DUMMYARG)
163
164#if QT_CONFIG(dtls)
165DEFINEFUNC2(int, DTLSv1_listen, SSL *s, s, BIO_ADDR *c, c, return -1, return)
166DEFINEFUNC(BIO_ADDR *, BIO_ADDR_new, DUMMYARG, DUMMYARG, return nullptr, return)
167DEFINEFUNC(void, BIO_ADDR_free, BIO_ADDR *ap, ap, return, DUMMYARG)
168DEFINEFUNC2(BIO_METHOD *, BIO_meth_new, int type, type, const char *name, name, return nullptr, return)
169DEFINEFUNC(void, BIO_meth_free, BIO_METHOD *biom, biom, return, DUMMYARG)
170DEFINEFUNC2(int, BIO_meth_set_write, BIO_METHOD *biom, biom, DgramWriteCallback write, write, return 0, return)
171DEFINEFUNC2(int, BIO_meth_set_read, BIO_METHOD *biom, biom, DgramReadCallback read, read, return 0, return)
172DEFINEFUNC2(int, BIO_meth_set_puts, BIO_METHOD *biom, biom, DgramPutsCallback puts, puts, return 0, return)
173DEFINEFUNC2(int, BIO_meth_set_ctrl, BIO_METHOD *biom, biom, DgramCtrlCallback ctrl, ctrl, return 0, return)
174DEFINEFUNC2(int, BIO_meth_set_create, BIO_METHOD *biom, biom, DgramCreateCallback crt, crt, return 0, return)
175DEFINEFUNC2(int, BIO_meth_set_destroy, BIO_METHOD *biom, biom, DgramDestroyCallback dtr, dtr, return 0, return)
176#endif // dtls
177
178#if QT_CONFIG(ocsp)
179DEFINEFUNC(const OCSP_CERTID *, OCSP_SINGLERESP_get0_id, const OCSP_SINGLERESP *x, x, return nullptr, return)
180DEFINEFUNC3(OCSP_RESPONSE *, d2i_OCSP_RESPONSE, OCSP_RESPONSE **a, a, const unsigned char **in, in, long len, len, return nullptr, return)
181DEFINEFUNC(void, OCSP_RESPONSE_free, OCSP_RESPONSE *rs, rs, return, DUMMYARG)
182DEFINEFUNC(OCSP_BASICRESP *, OCSP_response_get1_basic, OCSP_RESPONSE *resp, resp, return nullptr, return)
183DEFINEFUNC(void, OCSP_BASICRESP_free, OCSP_BASICRESP *bs, bs, return, DUMMYARG)
184DEFINEFUNC(int, OCSP_response_status, OCSP_RESPONSE *resp, resp, return OCSP_RESPONSE_STATUS_INTERNALERROR, return)
185DEFINEFUNC4(int, OCSP_basic_verify, OCSP_BASICRESP *bs, bs, STACK_OF(X509) *certs, certs, X509_STORE *st, st, unsigned long flags, flags, return -1, return)
186DEFINEFUNC(int, OCSP_resp_count, OCSP_BASICRESP *bs, bs, return 0, return)
187DEFINEFUNC2(OCSP_SINGLERESP *, OCSP_resp_get0, OCSP_BASICRESP *bs, bs, int idx, idx, return nullptr, return)
188DEFINEFUNC5(int, OCSP_single_get0_status, OCSP_SINGLERESP *single, single, int *reason, reason, ASN1_GENERALIZEDTIME **revtime, revtime,
189 ASN1_GENERALIZEDTIME **thisupd, thisupd, ASN1_GENERALIZEDTIME **nextupd, nextupd, return -1, return)
190DEFINEFUNC4(int, OCSP_check_validity, ASN1_GENERALIZEDTIME *thisupd, thisupd, ASN1_GENERALIZEDTIME *nextupd, nextupd, long nsec, nsec, long maxsec, maxsec, return 0, return)
191DEFINEFUNC3(OCSP_CERTID *, OCSP_cert_to_id, const EVP_MD *dgst, dgst, X509 *subject, subject, X509 *issuer, issuer, return nullptr, return)
192DEFINEFUNC(void, OCSP_CERTID_free, OCSP_CERTID *cid, cid, return, DUMMYARG)
193DEFINEFUNC5(int, OCSP_id_get0_info, ASN1_OCTET_STRING **piNameHash, piNameHash, ASN1_OBJECT **pmd, pmd,
194 ASN1_OCTET_STRING **piKeyHash, piKeyHash, ASN1_INTEGER **pserial, pserial, OCSP_CERTID *cid, cid,
195 return 0, return)
196DEFINEFUNC2(OCSP_RESPONSE *, OCSP_response_create, int status, status, OCSP_BASICRESP *bs, bs, return nullptr, return)
197DEFINEFUNC(const STACK_OF(X509) *, OCSP_resp_get0_certs, const OCSP_BASICRESP *bs, bs, return nullptr, return)
198DEFINEFUNC2(int, OCSP_id_cmp, OCSP_CERTID *a, a, OCSP_CERTID *b, b, return -1, return)
199DEFINEFUNC7(OCSP_SINGLERESP *, OCSP_basic_add1_status, OCSP_BASICRESP *r, r, OCSP_CERTID *c, c, int s, s,
200 int re, re, ASN1_TIME *rt, rt, ASN1_TIME *t, t, ASN1_TIME *n, n, return nullptr, return)
201DEFINEFUNC(OCSP_BASICRESP *, OCSP_BASICRESP_new, DUMMYARG, DUMMYARG, return nullptr, return)
202DEFINEFUNC2(int, i2d_OCSP_RESPONSE, OCSP_RESPONSE *r, r, unsigned char **ppout, ppout, return 0, return)
203DEFINEFUNC6(int, OCSP_basic_sign, OCSP_BASICRESP *br, br, X509 *signer, signer, EVP_PKEY *key, key,
204 const EVP_MD *dg, dg, STACK_OF(X509) *cs, cs, unsigned long flags, flags, return 0, return)
205#endif // ocsp
206
207DEFINEFUNC(void, AUTHORITY_INFO_ACCESS_free, AUTHORITY_INFO_ACCESS *p, p, return, return)
208DEFINEFUNC2(void, BIO_set_data, BIO *a, a, void *ptr, ptr, return, DUMMYARG)
209DEFINEFUNC(void *, BIO_get_data, BIO *a, a, return nullptr, return)
210DEFINEFUNC2(void, BIO_set_init, BIO *a, a, int init, init, return, DUMMYARG)
211DEFINEFUNC(int, BIO_get_shutdown, BIO *a, a, return -1, return)
212DEFINEFUNC2(void, BIO_set_shutdown, BIO *a, a, int shut, shut, return, DUMMYARG)
213
214DEFINEFUNC(long, ASN1_INTEGER_get, ASN1_INTEGER *a, a, return 0, return)
215DEFINEFUNC2(int, ASN1_INTEGER_cmp, const ASN1_INTEGER *a, a, const ASN1_INTEGER *b, b, return 1, return)
216DEFINEFUNC(int, ASN1_STRING_length, ASN1_STRING *a, a, return 0, return)
217DEFINEFUNC2(int, ASN1_STRING_to_UTF8, unsigned char **a, a, ASN1_STRING *b, b, return 0, return)
218DEFINEFUNC2(int, ASN1_TIME_to_tm, const ASN1_TIME *s, s, struct tm *tm, tm, return 0, return)
219DEFINEFUNC4(long, BIO_ctrl, BIO *a, a, int b, b, long c, c, void *d, d, return -1, return)
220DEFINEFUNC(int, BIO_free, BIO *a, a, return 0, return)
221DEFINEFUNC2(BIO *, BIO_new_mem_buf, void *a, a, int b, b, return nullptr, return)
222DEFINEFUNC3(int, BIO_read, BIO *a, a, void *b, b, int c, c, return -1, return)
223
224DEFINEFUNC3(int, BIO_write, BIO *a, a, const void *b, b, int c, c, return -1, return)
225DEFINEFUNC(int, BN_num_bits, const BIGNUM *a, a, return 0, return)
226DEFINEFUNC2(BN_ULONG, BN_mod_word, const BIGNUM *a, a, BN_ULONG w, w, return static_cast<BN_ULONG>(-1), return)
227DEFINEFUNC3(X509 *, d2i_X509, X509 **a, a, const unsigned char **b, b, long c, c, return nullptr, return)
228DEFINEFUNC2(char *, ERR_error_string, unsigned long a, a, char *b, b, return nullptr, return)
229DEFINEFUNC3(void, ERR_error_string_n, unsigned long e, e, char *b, b, size_t len, len, return, DUMMYARG)
230DEFINEFUNC(unsigned long, ERR_get_error, DUMMYARG, DUMMYARG, return 0, return)
231DEFINEFUNC(EVP_CIPHER_CTX *, EVP_CIPHER_CTX_new, void, DUMMYARG, return nullptr, return)
232DEFINEFUNC(void, EVP_CIPHER_CTX_free, EVP_CIPHER_CTX *a, a, return, DUMMYARG)
233DEFINEFUNC4(int, EVP_CIPHER_CTX_ctrl, EVP_CIPHER_CTX *ctx, ctx, int type, type, int arg, arg, void *ptr, ptr, return 0, return)
234DEFINEFUNC2(int, EVP_CIPHER_CTX_set_key_length, EVP_CIPHER_CTX *ctx, ctx, int keylen, keylen, return 0, return)
235DEFINEFUNC5(int, EVP_CipherInit, EVP_CIPHER_CTX *ctx, ctx, const EVP_CIPHER *type, type, const unsigned char *key, key, const unsigned char *iv, iv, int enc, enc, return 0, return)
236DEFINEFUNC6(int, EVP_CipherInit_ex, EVP_CIPHER_CTX *ctx, ctx, const EVP_CIPHER *cipher, cipher, ENGINE *impl, impl, const unsigned char *key, key, const unsigned char *iv, iv, int enc, enc, return 0, return)
237DEFINEFUNC5(int, EVP_CipherUpdate, EVP_CIPHER_CTX *ctx, ctx, unsigned char *out, out, int *outl, outl, const unsigned char *in, in, int inl, inl, return 0, return)
238DEFINEFUNC3(int, EVP_CipherFinal, EVP_CIPHER_CTX *ctx, ctx, unsigned char *out, out, int *outl, outl, return 0, return)
239DEFINEFUNC(const EVP_MD *, EVP_get_digestbyname, const char *name, name, return nullptr, return)
240#ifndef OPENSSL_NO_DES
241DEFINEFUNC(const EVP_CIPHER *, EVP_des_cbc, DUMMYARG, DUMMYARG, return nullptr, return)
242DEFINEFUNC(const EVP_CIPHER *, EVP_des_ede3_cbc, DUMMYARG, DUMMYARG, return nullptr, return)
243#endif
244#ifndef OPENSSL_NO_RC2
245DEFINEFUNC(const EVP_CIPHER *, EVP_rc2_cbc, DUMMYARG, DUMMYARG, return nullptr, return)
246#endif
247#ifndef OPENSSL_NO_AES
248DEFINEFUNC(const EVP_CIPHER *, EVP_aes_128_cbc, DUMMYARG, DUMMYARG, return nullptr, return)
249DEFINEFUNC(const EVP_CIPHER *, EVP_aes_192_cbc, DUMMYARG, DUMMYARG, return nullptr, return)
250DEFINEFUNC(const EVP_CIPHER *, EVP_aes_256_cbc, DUMMYARG, DUMMYARG, return nullptr, return)
251#endif
252DEFINEFUNC(const EVP_MD *, EVP_sha1, DUMMYARG, DUMMYARG, return nullptr, return)
253DEFINEFUNC(void, EVP_PKEY_free, EVP_PKEY *a, a, return, DUMMYARG)
254DEFINEFUNC(EVP_PKEY *, EVP_PKEY_new, DUMMYARG, DUMMYARG, return nullptr, return)
255DEFINEFUNC(int, EVP_PKEY_type, int a, a, return NID_undef, return)
256DEFINEFUNC2(int, i2d_X509, X509 *a, a, unsigned char **b, b, return -1, return)
257DEFINEFUNC(const char *, OBJ_nid2sn, int a, a, return nullptr, return)
258DEFINEFUNC(const char *, OBJ_nid2ln, int a, a, return nullptr, return)
259DEFINEFUNC(int, OBJ_sn2nid, const char *s, s, return 0, return)
260DEFINEFUNC(int, OBJ_ln2nid, const char *s, s, return 0, return)
261DEFINEFUNC3(int, i2t_ASN1_OBJECT, char *a, a, int b, b, ASN1_OBJECT *c, c, return -1, return)
262DEFINEFUNC4(int, OBJ_obj2txt, char *a, a, int b, b, ASN1_OBJECT *c, c, int d, d, return -1, return)
263DEFINEFUNC(int, OBJ_obj2nid, const ASN1_OBJECT *a, a, return NID_undef, return)
264DEFINEFUNC4(EVP_PKEY *, PEM_read_bio_PrivateKey, BIO *a, a, EVP_PKEY **b, b, pem_password_cb *c, c, void *d, d, return nullptr, return)
265
266DEFINEFUNC4(DH *, PEM_read_bio_DHparams, BIO *a, a, DH **b, b, pem_password_cb *c, c, void *d, d, return nullptr, return)
267DEFINEFUNC7(int, PEM_write_bio_PrivateKey, BIO *a, a, EVP_PKEY *b, b, const EVP_CIPHER *c, c, unsigned char *d, d, int e, e, pem_password_cb *f, f, void *g, g, return 0, return)
268DEFINEFUNC7(int, PEM_write_bio_PrivateKey_traditional, BIO *a, a, EVP_PKEY *b, b, const EVP_CIPHER *c, c, unsigned char *d, d, int e, e, pem_password_cb *f, f, void *g, g, return 0, return)
269DEFINEFUNC4(EVP_PKEY *, PEM_read_bio_PUBKEY, BIO *a, a, EVP_PKEY **b, b, pem_password_cb *c, c, void *d, d, return nullptr, return)
270DEFINEFUNC2(int, PEM_write_bio_PUBKEY, BIO *a, a, EVP_PKEY *b, b, return 0, return)
271DEFINEFUNC2(void, RAND_seed, const void *a, a, int b, b, return, DUMMYARG)
272DEFINEFUNC(int, RAND_status, void, DUMMYARG, return -1, return)
273DEFINEFUNC2(int, RAND_bytes, unsigned char *b, b, int n, n, return 0, return)
274DEFINEFUNC(int, SSL_accept, SSL *a, a, return -1, return)
275DEFINEFUNC(int, SSL_clear, SSL *a, a, return -1, return)
276DEFINEFUNC3(char *, SSL_CIPHER_description, const SSL_CIPHER *a, a, char *b, b, int c, c, return nullptr, return)
277DEFINEFUNC2(int, SSL_CIPHER_get_bits, const SSL_CIPHER *a, a, int *b, b, return 0, return)
278DEFINEFUNC(BIO *, SSL_get_rbio, const SSL *s, s, return nullptr, return)
279DEFINEFUNC(int, SSL_connect, SSL *a, a, return -1, return)
280DEFINEFUNC(int, SSL_CTX_check_private_key, const SSL_CTX *a, a, return -1, return)
281DEFINEFUNC4(long, SSL_CTX_ctrl, SSL_CTX *a, a, int b, b, long c, c, void *d, d, return -1, return)
282DEFINEFUNC(void, SSL_CTX_free, SSL_CTX *a, a, return, DUMMYARG)
283DEFINEFUNC(SSL_CTX *, SSL_CTX_new, const SSL_METHOD *a, a, return nullptr, return)
284DEFINEFUNC2(int, SSL_CTX_set_cipher_list, SSL_CTX *a, a, const char *b, b, return -1, return)
285DEFINEFUNC3(long, SSL_CTX_callback_ctrl, SSL_CTX *ctx, ctx, int dst, dst, GenericCallbackType cb, cb, return 0, return)
286DEFINEFUNC(int, SSL_CTX_set_default_verify_paths, SSL_CTX *a, a, return -1, return)
287DEFINEFUNC3(void, SSL_CTX_set_verify, SSL_CTX *a, a, int b, b, int (*c)(int, X509_STORE_CTX *), c, return, DUMMYARG)
288DEFINEFUNC2(void, SSL_CTX_set_verify_depth, SSL_CTX *a, a, int b, b, return, DUMMYARG)
289DEFINEFUNC2(int, SSL_CTX_use_certificate, SSL_CTX *a, a, X509 *b, b, return -1, return)
290DEFINEFUNC3(int, SSL_CTX_use_certificate_file, SSL_CTX *a, a, const char *b, b, int c, c, return -1, return)
291DEFINEFUNC2(int, SSL_CTX_use_PrivateKey, SSL_CTX *a, a, EVP_PKEY *b, b, return -1, return)
292DEFINEFUNC3(int, SSL_CTX_use_PrivateKey_file, SSL_CTX *a, a, const char *b, b, int c, c, return -1, return)
293DEFINEFUNC(X509_STORE *, SSL_CTX_get_cert_store, const SSL_CTX *a, a, return nullptr, return)
295DEFINEFUNC(void, SSL_CONF_CTX_free, SSL_CONF_CTX *a, a, return ,return);
296DEFINEFUNC2(void, SSL_CONF_CTX_set_ssl_ctx, SSL_CONF_CTX *a, a, SSL_CTX *b, b, return, return);
297DEFINEFUNC2(unsigned int, SSL_CONF_CTX_set_flags, SSL_CONF_CTX *a, a, unsigned int b, b, return 0, return);
298DEFINEFUNC(int, SSL_CONF_CTX_finish, SSL_CONF_CTX *a, a, return 0, return);
299DEFINEFUNC3(int, SSL_CONF_cmd, SSL_CONF_CTX *a, a, const char *b, b, const char *c, c, return 0, return);
300DEFINEFUNC(void, SSL_free, SSL *a, a, return, DUMMYARG)
301DEFINEFUNC(STACK_OF(SSL_CIPHER) *, SSL_get_ciphers, const SSL *a, a, return nullptr, return)
302DEFINEFUNC(const SSL_CIPHER *, SSL_get_current_cipher, SSL *a, a, return nullptr, return)
303DEFINEFUNC(int, SSL_version, const SSL *a, a, return 0, return)
304DEFINEFUNC2(int, SSL_get_error, SSL *a, a, int b, b, return -1, return)
305DEFINEFUNC(STACK_OF(X509) *, SSL_get_peer_cert_chain, SSL *a, a, return nullptr, return)
306
307#if defined(OPENSSL_VERSION_MAJOR) && OPENSSL_VERSION_MAJOR >= 3
308DEFINEFUNC(X509 *, SSL_get1_peer_certificate, SSL *a, a, return nullptr, return)
309DEFINEFUNC(int, EVP_PKEY_get_bits, const EVP_PKEY *pkey, pkey, return -1, return)
310DEFINEFUNC(int, EVP_PKEY_get_base_id, const EVP_PKEY *pkey, pkey, return -1, return)
311#else
312DEFINEFUNC(X509 *, SSL_get_peer_certificate, SSL *a, a, return nullptr, return)
313DEFINEFUNC(int, EVP_PKEY_base_id, EVP_PKEY *a, a, return NID_undef, return)
314#endif // OPENSSL_VERSION_MAJOR >= 3
315
316DEFINEFUNC(long, SSL_get_verify_result, const SSL *a, a, return -1, return)
317DEFINEFUNC(SSL *, SSL_new, SSL_CTX *a, a, return nullptr, return)
318DEFINEFUNC(SSL_CTX *, SSL_get_SSL_CTX, SSL *a, a, return nullptr, return)
319DEFINEFUNC4(long, SSL_ctrl, SSL *a, a, int cmd, cmd, long larg, larg, void *parg, parg, return -1, return)
320DEFINEFUNC3(int, SSL_read, SSL *a, a, void *b, b, int c, c, return -1, return)
321DEFINEFUNC3(void, SSL_set_bio, SSL *a, a, BIO *b, b, BIO *c, c, return, DUMMYARG)
322DEFINEFUNC(void, SSL_set_accept_state, SSL *a, a, return, DUMMYARG)
323DEFINEFUNC(void, SSL_set_connect_state, SSL *a, a, return, DUMMYARG)
324DEFINEFUNC(int, SSL_shutdown, SSL *a, a, return -1, return)
325DEFINEFUNC(int, SSL_in_init, const SSL *a, a, return 0, return)
326DEFINEFUNC(int, SSL_get_shutdown, const SSL *ssl, ssl, return 0, return)
327DEFINEFUNC2(int, SSL_set_session, SSL* to, to, SSL_SESSION *session, session, return -1, return)
328DEFINEFUNC(void, SSL_SESSION_free, SSL_SESSION *ses, ses, return, DUMMYARG)
329DEFINEFUNC(SSL_SESSION*, SSL_get1_session, SSL *ssl, ssl, return nullptr, return)
330DEFINEFUNC(SSL_SESSION*, SSL_get_session, const SSL *ssl, ssl, return nullptr, return)
331DEFINEFUNC3(int, SSL_set_ex_data, SSL *ssl, ssl, int idx, idx, void *arg, arg, return 0, return)
332DEFINEFUNC2(void *, SSL_get_ex_data, const SSL *ssl, ssl, int idx, idx, return nullptr, return)
333
334#ifndef OPENSSL_NO_PSK
335DEFINEFUNC2(void, SSL_set_psk_client_callback, SSL* ssl, ssl, q_psk_client_callback_t callback, callback, return, DUMMYARG)
336DEFINEFUNC2(void, SSL_set_psk_server_callback, SSL* ssl, ssl, q_psk_server_callback_t callback, callback, return, DUMMYARG)
337DEFINEFUNC2(int, SSL_CTX_use_psk_identity_hint, SSL_CTX* ctx, ctx, const char *hint, hint, return 0, return)
338#endif // !OPENSSL_NO_PSK
339
340DEFINEFUNC3(int, SSL_write, SSL *a, a, const void *b, b, int c, c, return -1, return)
341DEFINEFUNC2(int, X509_cmp, X509 *a, a, X509 *b, b, return -1, return)
342DEFINEFUNC4(int, X509_digest, const X509 *x509, x509, const EVP_MD *type, type, unsigned char *md, md, unsigned int *len, len, return -1, return)
343DEFINEFUNC(X509 *, X509_dup, X509 *a, a, return nullptr, return)
344DEFINEFUNC2(void, X509_print, BIO *a, a, X509 *b, b, return, DUMMYARG);
345DEFINEFUNC(ASN1_OBJECT *, X509_EXTENSION_get_object, X509_EXTENSION *a, a, return nullptr, return)
346DEFINEFUNC(void, X509_free, X509 *a, a, return, DUMMYARG)
347//Q_AUTOTEST_EXPORT ASN1_TIME *q_X509_gmtime_adj(ASN1_TIME *s, long adj);
348DEFINEFUNC2(ASN1_TIME *, X509_gmtime_adj, ASN1_TIME *s, s, long adj, adj, return nullptr, return)
349DEFINEFUNC(void, ASN1_TIME_free, ASN1_TIME *t, t, return, DUMMYARG)
350DEFINEFUNC2(X509_EXTENSION *, X509_get_ext, X509 *a, a, int b, b, return nullptr, return)
351DEFINEFUNC(int, X509_get_ext_count, X509 *a, a, return 0, return)
352DEFINEFUNC4(void *, X509_get_ext_d2i, X509 *a, a, int b, b, int *c, c, int *d, d, return nullptr, return)
353DEFINEFUNC(const X509V3_EXT_METHOD *, X509V3_EXT_get, X509_EXTENSION *a, a, return nullptr, return)
354DEFINEFUNC(void *, X509V3_EXT_d2i, X509_EXTENSION *a, a, return nullptr, return)
355DEFINEFUNC(int, X509_EXTENSION_get_critical, X509_EXTENSION *a, a, return 0, return)
356DEFINEFUNC(ASN1_OCTET_STRING *, X509_EXTENSION_get_data, X509_EXTENSION *a, a, return nullptr, return)
357DEFINEFUNC(void, BASIC_CONSTRAINTS_free, BASIC_CONSTRAINTS *a, a, return, DUMMYARG)
358DEFINEFUNC(void, AUTHORITY_KEYID_free, AUTHORITY_KEYID *a, a, return, DUMMYARG)
359DEFINEFUNC(void, GENERAL_NAME_free, GENERAL_NAME *a, a, return, DUMMYARG)
360DEFINEFUNC2(int, ASN1_STRING_print, BIO *a, a, const ASN1_STRING *b, b, return 0, return)
361DEFINEFUNC2(int, X509_check_issued, X509 *a, a, X509 *b, b, return -1, return)
362DEFINEFUNC(X509_NAME *, X509_get_issuer_name, X509 *a, a, return nullptr, return)
363DEFINEFUNC(X509_NAME *, X509_get_subject_name, X509 *a, a, return nullptr, return)
364DEFINEFUNC(ASN1_INTEGER *, X509_get_serialNumber, X509 *a, a, return nullptr, return)
365DEFINEFUNC(int, X509_verify_cert, X509_STORE_CTX *a, a, return -1, return)
366DEFINEFUNC(int, X509_NAME_entry_count, X509_NAME *a, a, return 0, return)
367DEFINEFUNC2(X509_NAME_ENTRY *, X509_NAME_get_entry, X509_NAME *a, a, int b, b, return nullptr, return)
368DEFINEFUNC(ASN1_STRING *, X509_NAME_ENTRY_get_data, X509_NAME_ENTRY *a, a, return nullptr, return)
369DEFINEFUNC(ASN1_OBJECT *, X509_NAME_ENTRY_get_object, X509_NAME_ENTRY *a, a, return nullptr, return)
370DEFINEFUNC(EVP_PKEY *, X509_PUBKEY_get, X509_PUBKEY *a, a, return nullptr, return)
371DEFINEFUNC(void, X509_STORE_free, X509_STORE *a, a, return, DUMMYARG)
372DEFINEFUNC(X509_STORE *, X509_STORE_new, DUMMYARG, DUMMYARG, return nullptr, return)
373DEFINEFUNC2(int, X509_STORE_add_cert, X509_STORE *a, a, X509 *b, b, return 0, return)
374DEFINEFUNC(void, X509_STORE_CTX_free, X509_STORE_CTX *a, a, return, DUMMYARG)
375DEFINEFUNC4(int, X509_STORE_CTX_init, X509_STORE_CTX *a, a, X509_STORE *b, b, X509 *c, c, STACK_OF(X509) *d, d, return -1, return)
376DEFINEFUNC2(int, X509_STORE_CTX_set_purpose, X509_STORE_CTX *a, a, int b, b, return -1, return)
377DEFINEFUNC(int, X509_STORE_CTX_get_error, X509_STORE_CTX *a, a, return -1, return)
378DEFINEFUNC(int, X509_STORE_CTX_get_error_depth, X509_STORE_CTX *a, a, return -1, return)
379DEFINEFUNC(X509 *, X509_STORE_CTX_get_current_cert, X509_STORE_CTX *a, a, return nullptr, return)
380DEFINEFUNC(X509_STORE *, X509_STORE_CTX_get0_store, X509_STORE_CTX *ctx, ctx, return nullptr, return)
381DEFINEFUNC(X509_STORE_CTX *, X509_STORE_CTX_new, DUMMYARG, DUMMYARG, return nullptr, return)
382DEFINEFUNC2(void *, X509_STORE_CTX_get_ex_data, X509_STORE_CTX *ctx, ctx, int idx, idx, return nullptr, return)
383DEFINEFUNC(int, SSL_get_ex_data_X509_STORE_CTX_idx, DUMMYARG, DUMMYARG, return -1, return)
384
385#if OPENSSL_VERSION_MAJOR < 3
386DEFINEFUNC3(int, SSL_CTX_load_verify_locations, SSL_CTX *ctx, ctx, const char *CAfile, CAfile, const char *CApath, CApath, return 0, return)
387#else
388DEFINEFUNC2(int, SSL_CTX_load_verify_dir, SSL_CTX *ctx, ctx, const char *CApath, CApath, return 0, return)
389#endif // OPENSSL_VERSION_MAJOR
390
391DEFINEFUNC2(int, i2d_SSL_SESSION, SSL_SESSION *in, in, unsigned char **pp, pp, return 0, return)
392DEFINEFUNC3(SSL_SESSION *, d2i_SSL_SESSION, SSL_SESSION **a, a, const unsigned char **pp, pp, long length, length, return nullptr, return)
393
394#ifndef OPENSSL_NO_NEXTPROTONEG
395DEFINEFUNC6(int, SSL_select_next_proto, unsigned char **out, out, unsigned char *outlen, outlen,
396 const unsigned char *in, in, unsigned int inlen, inlen,
397 const unsigned char *client, client, unsigned int client_len, client_len,
398 return -1, return)
400 int (*cb) (SSL *ssl, unsigned char **out,
401 unsigned char *outlen,
402 const unsigned char *in,
403 unsigned int inlen, void *arg), cb,
405DEFINEFUNC3(void, SSL_get0_next_proto_negotiated, const SSL *s, s,
406 const unsigned char **data, data, unsigned *len, len, return, DUMMYARG)
407DEFINEFUNC3(int, SSL_set_alpn_protos, SSL *s, s, const unsigned char *protos, protos,
409DEFINEFUNC3(void, SSL_CTX_set_alpn_select_cb, SSL_CTX *s, s,
410 int (*cb) (SSL *ssl, const unsigned char **out,
411 unsigned char *outlen,
412 const unsigned char *in,
413 unsigned int inlen, void *arg), cb,
414 void *arg, arg, return, DUMMYARG)
415DEFINEFUNC3(void, SSL_get0_alpn_selected, const SSL *s, s, const unsigned char **data, data,
416 unsigned *len, len, return, DUMMYARG)
417#endif // !OPENSSL_NO_NEXTPROTONEG
418
419// DTLS:
420#if QT_CONFIG(dtls)
421DEFINEFUNC2(void, SSL_CTX_set_cookie_generate_cb, SSL_CTX *ctx, ctx, CookieGenerateCallback cb, cb, return, DUMMYARG)
422DEFINEFUNC2(void, SSL_CTX_set_cookie_verify_cb, SSL_CTX *ctx, ctx, CookieVerifyCallback cb, cb, return, DUMMYARG)
423DEFINEFUNC(const SSL_METHOD *, DTLS_server_method, DUMMYARG, DUMMYARG, return nullptr, return)
424DEFINEFUNC(const SSL_METHOD *, DTLS_client_method, DUMMYARG, DUMMYARG, return nullptr, return)
425#endif // dtls
426DEFINEFUNC2(void, BIO_set_flags, BIO *b, b, int flags, flags, return, DUMMYARG)
427DEFINEFUNC2(void, BIO_clear_flags, BIO *b, b, int flags, flags, return, DUMMYARG)
428DEFINEFUNC2(void *, BIO_get_ex_data, BIO *b, b, int idx, idx, return nullptr, return)
429DEFINEFUNC3(int, BIO_set_ex_data, BIO *b, b, int idx, idx, void *data, data, return -1, return)
430
431DEFINEFUNC3(void *, CRYPTO_malloc, size_t num, num, const char *file, file, int line, line, return nullptr, return)
432DEFINEFUNC(DH *, DH_new, DUMMYARG, DUMMYARG, return nullptr, return)
433DEFINEFUNC(void, DH_free, DH *dh, dh, return, DUMMYARG)
434DEFINEFUNC3(DH *, d2i_DHparams, DH**a, a, const unsigned char **pp, pp, long length, length, return nullptr, return)
435DEFINEFUNC2(int, i2d_DHparams, DH *a, a, unsigned char **p, p, return -1, return)
436DEFINEFUNC2(int, DH_check, DH *dh, dh, int *codes, codes, return 0, return)
437DEFINEFUNC3(BIGNUM *, BN_bin2bn, const unsigned char *s, s, int len, len, BIGNUM *ret, ret, return nullptr, return)
438
439#ifndef OPENSSL_NO_EC
440DEFINEFUNC2(size_t, EC_get_builtin_curves, EC_builtin_curve * r, r, size_t nitems, nitems, return 0, return)
441DEFINEFUNC(int, EC_curve_nist2nid, const char *name, name, return 0, return)
442#endif // OPENSSL_NO_EC
443
444DEFINEFUNC5(int, PKCS12_parse, PKCS12 *p12, p12, const char *pass, pass, EVP_PKEY **pkey, pkey, \
445 X509 **cert, cert, STACK_OF(X509) **ca, ca, return 1, return);
446DEFINEFUNC2(PKCS12 *, d2i_PKCS12_bio, BIO *bio, bio, PKCS12 **pkcs12, pkcs12, return nullptr, return);
447DEFINEFUNC(void, PKCS12_free, PKCS12 *pkcs12, pkcs12, return, DUMMYARG)
448
449#ifndef OPENSSL_NO_DEPRECATED_3_0
450
451DEFINEFUNC4(DSA *, PEM_read_bio_DSA_PUBKEY, BIO *a, a, DSA **b, b, pem_password_cb *c, c, void *d, d, return nullptr, return)
452DEFINEFUNC4(RSA *, PEM_read_bio_RSA_PUBKEY, BIO *a, a, RSA **b, b, pem_password_cb *c, c, void *d, d, return nullptr, return)
453DEFINEFUNC4(DSA *, PEM_read_bio_DSAPrivateKey, BIO *a, a, DSA **b, b, pem_password_cb *c, c, void *d, d, return nullptr, return)
454DEFINEFUNC4(RSA *, PEM_read_bio_RSAPrivateKey, BIO *a, a, RSA **b, b, pem_password_cb *c, c, void *d, d, return nullptr, return)
455
456DEFINEFUNC2(int, PEM_write_bio_DSA_PUBKEY, BIO *a, a, DSA *b, b, return 0, return)
457DEFINEFUNC2(int, PEM_write_bio_RSA_PUBKEY, BIO *a, a, RSA *b, b, return 0, return)
458DEFINEFUNC7(int, PEM_write_bio_DSAPrivateKey, BIO *a, a, DSA *b, b, const EVP_CIPHER *c, c, unsigned char *d, d, int e, e, pem_password_cb *f, f, void *g, g, return 0, return)
459DEFINEFUNC7(int, PEM_write_bio_RSAPrivateKey, BIO *a, a, RSA *b, b, const EVP_CIPHER *c, c, unsigned char *d, d, int e, e, pem_password_cb *f, f, void *g, g, return 0, return)
460
461DEFINEFUNC2(int, SSL_CTX_use_RSAPrivateKey, SSL_CTX *a, a, RSA *b, b, return -1, return)
462
463DEFINEFUNC(DSA *, DSA_new, DUMMYARG, DUMMYARG, return nullptr, return)
464DEFINEFUNC(void, DSA_free, DSA *a, a, return, DUMMYARG)
465
466DEFINEFUNC(RSA *, RSA_new, DUMMYARG, DUMMYARG, return nullptr, return)
467DEFINEFUNC(void, RSA_free, RSA *a, a, return, DUMMYARG)
468
469DEFINEFUNC(int, RSA_bits, RSA *a, a, return 0, return)
470DEFINEFUNC(int, DSA_bits, DSA *a, a, return 0, return)
471DEFINEFUNC(int, DH_bits, DH *dh, dh, return 0, return)
472
473DEFINEFUNC(DSA *, EVP_PKEY_get1_DSA, EVP_PKEY *a, a, return nullptr, return)
474DEFINEFUNC(RSA *, EVP_PKEY_get1_RSA, EVP_PKEY *a, a, return nullptr, return)
475DEFINEFUNC(DH *, EVP_PKEY_get1_DH, EVP_PKEY *a, a, return nullptr, return)
476
477DEFINEFUNC2(int, EVP_PKEY_cmp, const EVP_PKEY *a, a, const EVP_PKEY *b, b, return -1, return)
478DEFINEFUNC3(int, EVP_PKEY_assign, EVP_PKEY *a, a, int b, b, void *r, r, return -1, return)
479
480DEFINEFUNC2(int, EVP_PKEY_set1_RSA, EVP_PKEY *a, a, RSA *b, b, return -1, return)
481DEFINEFUNC2(int, EVP_PKEY_set1_DSA, EVP_PKEY *a, a, DSA *b, b, return -1, return)
482DEFINEFUNC2(int, EVP_PKEY_set1_DH, EVP_PKEY *a, a, DH *b, b, return -1, return)
483
484#ifndef OPENSSL_NO_EC
485
486DEFINEFUNC4(EC_KEY *, PEM_read_bio_EC_PUBKEY, BIO *a, a, EC_KEY **b, b, pem_password_cb *c, c, void *d, d, return nullptr, return)
487DEFINEFUNC4(EC_KEY *, PEM_read_bio_ECPrivateKey, BIO *a, a, EC_KEY **b, b, pem_password_cb *c, c, void *d, d, return nullptr, return)
488
489DEFINEFUNC2(int, PEM_write_bio_EC_PUBKEY, BIO *a, a, EC_KEY *b, b, return 0, return)
490DEFINEFUNC7(int, PEM_write_bio_ECPrivateKey, BIO *a, a, EC_KEY *b, b, const EVP_CIPHER *c, c, unsigned char *d, d, int e, e, pem_password_cb *f, f, void *g, g, return 0, return)
491
492DEFINEFUNC(const EC_GROUP*, EC_KEY_get0_group, const EC_KEY* k, k, return nullptr, return)
493DEFINEFUNC(int, EC_GROUP_get_degree, const EC_GROUP* g, g, return 0, return)
494
495DEFINEFUNC2(int, EVP_PKEY_set1_EC_KEY, EVP_PKEY *a, a, EC_KEY *b, b, return -1, return)
496DEFINEFUNC(EC_KEY *, EVP_PKEY_get1_EC_KEY, EVP_PKEY *a, a, return nullptr, return)
497
498DEFINEFUNC(EC_KEY *, EC_KEY_dup, const EC_KEY *ec, ec, return nullptr, return)
499DEFINEFUNC(EC_KEY *, EC_KEY_new_by_curve_name, int nid, nid, return nullptr, return)
500DEFINEFUNC(void, EC_KEY_free, EC_KEY *ecdh, ecdh, return, DUMMYARG)
501
502#endif // OPENSSL_NO_EC
503
504
505
506#endif
507
508#define RESOLVEFUNC(func) \
509 if (!(_q_##func = _q_PTR_##func(libs.ssl->resolve(#func))) \
510 && !(_q_##func = _q_PTR_##func(libs.crypto->resolve(#func)))) \
511 qsslSocketCannotResolveSymbolWarning(#func);
512
513#if !defined QT_LINKED_OPENSSL
514
515#if !QT_CONFIG(library)
517{
518 qCWarning(lcTlsBackend, "QSslSocket: unable to resolve symbols. Qt is configured without the "
519 "'library' feature, which means runtime resolving of libraries won't work.");
520 qCWarning(lcTlsBackend, "Either compile Qt statically or with support for runtime resolving "
521 "of libraries.");
522 return false;
523}
524#else
525
526# ifdef Q_OS_UNIX
527struct NumericallyLess
528{
529 typedef bool result_type;
530 result_type operator()(QStringView lhs, QStringView rhs) const
531 {
532 bool ok = false;
533 int b = 0;
534 int a = lhs.toInt(&ok);
535 if (ok)
536 b = rhs.toInt(&ok);
537 if (ok) {
538 // both toInt succeeded
539 return a < b;
540 } else {
541 // compare as strings;
542 return lhs < rhs;
543 }
544 }
545};
546
547struct LibGreaterThan
548{
549 typedef bool result_type;
550 result_type operator()(QStringView lhs, QStringView rhs) const
551 {
552 const auto lhsparts = lhs.split(u'.');
553 const auto rhsparts = rhs.split(u'.');
554 Q_ASSERT(lhsparts.size() > 1 && rhsparts.size() > 1);
555
556 // note: checking rhs < lhs, the same as lhs > rhs
557 return std::lexicographical_compare(rhsparts.begin() + 1, rhsparts.end(),
558 lhsparts.begin() + 1, lhsparts.end(),
559 NumericallyLess());
560 }
561};
562
563#if defined(Q_OS_LINUX) && !defined(Q_OS_ANDROID)
564static int dlIterateCallback(struct dl_phdr_info *info, size_t size, void *data)
565{
566 if (size < sizeof (info->dlpi_addr) + sizeof (info->dlpi_name))
567 return 1;
570 if (!path.isEmpty()) {
572 path = fi.absolutePath();
573 if (!path.isEmpty())
574 (void)paths->hasSeen(std::move(path));
575 }
576 return 0;
577}
578#endif
579
580static QStringList libraryPathList()
581{
583# ifdef Q_OS_DARWIN
584 paths = QString::fromLatin1(qgetenv("DYLD_LIBRARY_PATH")).split(u':', Qt::SkipEmptyParts);
585
586 // search in .app/Contents/Frameworks
587 UInt32 packageType;
588 CFBundleGetPackageInfo(CFBundleGetMainBundle(), &packageType, nullptr);
589 if (packageType == FOUR_CHAR_CODE('APPL')) {
590 QUrl bundleUrl = QUrl::fromCFURL(QCFType<CFURLRef>(CFBundleCopyBundleURL(CFBundleGetMainBundle())));
591 QUrl frameworksUrl = QUrl::fromCFURL(QCFType<CFURLRef>(CFBundleCopyPrivateFrameworksURL(CFBundleGetMainBundle())));
592 paths << bundleUrl.resolved(frameworksUrl).path();
593 }
594# else
595 paths = QString::fromLatin1(qgetenv("LD_LIBRARY_PATH")).split(u':', Qt::SkipEmptyParts);
596# endif
597 paths << "/lib"_L1 << "/usr/lib"_L1 << "/usr/local/lib"_L1;
598 paths << "/lib64"_L1 << "/usr/lib64"_L1 << "/usr/local/lib64"_L1;
599 paths << "/lib32"_L1 << "/usr/lib32"_L1 << "/usr/local/lib32"_L1;
600
601#if defined(Q_OS_ANDROID)
602 paths << "/system/lib"_L1;
603#elif defined(Q_OS_LINUX)
604 // discover paths of already loaded libraries
605 QDuplicateTracker<QString> loadedPaths;
606 dl_iterate_phdr(dlIterateCallback, &loadedPaths);
607 std::move(loadedPaths).appendTo(paths);
608#endif
609
610 return paths;
611}
612
614static QStringList findAllLibs(QLatin1StringView filter)
615{
616 const QStringList paths = libraryPathList();
617 QStringList found;
619
620 for (const QString &path : paths) {
621 QDir dir(path);
622 QStringList entryList = dir.entryList(filters, QDir::Files);
623
624 std::sort(entryList.begin(), entryList.end(), LibGreaterThan());
625 for (const QString &entry : std::as_const(entryList))
626 found << path + u'/' + entry;
627 }
628
629 return found;
630}
631
632static QStringList findAllLibSsl()
633{
634 return findAllLibs("libssl.*"_L1);
635}
636
637static QStringList findAllLibCrypto()
638{
639 return findAllLibs("libcrypto.*"_L1);
640}
641# endif
642
643#if (OPENSSL_VERSION_NUMBER >> 28) < 3
644#define QT_OPENSSL_VERSION "1_1"
645#elif OPENSSL_VERSION_MAJOR == 3 // Starting with 3.0 this define is available
646#define QT_OPENSSL_VERSION "3"
647#endif // > 3 intentionally left undefined
648
649#ifdef Q_OS_WIN
650
651struct LoadedOpenSsl {
652 std::unique_ptr<QSystemLibrary> ssl, crypto;
653};
654
655static bool tryToLoadOpenSslWin32Library(QLatin1StringView ssleay32LibName, QLatin1StringView libeay32LibName, LoadedOpenSsl &result)
656{
657 auto ssleay32 = std::make_unique<QSystemLibrary>(ssleay32LibName);
658 if (!ssleay32->load(false)) {
659 return FALSE;
660 }
661
662 auto libeay32 = std::make_unique<QSystemLibrary>(libeay32LibName);
663 if (!libeay32->load(false)) {
664 return FALSE;
665 }
666
667 result.ssl = std::move(ssleay32);
668 result.crypto = std::move(libeay32);
669 return TRUE;
670}
671
672static LoadedOpenSsl loadOpenSsl()
673{
674 LoadedOpenSsl result;
675
676 // With OpenSSL 1.1 the names have changed to libssl-1_1 and libcrypto-1_1 for builds using
677 // MSVC and GCC. For 3.0 the version suffix changed again, to just '3'.
678 // For non-x86 builds, an architecture suffix is also appended.
679
680#if defined(Q_PROCESSOR_X86_64)
681#define QT_SSL_SUFFIX "-x64"
682#elif defined(Q_PROCESSOR_ARM_64)
683#define QT_SSL_SUFFIX "-arm64"
684#elif defined(Q_PROCESSOR_ARM_32)
685#define QT_SSL_SUFFIX "-arm"
686#else
687#define QT_SSL_SUFFIX
688#endif
689
690 tryToLoadOpenSslWin32Library("libssl-" QT_OPENSSL_VERSION QT_SSL_SUFFIX ""_L1,
691 "libcrypto-" QT_OPENSSL_VERSION QT_SSL_SUFFIX ""_L1, result);
692
693#undef QT_SSL_SUFFIX
694 return result;
695}
696#else // !Q_OS_WIN:
697
698struct LoadedOpenSsl {
699 std::unique_ptr<QLibrary> ssl, crypto;
700};
701
702static LoadedOpenSsl loadOpenSsl()
703{
704 LoadedOpenSsl result = { std::make_unique<QLibrary>(), std::make_unique<QLibrary>() };
705
706# if defined(Q_OS_UNIX)
707 QLibrary * const libssl = result.ssl.get();
708 QLibrary * const libcrypto = result.crypto.get();
709
710 // Try to find the libssl library on the system.
711 //
712 // Up until Qt 4.3, this only searched for the "ssl" library at version -1, that
713 // is, libssl.so on most Unix systems. However, the .so file isn't present in
714 // user installations because it's considered a development file.
715 //
716 // The right thing to do is to load the library at the major version we know how
717 // to work with: the SHLIB_VERSION_NUMBER version (macro defined in opensslv.h)
718 //
719 // However, OpenSSL is a well-known case of binary-compatibility breakage. To
720 // avoid such problems, many system integrators and Linux distributions change
721 // the soname of the binary, letting the full version number be the soname. So
722 // we'll find libssl.so.0.9.7, libssl.so.0.9.8, etc. in the system. For that
723 // reason, we will search a few common paths (see findAllLibSsl() above) in hopes
724 // we find one that works.
725 //
726 // If that fails, for OpenSSL 1.0 we also try some fallbacks -- look up
727 // libssl.so with a hardcoded soname. The reason is QTBUG-68156: the binary
728 // builds of Qt happen (at the time of this writing) on RHEL machines,
729 // which change SHLIB_VERSION_NUMBER to a non-portable string. When running
730 // those binaries on the target systems, this code won't pick up
731 // libssl.so.MODIFIED_SHLIB_VERSION_NUMBER because it doesn't exist there.
732 // Given that the only 1.0 supported release (at the time of this writing)
733 // is 1.0.2, with soname "1.0.0", give that a try too. Note that we mandate
734 // OpenSSL >= 1.0.0 with a configure-time check, and OpenSSL has kept binary
735 // compatibility between 1.0.0 and 1.0.2.
736 //
737 // It is important, however, to try the canonical name and the unversioned name
738 // without going through the loop. By not specifying a path, we let the system
739 // dlopen(3) function determine it for us. This will include any DT_RUNPATH or
740 // DT_RPATH tags on our library header as well as other system-specific search
741 // paths. See the man page for dlopen(3) on your system for more information.
742
743#ifdef Q_OS_OPENBSD
745#endif
746#if defined(SHLIB_VERSION_NUMBER) && !defined(Q_OS_QNX) // on QNX, the libs are always libssl.so and libcrypto.so
747 // first attempt: the canonical name is libssl.so.<SHLIB_VERSION_NUMBER>
748 libssl->setFileNameAndVersion("ssl"_L1, SHLIB_VERSION_NUMBER ""_L1);
749 libcrypto->setFileNameAndVersion("crypto"_L1, SHLIB_VERSION_NUMBER ""_L1);
750 if (libcrypto->load() && libssl->load()) {
751 // libssl.so.<SHLIB_VERSION_NUMBER> and libcrypto.so.<SHLIB_VERSION_NUMBER> found
752 return result;
753 } else {
754 libssl->unload();
755 libcrypto->unload();
756 }
757#endif
758
759#ifndef Q_OS_DARWIN
760 // second attempt: find the development files libssl.so and libcrypto.so
761 //
762 // disabled on macOS/iOS:
763 // macOS's /usr/lib/libssl.dylib, /usr/lib/libcrypto.dylib will be picked up in the third
764 // attempt, _after_ <bundle>/Contents/Frameworks has been searched.
765 // iOS does not ship a system libssl.dylib, libcrypto.dylib in the first place.
766# if defined(Q_OS_ANDROID)
767 // OpenSSL 1.1.x must be suffixed otherwise it will use the system libcrypto.so libssl.so which on API-21 are OpenSSL 1.0 not 1.1
768 auto openSSLSuffix = [](const QByteArray &defaultSuffix = {}) {
769 auto suffix = qgetenv("ANDROID_OPENSSL_SUFFIX");
770 if (suffix.isEmpty())
771 return defaultSuffix;
772 return suffix;
773 };
774
775 static QString suffix = QString::fromLatin1(openSSLSuffix("_" QT_OPENSSL_VERSION));
776
777 libssl->setFileNameAndVersion("ssl"_L1 + suffix, -1);
778 libcrypto->setFileNameAndVersion("crypto"_L1 + suffix, -1);
779# else
780 libssl->setFileNameAndVersion("ssl"_L1, -1);
781 libcrypto->setFileNameAndVersion("crypto"_L1, -1);
782# endif
783 if (libcrypto->load() && libssl->load()) {
784 // libssl.so.0 and libcrypto.so.0 found
785 return result;
786 } else {
787 libssl->unload();
788 libcrypto->unload();
789 }
790#endif
791
792 // third attempt: loop on the most common library paths and find libssl
793 const QStringList sslList = findAllLibSsl();
794 const QStringList cryptoList = findAllLibCrypto();
795
796 for (const QString &crypto : cryptoList) {
797#ifdef Q_OS_DARWIN
798 // Clients should not load the unversioned libcrypto dylib as it does not have a stable ABI
799 if (crypto.endsWith("libcrypto.dylib"))
800 continue;
801#endif
802 libcrypto->setFileNameAndVersion(crypto, -1);
803 if (libcrypto->load()) {
804 QFileInfo fi(crypto);
805 QString version = fi.completeSuffix();
806
807 for (const QString &ssl : sslList) {
808 if (!ssl.endsWith(version))
809 continue;
810
811 libssl->setFileNameAndVersion(ssl, -1);
812
813 if (libssl->load()) {
814 // libssl.so.x and libcrypto.so.x found
815 return result;
816 } else {
817 libssl->unload();
818 }
819 }
820 }
821 libcrypto->unload();
822 }
823
824 // failed to load anything
825 result = {};
826 return result;
827
828# else
829 // not implemented for this platform yet
830 return result;
831# endif
832}
833#endif
834
836{
837 static bool symbolsResolved = []() {
838 LoadedOpenSsl libs = loadOpenSsl();
839 if (!libs.ssl || !libs.crypto) {
840 qCWarning(lcTlsBackend, "Failed to load libssl/libcrypto.");
841 return false;
842 }
843
844 RESOLVEFUNC(OPENSSL_init_ssl)
845 RESOLVEFUNC(OPENSSL_init_crypto)
846 RESOLVEFUNC(ASN1_STRING_get0_data)
847 RESOLVEFUNC(EVP_CIPHER_CTX_reset)
848 RESOLVEFUNC(AUTHORITY_INFO_ACCESS_free)
849 RESOLVEFUNC(EVP_PKEY_up_ref)
850 RESOLVEFUNC(EVP_PKEY_CTX_new)
851 RESOLVEFUNC(EVP_PKEY_param_check)
852 RESOLVEFUNC(EVP_PKEY_CTX_free)
853 RESOLVEFUNC(OPENSSL_sk_new_null)
854 RESOLVEFUNC(OPENSSL_sk_push)
855 RESOLVEFUNC(OPENSSL_sk_free)
856 RESOLVEFUNC(OPENSSL_sk_num)
857 RESOLVEFUNC(OPENSSL_sk_pop_free)
858 RESOLVEFUNC(OPENSSL_sk_value)
859 RESOLVEFUNC(DH_get0_pqg)
860 RESOLVEFUNC(SSL_CTX_set_options)
861 RESOLVEFUNC(SSL_set_info_callback)
862 RESOLVEFUNC(SSL_alert_type_string)
863 RESOLVEFUNC(SSL_alert_desc_string_long)
864 RESOLVEFUNC(SSL_CTX_get_security_level)
865 RESOLVEFUNC(SSL_CTX_set_security_level)
866#ifdef TLS1_3_VERSION
867 RESOLVEFUNC(SSL_CTX_set_ciphersuites)
868 RESOLVEFUNC(SSL_set_psk_use_session_callback)
869 RESOLVEFUNC(SSL_CTX_sess_set_new_cb)
870 RESOLVEFUNC(SSL_SESSION_is_resumable)
871#endif // TLS 1.3 or OpenSSL > 1.1.1
872
873 RESOLVEFUNC(SSL_get_client_random)
874 RESOLVEFUNC(SSL_SESSION_get_master_key)
875 RESOLVEFUNC(SSL_session_reused)
876 RESOLVEFUNC(SSL_get_session)
877 RESOLVEFUNC(SSL_set_options)
878 RESOLVEFUNC(CRYPTO_get_ex_new_index)
879 RESOLVEFUNC(TLS_method)
880 RESOLVEFUNC(TLS_client_method)
881 RESOLVEFUNC(TLS_server_method)
882 RESOLVEFUNC(X509_up_ref)
883 RESOLVEFUNC(X509_STORE_CTX_get0_chain)
884 RESOLVEFUNC(X509_getm_notBefore)
885 RESOLVEFUNC(X509_getm_notAfter)
886 RESOLVEFUNC(ASN1_item_free)
887 RESOLVEFUNC(X509V3_conf_free)
888 RESOLVEFUNC(X509_get_version)
889 RESOLVEFUNC(X509_get_pubkey)
890 RESOLVEFUNC(X509_STORE_set_verify_cb)
891 RESOLVEFUNC(X509_STORE_set_ex_data)
892 RESOLVEFUNC(X509_STORE_get_ex_data)
893 RESOLVEFUNC(CRYPTO_free)
894 RESOLVEFUNC(CRYPTO_memcmp)
895 RESOLVEFUNC(OpenSSL_version_num)
896 RESOLVEFUNC(OpenSSL_version)
897
898 if (!_q_OpenSSL_version || !_q_OpenSSL_version_num) {
899 // Apparently, we were built with OpenSSL 1.1 enabled but are now using
900 // a wrong library.
901 qCWarning(lcTlsBackend, "Incompatible version of OpenSSL");
902 return false;
903 }
904
905#if OPENSSL_VERSION_NUMBER >= 0x30000000
906 if (q_OpenSSL_version_num() < 0x30000000) {
907 qCWarning(lcTlsBackend, "Incompatible version of OpenSSL (built with OpenSSL >= 3.x, runtime version is < 3.x)");
908 return false;
909 }
910#else
911 if (q_OpenSSL_version_num() >= 0x30000000) {
912 qCWarning(lcTlsBackend, "Incompatible version of OpenSSL (built with OpenSSL 1.x, runtime version is >= 3.x)");
913 return false;
914 }
915#endif // OPENSSL_VERSION_NUMBER
916
917 RESOLVEFUNC(SSL_SESSION_get_ticket_lifetime_hint)
918
919#if QT_CONFIG(dtls)
920 RESOLVEFUNC(DTLSv1_listen)
921 RESOLVEFUNC(BIO_ADDR_new)
922 RESOLVEFUNC(BIO_ADDR_free)
923 RESOLVEFUNC(BIO_meth_new)
924 RESOLVEFUNC(BIO_meth_free)
925 RESOLVEFUNC(BIO_meth_set_write)
926 RESOLVEFUNC(BIO_meth_set_read)
927 RESOLVEFUNC(BIO_meth_set_puts)
928 RESOLVEFUNC(BIO_meth_set_ctrl)
929 RESOLVEFUNC(BIO_meth_set_create)
930 RESOLVEFUNC(BIO_meth_set_destroy)
931#endif // dtls
932
933#if QT_CONFIG(ocsp)
934 RESOLVEFUNC(OCSP_SINGLERESP_get0_id)
935 RESOLVEFUNC(d2i_OCSP_RESPONSE)
936 RESOLVEFUNC(OCSP_RESPONSE_free)
937 RESOLVEFUNC(OCSP_response_status)
938 RESOLVEFUNC(OCSP_response_get1_basic)
939 RESOLVEFUNC(OCSP_BASICRESP_free)
940 RESOLVEFUNC(OCSP_basic_verify)
941 RESOLVEFUNC(OCSP_resp_count)
942 RESOLVEFUNC(OCSP_resp_get0)
943 RESOLVEFUNC(OCSP_single_get0_status)
944 RESOLVEFUNC(OCSP_check_validity)
945 RESOLVEFUNC(OCSP_cert_to_id)
946 RESOLVEFUNC(OCSP_id_get0_info)
947 RESOLVEFUNC(OCSP_resp_get0_certs)
948 RESOLVEFUNC(OCSP_basic_sign)
949 RESOLVEFUNC(OCSP_response_create)
950 RESOLVEFUNC(i2d_OCSP_RESPONSE)
951 RESOLVEFUNC(OCSP_basic_add1_status)
952 RESOLVEFUNC(OCSP_BASICRESP_new)
953 RESOLVEFUNC(OCSP_CERTID_free)
954 RESOLVEFUNC(OCSP_cert_to_id)
955 RESOLVEFUNC(OCSP_id_cmp)
956#endif // ocsp
957
958 RESOLVEFUNC(BIO_set_data)
959 RESOLVEFUNC(BIO_get_data)
960 RESOLVEFUNC(BIO_set_init)
961 RESOLVEFUNC(BIO_get_shutdown)
962 RESOLVEFUNC(BIO_set_shutdown)
963 RESOLVEFUNC(ASN1_INTEGER_get)
964 RESOLVEFUNC(ASN1_INTEGER_cmp)
965 RESOLVEFUNC(ASN1_STRING_length)
966 RESOLVEFUNC(ASN1_STRING_to_UTF8)
967 RESOLVEFUNC(ASN1_TIME_to_tm)
968 RESOLVEFUNC(BIO_ctrl)
969 RESOLVEFUNC(BIO_free)
970 RESOLVEFUNC(BIO_new)
971 RESOLVEFUNC(BIO_new_mem_buf)
972 RESOLVEFUNC(BIO_read)
973 RESOLVEFUNC(BIO_s_mem)
974 RESOLVEFUNC(BIO_write)
975 RESOLVEFUNC(BIO_set_flags)
976 RESOLVEFUNC(BIO_clear_flags)
977 RESOLVEFUNC(BIO_set_ex_data)
978 RESOLVEFUNC(BIO_get_ex_data)
979 RESOLVEFUNC(BN_num_bits)
980 RESOLVEFUNC(BN_is_word)
981 RESOLVEFUNC(BN_mod_word)
982 RESOLVEFUNC(ERR_error_string)
983 RESOLVEFUNC(ERR_error_string_n)
984 RESOLVEFUNC(ERR_get_error)
985 RESOLVEFUNC(EVP_CIPHER_CTX_new)
986 RESOLVEFUNC(EVP_CIPHER_CTX_free)
987 RESOLVEFUNC(EVP_CIPHER_CTX_ctrl)
988 RESOLVEFUNC(EVP_CIPHER_CTX_set_key_length)
989 RESOLVEFUNC(EVP_CipherInit)
990 RESOLVEFUNC(EVP_CipherInit_ex)
991 RESOLVEFUNC(EVP_CipherUpdate)
992 RESOLVEFUNC(EVP_CipherFinal)
993 RESOLVEFUNC(EVP_get_digestbyname)
994#ifndef OPENSSL_NO_DES
995 RESOLVEFUNC(EVP_des_cbc)
996 RESOLVEFUNC(EVP_des_ede3_cbc)
997#endif
998#ifndef OPENSSL_NO_RC2
999 RESOLVEFUNC(EVP_rc2_cbc)
1000#endif
1001#ifndef OPENSSL_NO_AES
1002 RESOLVEFUNC(EVP_aes_128_cbc)
1003 RESOLVEFUNC(EVP_aes_192_cbc)
1004 RESOLVEFUNC(EVP_aes_256_cbc)
1005#endif
1006 RESOLVEFUNC(EVP_sha1)
1007 RESOLVEFUNC(EVP_PKEY_free)
1008 RESOLVEFUNC(EVP_PKEY_new)
1009 RESOLVEFUNC(EVP_PKEY_type)
1010 RESOLVEFUNC(OBJ_nid2sn)
1011 RESOLVEFUNC(OBJ_nid2ln)
1012 RESOLVEFUNC(OBJ_sn2nid)
1013 RESOLVEFUNC(OBJ_ln2nid)
1014 RESOLVEFUNC(i2t_ASN1_OBJECT)
1015 RESOLVEFUNC(OBJ_obj2txt)
1016 RESOLVEFUNC(OBJ_obj2nid)
1017 RESOLVEFUNC(PEM_read_bio_PrivateKey)
1018 RESOLVEFUNC(PEM_read_bio_DHparams)
1019 RESOLVEFUNC(PEM_write_bio_PrivateKey)
1020 RESOLVEFUNC(PEM_write_bio_PrivateKey_traditional)
1021 RESOLVEFUNC(PEM_read_bio_PUBKEY)
1022 RESOLVEFUNC(PEM_write_bio_PUBKEY)
1023 RESOLVEFUNC(RAND_seed)
1024 RESOLVEFUNC(RAND_status)
1025 RESOLVEFUNC(RAND_bytes)
1026 RESOLVEFUNC(SSL_CIPHER_description)
1027 RESOLVEFUNC(SSL_CIPHER_get_bits)
1028 RESOLVEFUNC(SSL_get_rbio)
1029 RESOLVEFUNC(SSL_CTX_check_private_key)
1030 RESOLVEFUNC(SSL_CTX_ctrl)
1031 RESOLVEFUNC(SSL_CTX_free)
1032 RESOLVEFUNC(SSL_CTX_new)
1033 RESOLVEFUNC(SSL_CTX_set_cipher_list)
1034 RESOLVEFUNC(SSL_CTX_callback_ctrl)
1035 RESOLVEFUNC(SSL_CTX_set_default_verify_paths)
1036 RESOLVEFUNC(SSL_CTX_set_verify)
1037 RESOLVEFUNC(SSL_CTX_set_verify_depth)
1038 RESOLVEFUNC(SSL_CTX_use_certificate)
1039 RESOLVEFUNC(SSL_CTX_use_certificate_file)
1040 RESOLVEFUNC(SSL_CTX_use_PrivateKey)
1041 RESOLVEFUNC(SSL_CTX_use_PrivateKey_file)
1042 RESOLVEFUNC(SSL_CTX_get_cert_store);
1044 RESOLVEFUNC(SSL_CONF_CTX_free);
1045 RESOLVEFUNC(SSL_CONF_CTX_set_ssl_ctx);
1046 RESOLVEFUNC(SSL_CONF_CTX_set_flags);
1047 RESOLVEFUNC(SSL_CONF_CTX_finish);
1048 RESOLVEFUNC(SSL_CONF_cmd);
1049 RESOLVEFUNC(SSL_accept)
1050 RESOLVEFUNC(SSL_clear)
1051 RESOLVEFUNC(SSL_connect)
1052 RESOLVEFUNC(SSL_free)
1053 RESOLVEFUNC(SSL_get_ciphers)
1054 RESOLVEFUNC(SSL_get_current_cipher)
1055 RESOLVEFUNC(SSL_version)
1056 RESOLVEFUNC(SSL_get_error)
1057 RESOLVEFUNC(SSL_get_peer_cert_chain)
1058
1059#if defined(OPENSSL_VERSION_MAJOR) && OPENSSL_VERSION_MAJOR >= 3
1060 RESOLVEFUNC(SSL_get1_peer_certificate)
1061 RESOLVEFUNC(EVP_PKEY_get_bits)
1062 RESOLVEFUNC(EVP_PKEY_get_base_id)
1063#else
1064 RESOLVEFUNC(SSL_get_peer_certificate)
1065 RESOLVEFUNC(EVP_PKEY_base_id)
1066#endif // OPENSSL_VERSION_MAJOR >= 3
1067
1068#ifndef OPENSSL_NO_DEPRECATED_3_0
1069 RESOLVEFUNC(EVP_PKEY_assign)
1070 RESOLVEFUNC(EVP_PKEY_cmp)
1071
1072 RESOLVEFUNC(EVP_PKEY_set1_RSA)
1073 RESOLVEFUNC(EVP_PKEY_set1_DSA)
1074 RESOLVEFUNC(EVP_PKEY_set1_DH)
1075
1076 RESOLVEFUNC(EVP_PKEY_get1_DSA)
1077 RESOLVEFUNC(EVP_PKEY_get1_RSA)
1078 RESOLVEFUNC(EVP_PKEY_get1_DH)
1079
1080 RESOLVEFUNC(PEM_read_bio_DSA_PUBKEY)
1081 RESOLVEFUNC(PEM_read_bio_RSA_PUBKEY)
1082 RESOLVEFUNC(PEM_read_bio_DSAPrivateKey)
1083 RESOLVEFUNC(PEM_read_bio_RSAPrivateKey)
1084
1085 RESOLVEFUNC(PEM_write_bio_DSA_PUBKEY)
1086 RESOLVEFUNC(PEM_write_bio_RSA_PUBKEY)
1087 RESOLVEFUNC(PEM_write_bio_DSAPrivateKey)
1088 RESOLVEFUNC(PEM_write_bio_RSAPrivateKey)
1089 RESOLVEFUNC(SSL_CTX_use_RSAPrivateKey)
1090
1091 RESOLVEFUNC(DSA_new)
1092 RESOLVEFUNC(DSA_free)
1093
1094 RESOLVEFUNC(RSA_new)
1095 RESOLVEFUNC(RSA_free)
1096
1097 RESOLVEFUNC(DH_bits)
1098 RESOLVEFUNC(DSA_bits)
1099 RESOLVEFUNC(RSA_bits)
1100
1101#ifndef OPENSSL_NO_EC
1102
1103 RESOLVEFUNC(EVP_PKEY_set1_EC_KEY)
1104 RESOLVEFUNC(EVP_PKEY_get1_EC_KEY)
1105 RESOLVEFUNC(PEM_read_bio_EC_PUBKEY)
1106 RESOLVEFUNC(PEM_read_bio_ECPrivateKey)
1107 RESOLVEFUNC(PEM_write_bio_EC_PUBKEY)
1108 RESOLVEFUNC(PEM_write_bio_ECPrivateKey)
1109 RESOLVEFUNC(EC_KEY_get0_group)
1110 RESOLVEFUNC(EC_GROUP_get_degree)
1111 RESOLVEFUNC(EC_KEY_dup)
1112 RESOLVEFUNC(EC_KEY_new_by_curve_name)
1113 RESOLVEFUNC(EC_KEY_free)
1114
1115#endif // OPENSSL_NO_EC
1116
1117#endif // OPENSSL_NO_DEPRECATED_3_0
1118
1119 RESOLVEFUNC(SSL_get_verify_result)
1120 RESOLVEFUNC(SSL_new)
1121 RESOLVEFUNC(SSL_get_SSL_CTX)
1122 RESOLVEFUNC(SSL_ctrl)
1123 RESOLVEFUNC(SSL_read)
1124 RESOLVEFUNC(SSL_set_accept_state)
1125 RESOLVEFUNC(SSL_set_bio)
1126 RESOLVEFUNC(SSL_set_connect_state)
1127 RESOLVEFUNC(SSL_shutdown)
1128 RESOLVEFUNC(SSL_in_init)
1129 RESOLVEFUNC(SSL_get_shutdown)
1130 RESOLVEFUNC(SSL_set_session)
1131 RESOLVEFUNC(SSL_SESSION_free)
1132 RESOLVEFUNC(SSL_get1_session)
1133 RESOLVEFUNC(SSL_get_session)
1134 RESOLVEFUNC(SSL_set_ex_data)
1135 RESOLVEFUNC(SSL_get_ex_data)
1136 RESOLVEFUNC(SSL_get_ex_data_X509_STORE_CTX_idx)
1137
1138#ifndef OPENSSL_NO_PSK
1139 RESOLVEFUNC(SSL_set_psk_client_callback)
1140 RESOLVEFUNC(SSL_set_psk_server_callback)
1141 RESOLVEFUNC(SSL_CTX_use_psk_identity_hint)
1142#endif // !OPENSSL_NO_PSK
1143
1144 RESOLVEFUNC(SSL_write)
1145 RESOLVEFUNC(X509_NAME_entry_count)
1146 RESOLVEFUNC(X509_NAME_get_entry)
1147 RESOLVEFUNC(X509_NAME_ENTRY_get_data)
1148 RESOLVEFUNC(X509_NAME_ENTRY_get_object)
1149 RESOLVEFUNC(X509_PUBKEY_get)
1150 RESOLVEFUNC(X509_STORE_free)
1151 RESOLVEFUNC(X509_STORE_new)
1152 RESOLVEFUNC(X509_STORE_add_cert)
1153 RESOLVEFUNC(X509_STORE_CTX_free)
1154 RESOLVEFUNC(X509_STORE_CTX_init)
1155 RESOLVEFUNC(X509_STORE_CTX_new)
1156 RESOLVEFUNC(X509_STORE_CTX_set_purpose)
1157 RESOLVEFUNC(X509_STORE_CTX_get_error)
1158 RESOLVEFUNC(X509_STORE_CTX_get_error_depth)
1159 RESOLVEFUNC(X509_STORE_CTX_get_current_cert)
1160 RESOLVEFUNC(X509_STORE_CTX_get0_store)
1161 RESOLVEFUNC(X509_cmp)
1162 RESOLVEFUNC(X509_STORE_CTX_get_ex_data)
1163 RESOLVEFUNC(X509_dup)
1164 RESOLVEFUNC(X509_print)
1165 RESOLVEFUNC(X509_digest)
1166 RESOLVEFUNC(X509_EXTENSION_get_object)
1167 RESOLVEFUNC(X509_free)
1168 RESOLVEFUNC(X509_gmtime_adj)
1169 RESOLVEFUNC(ASN1_TIME_free)
1170 RESOLVEFUNC(X509_get_ext)
1171 RESOLVEFUNC(X509_get_ext_count)
1172 RESOLVEFUNC(X509_get_ext_d2i)
1173 RESOLVEFUNC(X509V3_EXT_get)
1174 RESOLVEFUNC(X509V3_EXT_d2i)
1175 RESOLVEFUNC(X509_EXTENSION_get_critical)
1176 RESOLVEFUNC(X509_EXTENSION_get_data)
1177 RESOLVEFUNC(BASIC_CONSTRAINTS_free)
1178 RESOLVEFUNC(AUTHORITY_KEYID_free)
1179 RESOLVEFUNC(GENERAL_NAME_free)
1180 RESOLVEFUNC(ASN1_STRING_print)
1181 RESOLVEFUNC(X509_check_issued)
1182 RESOLVEFUNC(X509_get_issuer_name)
1183 RESOLVEFUNC(X509_get_subject_name)
1184 RESOLVEFUNC(X509_get_serialNumber)
1185 RESOLVEFUNC(X509_verify_cert)
1186 RESOLVEFUNC(d2i_X509)
1187 RESOLVEFUNC(i2d_X509)
1188#if OPENSSL_VERSION_MAJOR < 3
1189 RESOLVEFUNC(SSL_CTX_load_verify_locations)
1190#else
1191 RESOLVEFUNC(SSL_CTX_load_verify_dir)
1192#endif // OPENSSL_VERSION_MAJOR
1193 RESOLVEFUNC(i2d_SSL_SESSION)
1194 RESOLVEFUNC(d2i_SSL_SESSION)
1195
1196#ifndef OPENSSL_NO_NEXTPROTONEG
1197 RESOLVEFUNC(SSL_select_next_proto)
1199 RESOLVEFUNC(SSL_get0_next_proto_negotiated)
1201 RESOLVEFUNC(SSL_CTX_set_alpn_select_cb)
1203#endif // !OPENSSL_NO_NEXTPROTONEG
1204
1205#if QT_CONFIG(dtls)
1206 RESOLVEFUNC(SSL_CTX_set_cookie_generate_cb)
1207 RESOLVEFUNC(SSL_CTX_set_cookie_verify_cb)
1208 RESOLVEFUNC(DTLS_server_method)
1209 RESOLVEFUNC(DTLS_client_method)
1210#endif // dtls
1211
1212 RESOLVEFUNC(CRYPTO_malloc)
1213 RESOLVEFUNC(DH_new)
1214 RESOLVEFUNC(DH_free)
1215 RESOLVEFUNC(d2i_DHparams)
1216 RESOLVEFUNC(i2d_DHparams)
1217 RESOLVEFUNC(DH_check)
1218 RESOLVEFUNC(BN_bin2bn)
1219
1220#ifndef OPENSSL_NO_EC
1221 RESOLVEFUNC(EC_get_builtin_curves)
1222#endif // OPENSSL_NO_EC
1223
1224 RESOLVEFUNC(PKCS12_parse)
1225 RESOLVEFUNC(d2i_PKCS12_bio)
1226 RESOLVEFUNC(PKCS12_free)
1227 return true;
1228 }();
1229
1230 return symbolsResolved;
1231}
1232#endif // QT_CONFIG(library)
1233
1234#else // !defined QT_LINKED_OPENSSL
1235
1237{
1238#ifdef QT_NO_OPENSSL
1239 return false;
1240#endif
1241 return true;
1242}
1243#endif // !defined QT_LINKED_OPENSSL
1244
\inmodule QtCore
Definition qbytearray.h:57
\inmodule QtCore
Definition qdir.h:19
@ Files
Definition qdir.h:22
\inmodule QtCore \reentrant
Definition qfileinfo.h:22
QString completeSuffix() const
Returns the complete suffix (extension) of the file.
QString absolutePath() const
Returns a file's path absolute path.
\inmodule QtCore \reentrant
Definition qlibrary.h:17
bool load()
Loads the library and returns true if the library was loaded successfully; otherwise returns false.
Definition qlibrary.cpp:806
@ ExportExternalSymbolsHint
Definition qlibrary.h:24
void setFileNameAndVersion(const QString &fileName, int verNum)
Sets the fileName property and major version number to fileName and versionNumber respectively.
Definition qlibrary.cpp:969
bool unload()
Unloads the library and returns true if the library could be unloaded; otherwise returns false.
Definition qlibrary.cpp:834
void setLoadHints(LoadHints hints)
\inmodule QtCore
\inmodule QtCore
Definition qstringview.h:76
Q_CORE_EXPORT QList< QStringView > split(QStringView sep, Qt::SplitBehavior behavior=Qt::KeepEmptyParts, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Splits the view into substring views wherever sep occurs, and returns the list of those string views.
Definition qstring.cpp:7987
int toInt(bool *ok=nullptr, int base=10) const
Returns the string view converted to an int using base base, which is 10 by default and must be betwe...
Definition qstring.h:1025
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:127
static QString fromLatin1(QByteArrayView ba)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition qstring.cpp:5710
QStringList split(const QString &sep, Qt::SplitBehavior behavior=Qt::KeepEmptyParts, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Splits the string into substrings wherever sep occurs, and returns the list of those strings.
Definition qstring.cpp:7956
static QString fromLocal8Bit(QByteArrayView ba)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition qstring.cpp:5788
\inmodule QtCore
Definition qurl.h:94
QUrl resolved(const QUrl &relative) const
Returns the result of the merge of this URL with relative.
Definition qurl.cpp:2722
QString path(ComponentFormattingOptions options=FullyDecoded) const
Returns the path of the URL.
Definition qurl.cpp:2465
EGLContext ctx
QString str
[2]
double e
QSet< QString >::iterator it
Combined button and popup list for selecting options.
@ SkipEmptyParts
Definition qnamespace.h:127
#define Q_NEVER_INLINE
DBusConnection const char DBusError DBusBusType DBusError return DBusConnection DBusHandleMessageFunction void DBusFreeFunction return DBusConnection return DBusConnection return const char DBusError return DBusConnection DBusMessage dbus_uint32_t return DBusConnection dbus_bool_t DBusConnection DBusAddWatchFunction DBusRemoveWatchFunction DBusWatchToggledFunction void DBusFreeFunction return DBusConnection DBusDispatchStatusFunction void DBusFreeFunction DBusTimeout return DBusTimeout return DBusWatch return DBusWatch unsigned int return DBusError const DBusError return const DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessageIter int const void return DBusMessageIter DBusMessageIter return DBusMessageIter void DBusMessageIter void int return DBusMessage DBusMessageIter return DBusMessageIter return DBusMessageIter DBusMessageIter const char const char const char const char return DBusMessage return DBusMessage const char return DBusMessage dbus_bool_t return DBusMessage dbus_uint32_t return DBusMessage void
#define DEFINEFUNC(ret, func, args, argcall, funcret)
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
#define qCWarning(category,...)
return ret
static ControlElement< T > * ptr(QWidget *widget)
GLboolean GLboolean GLboolean b
GLint GLint GLint GLint GLint x
[0]
GLenum GLuint GLint level
GLuint64 key
GLfloat GLfloat GLfloat w
[0]
GLboolean GLboolean GLboolean GLboolean a
[7]
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLboolean r
[2]
GLenum GLuint GLenum GLsizei length
GLfloat GLfloat f
GLenum type
GLsizei const GLuint * paths
GLenum GLenum dst
GLbitfield flags
GLint GLint GLint GLint GLint GLint GLint GLbitfield GLenum filter
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLboolean GLboolean g
GLuint name
GLfloat n
const GLubyte * c
GLuint GLfloat * val
GLuint entry
GLenum GLsizei len
GLdouble GLdouble t
Definition qopenglext.h:243
GLuint in
GLdouble GLdouble GLdouble GLdouble q
Definition qopenglext.h:259
GLsizei const GLchar *const * path
GLuint64EXT * result
[6]
GLdouble s
[6]
Definition qopenglext.h:235
GLfloat GLfloat p
[1]
GLuint num
#define Q_ASSERT(cond)
Definition qrandom.cpp:47
SSL_CTX int(*) void arg)
bool q_resolveOpenSslSymbols()
SSL_CTX int(* cb)(SSL *ssl, unsigned char **out, unsigned char *outlen, const unsigned char *in, unsigned int inlen, void *arg)
SSL_CTX int(*) void DUMMYAR SSL_set_alpn_protos)
SSL_CTX int(*) void DUMMYARG SSL const unsigned char protos)
#define RESOLVEFUNC(func)
SSL_CTX int(*) void DUMMYAR DEFINEFUNC3)(void, SSL_get0_next_proto_negotiated, const SSL *s, s, const unsigned char **data, data, unsigned *len, len, return, DUMMYARG) DEFINEFUNC3(int
SSL_CTX int(*) void DUMMYARG SSL const unsigned char unsigned retur SSL_get0_alpn_selected)
SSL_CTX int(*) void DUMMYARG SSL const unsigned char unsigned return const SSL const unsigned char unsigned DUMMYAR DEFINEFUNC5)(int, PKCS12_parse, PKCS12 *p12, p12, const char *pass, pass, EVP_PKEY **pkey, pkey, X509 **cert, cert, STACK_OF(X509) **ca, ca, return 1, return)
SSL_CTX int(*) void DUMMYARG SSL const unsigned char unsigne protos_len)
#define DEFINEFUNC4(ret, func, arg1, a, arg2, b, arg3, c, arg4, d, err, funcret)
unsigned long qssloptions
unsigned int(* q_psk_server_callback_t)(SSL *ssl, const char *identity, unsigned char *psk, unsigned int max_psk_len)
void(* GenericCallbackType)()
#define DEFINEFUNC7(ret, func, arg1, a, arg2, b, arg3, c, arg4, d, arg5, e, arg6, f, arg7, g, err, funcret)
#define DEFINEFUNC2(ret, func, arg1, a, arg2, b, err, funcret)
int(* q_SSL_psk_use_session_cb_func_t)(SSL *, const EVP_MD *, const unsigned char **, size_t *, SSL_SESSION **)
STACK_OF(X509) *q_X509_STORE_CTX_get0_chain(X509_STORE_CTX *ctx)
#define DEFINEFUNC6(ret, func, arg1, a, arg2, b, arg3, c, arg4, d, arg5, e, arg6, f, err, funcret)
unsigned int(* q_psk_client_callback_t)(SSL *ssl, const char *hint, char *identity, unsigned int max_identity_len, unsigned char *psk, unsigned int max_psk_len)
long q_OpenSSL_version_num()
static QT_BEGIN_NAMESPACE QVariant hint(QPlatformIntegration::StyleHint h)
Q_CORE_EXPORT QByteArray qgetenv(const char *varName)
static QT_BEGIN_NAMESPACE void init(QTextBoundaryFinder::BoundaryType type, QStringView str, QCharAttributes *attributes)
ReturnedValue read(const char *data)
QFile file
[0]
QFileInfo info(fileName)
[8]
QFileInfo fi("c:/temp/foo")
[newstuff]
gzip write("uncompressed data")
QSettings settings("MySoft", "Star Runner")
[0]
QTextStream out(stdout)
[7]
QString dir
[11]
const QStringList filters({"Image files (*.png *.xpm *.jpg)", "Text files (*.txt)", "Any files (*)" })
[6]
QList< QSslCertificate > cert
[0]
const auto certs
[1]