60 #include <QtNetwork/private/qssl_p.h>
63 # include <QtCore/private/qsystemlibrary_p.h>
64 #elif QT_CONFIG(library)
65 # include <QtCore/qlibrary.h>
67 #include <QtCore/qmutex.h>
68 #include <QtCore/qdatetime.h>
69 #if defined(Q_OS_UNIX)
70 #include <QtCore/qdir.h>
72 #include <QtCore/private/qduplicatetracker_p.h>
73 #if defined(Q_OS_LINUX) && !defined(Q_OS_ANDROID)
77 #include <QtCore/private/qcore_mac_p.h>
123 #ifndef QT_LINKED_OPENSSL
128 qCWarning(lcTlsBackend,
"QSslSocket: cannot call unresolved function %s", functionName);
131 #if QT_CONFIG(library)
132 void qsslSocketCannotResolveSymbolWarning(
const char *functionName)
134 qCWarning(lcTlsBackend,
"QSslSocket: cannot resolve %s", functionName);
142 DEFINEFUNC(
const unsigned char *, ASN1_STRING_get0_data,
const ASN1_STRING *
a,
a,
return nullptr,
return)
145 DEFINEFUNC(BIO *, BIO_new,
const BIO_METHOD *
a,
a,
return nullptr,
return)
147 DEFINEFUNC2(
int, BN_is_word, BIGNUM *
a,
a, BN_ULONG
w,
w,
return 0,
return)
148 DEFINEFUNC(
int, EVP_CIPHER_CTX_reset, EVP_CIPHER_CTX *
c,
c,
return 0,
return)
149 DEFINEFUNC(
int, EVP_PKEY_up_ref, EVP_PKEY *
a,
a,
return 0,
return)
150 DEFINEFUNC2(EVP_PKEY_CTX *, EVP_PKEY_CTX_new, EVP_PKEY *pkey, pkey, ENGINE *
e,
e,
return nullptr,
return)
151 DEFINEFUNC(
int, EVP_PKEY_param_check, EVP_PKEY_CTX *ctx, ctx,
return 0,
return)
152 DEFINEFUNC(
void, EVP_PKEY_CTX_free, EVP_PKEY_CTX *ctx, ctx,
return,
return)
153 DEFINEFUNC(
int, OPENSSL_sk_num, OPENSSL_STACK *
a,
a,
return -1,
return)
161 using info_callback =
void (*) (
const SSL *ssl,
int type,
int val);
167 #ifdef TLS1_3_VERSION
168 DEFINEFUNC2(
int, SSL_CTX_set_ciphersuites, SSL_CTX *ctx, ctx,
const char *
str,
str,
return 0,
return)
170 DEFINEFUNC2(
void, SSL_CTX_sess_set_new_cb, SSL_CTX *ctx, ctx, NewSessionCallback
cb,
cb,
return,
return)
171 DEFINEFUNC(
int, SSL_SESSION_is_resumable,
const SSL_SESSION *
s,
s,
return 0,
return)
173 DEFINEFUNC3(
size_t, SSL_get_client_random, SSL *
a,
a,
unsigned char *
out,
out,
size_t outlen, outlen,
return 0,
return)
174 DEFINEFUNC3(
size_t, SSL_SESSION_get_master_key,
const SSL_SESSION *ses, ses,
unsigned char *
out,
out,
size_t outlen, outlen,
return 0,
return)
175 DEFINEFUNC6(
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)
176 DEFINEFUNC2(
unsigned long, SSL_set_options, SSL *ssl, ssl,
unsigned long op,
op,
return 0,
return)
182 DEFINEFUNC(ASN1_TIME *, X509_getm_notBefore, X509 *
a,
a,
return nullptr,
return)
183 DEFINEFUNC(ASN1_TIME *, X509_getm_notAfter, X509 *
a,
a,
return nullptr,
return)
186 DEFINEFUNC(
long, X509_get_version, X509 *
a,
a,
return -1,
return)
187 DEFINEFUNC(EVP_PKEY *, X509_get_pubkey, X509 *
a,
a,
return nullptr,
return)
188 DEFINEFUNC2(
void, X509_STORE_set_verify_cb, X509_STORE *
a,
a, X509_STORE_CTX_verify_cb verify_cb, verify_cb,
return,
DUMMYARG)
190 DEFINEFUNC2(
void *, X509_STORE_get_ex_data, X509_STORE *
r,
r,
int idx,
idx,
return nullptr,
return)
191 DEFINEFUNC(
STACK_OF(X509) *, X509_STORE_CTX_get0_chain, X509_STORE_CTX *
a,
a,
return nullptr,
return)
194 DEFINEFUNC(
const char *, OpenSSL_version,
int a,
a,
return nullptr,
return)
195 DEFINEFUNC(
unsigned long, SSL_SESSION_get_ticket_lifetime_hint,
const SSL_SESSION *session, session,
return 0,
return)
196 DEFINEFUNC4(
void, DH_get0_pqg,
const DH *dh, dh,
const BIGNUM **
p,
p,
const BIGNUM **
q,
q,
const BIGNUM **
g,
g,
return,
DUMMYARG)
199 DEFINEFUNC2(
int, DTLSv1_listen, SSL *
s,
s, BIO_ADDR *
c,
c,
return -1,
return)
204 DEFINEFUNC2(
int, BIO_meth_set_write, BIO_METHOD *biom, biom, DgramWriteCallback
write,
write,
return 0,
return)
205 DEFINEFUNC2(
int, BIO_meth_set_read, BIO_METHOD *biom, biom, DgramReadCallback read, read,
return 0,
return)
206 DEFINEFUNC2(
int, BIO_meth_set_puts, BIO_METHOD *biom, biom, DgramPutsCallback puts, puts,
return 0,
return)
207 DEFINEFUNC2(
int, BIO_meth_set_ctrl, BIO_METHOD *biom, biom, DgramCtrlCallback ctrl, ctrl,
return 0,
return)
208 DEFINEFUNC2(
int, BIO_meth_set_create, BIO_METHOD *biom, biom, DgramCreateCallback crt, crt,
return 0,
return)
209 DEFINEFUNC2(
int, BIO_meth_set_destroy, BIO_METHOD *biom, biom, DgramDestroyCallback dtr, dtr,
return 0,
return)
213 DEFINEFUNC(
const OCSP_CERTID *, OCSP_SINGLERESP_get0_id,
const OCSP_SINGLERESP *
x,
x,
return nullptr,
return)
214 DEFINEFUNC3(OCSP_RESPONSE *, d2i_OCSP_RESPONSE, OCSP_RESPONSE **
a,
a,
const unsigned char **
in,
in,
long len,
len,
return nullptr,
return)
216 DEFINEFUNC(OCSP_BASICRESP *, OCSP_response_get1_basic, OCSP_RESPONSE *resp, resp,
return nullptr,
return)
218 DEFINEFUNC(
int, OCSP_response_status, OCSP_RESPONSE *resp, resp,
return OCSP_RESPONSE_STATUS_INTERNALERROR,
return)
219 DEFINEFUNC4(
int, OCSP_basic_verify, OCSP_BASICRESP *bs, bs,
STACK_OF(X509) *
certs,
certs, X509_STORE *st, st,
unsigned long flags,
flags,
return -1,
return)
220 DEFINEFUNC(
int, OCSP_resp_count, OCSP_BASICRESP *bs, bs,
return 0,
return)
221 DEFINEFUNC2(OCSP_SINGLERESP *, OCSP_resp_get0, OCSP_BASICRESP *bs, bs,
int idx,
idx,
return nullptr,
return)
222 DEFINEFUNC5(
int, OCSP_single_get0_status, OCSP_SINGLERESP *single, single,
int *reason, reason, ASN1_GENERALIZEDTIME **revtime, revtime,
223 ASN1_GENERALIZEDTIME **thisupd, thisupd, ASN1_GENERALIZEDTIME **nextupd, nextupd,
return -1,
return)
224 DEFINEFUNC4(
int, OCSP_check_validity, ASN1_GENERALIZEDTIME *thisupd, thisupd, ASN1_GENERALIZEDTIME *nextupd, nextupd,
long nsec, nsec,
long maxsec, maxsec,
return 0,
return)
225 DEFINEFUNC3(OCSP_CERTID *, OCSP_cert_to_id,
const EVP_MD *dgst, dgst, X509 *subject, subject, X509 *issuer, issuer,
return nullptr,
return)
227 DEFINEFUNC5(
int, OCSP_id_get0_info, ASN1_OCTET_STRING **piNameHash, piNameHash, ASN1_OBJECT **pmd, pmd,
228 ASN1_OCTET_STRING **piKeyHash, piKeyHash, ASN1_INTEGER **pserial, pserial, OCSP_CERTID *cid, cid,
230 DEFINEFUNC2(OCSP_RESPONSE *, OCSP_response_create,
int status, status, OCSP_BASICRESP *bs, bs,
return nullptr,
return)
231 DEFINEFUNC(
const STACK_OF(X509) *, OCSP_resp_get0_certs,
const OCSP_BASICRESP *bs, bs,
return nullptr,
return)
232 DEFINEFUNC2(
int, OCSP_id_cmp, OCSP_CERTID *
a,
a, OCSP_CERTID *
b,
b,
return -1,
return)
233 DEFINEFUNC7(OCSP_SINGLERESP *, OCSP_basic_add1_status, OCSP_BASICRESP *
r,
r, OCSP_CERTID *
c,
c,
int s,
s,
234 int re, re, ASN1_TIME *
rt,
rt, ASN1_TIME *
t,
t, ASN1_TIME *
n,
n,
return nullptr,
return)
236 DEFINEFUNC2(
int, i2d_OCSP_RESPONSE, OCSP_RESPONSE *
r,
r,
unsigned char **ppout, ppout,
return 0,
return)
237 DEFINEFUNC6(
int, OCSP_basic_sign, OCSP_BASICRESP *br, br, X509 *signer, signer, EVP_PKEY *
key,
key,
238 const EVP_MD *dg, dg,
STACK_OF(X509) *cs, cs,
unsigned long flags,
flags,
return 0,
return)
241 DEFINEFUNC(
void, AUTHORITY_INFO_ACCESS_free, AUTHORITY_INFO_ACCESS *
p,
p,
return,
return)
243 DEFINEFUNC(
void *, BIO_get_data, BIO *
a,
a,
return nullptr,
return)
245 DEFINEFUNC(
int, BIO_get_shutdown, BIO *
a,
a,
return -1,
return)
248 DEFINEFUNC(
long, ASN1_INTEGER_get, ASN1_INTEGER *
a,
a,
return 0,
return)
249 DEFINEFUNC2(
int, ASN1_INTEGER_cmp,
const ASN1_INTEGER *
a,
a,
const ASN1_INTEGER *
b,
b,
return 1,
return)
250 DEFINEFUNC(
int, ASN1_STRING_length, ASN1_STRING *
a,
a,
return 0,
return)
251 DEFINEFUNC2(
int, ASN1_STRING_to_UTF8,
unsigned char **
a,
a, ASN1_STRING *
b,
b,
return 0,
return)
252 DEFINEFUNC2(
int, ASN1_TIME_to_tm,
const ASN1_TIME *
s,
s,
struct tm *tm, tm,
return 0,
return)
253 DEFINEFUNC4(
long, BIO_ctrl, BIO *
a,
a,
int b,
b,
long c,
c,
void *
d,
d,
return -1,
return)
255 DEFINEFUNC2(BIO *, BIO_new_mem_buf,
void *
a,
a,
int b,
b,
return nullptr,
return)
258 DEFINEFUNC3(
int, BIO_write, BIO *
a,
a,
const void *
b,
b,
int c,
c,
return -1,
return)
259 DEFINEFUNC(
int, BN_num_bits,
const BIGNUM *
a,
a,
return 0,
return)
260 DEFINEFUNC2(BN_ULONG, BN_mod_word,
const BIGNUM *
a,
a, BN_ULONG
w,
w,
return static_cast<BN_ULONG
>(-1),
return)
261 DEFINEFUNC3(X509 *, d2i_X509, X509 **
a,
a,
const unsigned char **
b,
b,
long c,
c,
return nullptr,
return)
262 DEFINEFUNC2(
char *, ERR_error_string,
unsigned long a,
a,
char *
b,
b,
return nullptr,
return)
265 DEFINEFUNC(EVP_CIPHER_CTX *, EVP_CIPHER_CTX_new,
void,
DUMMYARG,
return nullptr,
return)
267 DEFINEFUNC4(
int, EVP_CIPHER_CTX_ctrl, EVP_CIPHER_CTX *ctx, ctx,
int type,
type,
int arg,
arg,
void *ptr, ptr,
return 0,
return)
268 DEFINEFUNC2(
int, EVP_CIPHER_CTX_set_key_length, EVP_CIPHER_CTX *ctx, ctx,
int keylen, keylen,
return 0,
return)
269 DEFINEFUNC5(
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)
270 DEFINEFUNC6(
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)
271 DEFINEFUNC5(
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)
272 DEFINEFUNC3(
int, EVP_CipherFinal, EVP_CIPHER_CTX *ctx, ctx,
unsigned char *
out,
out,
int *outl, outl,
return 0,
return)
273 DEFINEFUNC(
const EVP_MD *, EVP_get_digestbyname,
const char *
name,
name,
return nullptr,
return)
274 #ifndef OPENSSL_NO_DES
278 #ifndef OPENSSL_NO_RC2
281 #ifndef OPENSSL_NO_AES
289 DEFINEFUNC(
int, EVP_PKEY_type,
int a,
a,
return NID_undef,
return)
290 DEFINEFUNC2(
int, i2d_X509, X509 *
a,
a,
unsigned char **
b,
b,
return -1,
return)
291 DEFINEFUNC(
const char *, OBJ_nid2sn,
int a,
a,
return nullptr,
return)
292 DEFINEFUNC(
const char *, OBJ_nid2ln,
int a,
a,
return nullptr,
return)
293 DEFINEFUNC(
int, OBJ_sn2nid,
const char *
s,
s,
return 0,
return)
294 DEFINEFUNC(
int, OBJ_ln2nid,
const char *
s,
s,
return 0,
return)
295 DEFINEFUNC3(
int, i2t_ASN1_OBJECT,
char *
a,
a,
int b,
b, ASN1_OBJECT *
c,
c,
return -1,
return)
296 DEFINEFUNC4(
int, OBJ_obj2txt,
char *
a,
a,
int b,
b, ASN1_OBJECT *
c,
c,
int d,
d,
return -1,
return)
297 DEFINEFUNC(
int, OBJ_obj2nid,
const ASN1_OBJECT *
a,
a,
return NID_undef,
return)
298 DEFINEFUNC4(EVP_PKEY *, PEM_read_bio_PrivateKey, BIO *
a,
a, EVP_PKEY **
b,
b, pem_password_cb *
c,
c,
void *
d,
d,
return nullptr,
return)
300 DEFINEFUNC4(DH *, PEM_read_bio_DHparams, BIO *
a,
a, DH **
b,
b, pem_password_cb *
c,
c,
void *
d,
d,
return nullptr,
return)
301 DEFINEFUNC7(
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)
302 DEFINEFUNC7(
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)
303 DEFINEFUNC4(EVP_PKEY *, PEM_read_bio_PUBKEY, BIO *
a,
a, EVP_PKEY **
b,
b, pem_password_cb *
c,
c,
void *
d,
d,
return nullptr,
return)
304 DEFINEFUNC2(
int, PEM_write_bio_PUBKEY, BIO *
a,
a, EVP_PKEY *
b,
b,
return 0,
return)
307 DEFINEFUNC2(
int, RAND_bytes,
unsigned char *
b,
b,
int n,
n,
return 0,
return)
308 DEFINEFUNC(
int, SSL_accept, SSL *
a,
a,
return -1,
return)
309 DEFINEFUNC(
int, SSL_clear, SSL *
a,
a,
return -1,
return)
310 DEFINEFUNC3(
char *, SSL_CIPHER_description,
const SSL_CIPHER *
a,
a,
char *
b,
b,
int c,
c,
return nullptr,
return)
311 DEFINEFUNC2(
int, SSL_CIPHER_get_bits,
const SSL_CIPHER *
a,
a,
int *
b,
b,
return 0,
return)
312 DEFINEFUNC(BIO *, SSL_get_rbio,
const SSL *
s,
s,
return nullptr,
return)
313 DEFINEFUNC(
int, SSL_connect, SSL *
a,
a,
return -1,
return)
314 DEFINEFUNC(
int, SSL_CTX_check_private_key,
const SSL_CTX *
a,
a,
return -1,
return)
315 DEFINEFUNC4(
long, SSL_CTX_ctrl, SSL_CTX *
a,
a,
int b,
b,
long c,
c,
void *
d,
d,
return -1,
return)
317 DEFINEFUNC(SSL_CTX *, SSL_CTX_new,
const SSL_METHOD *
a,
a,
return nullptr,
return)
318 DEFINEFUNC2(
int, SSL_CTX_set_cipher_list, SSL_CTX *
a,
a,
const char *
b,
b,
return -1,
return)
320 DEFINEFUNC(
int, SSL_CTX_set_default_verify_paths, SSL_CTX *
a,
a,
return -1,
return)
321 DEFINEFUNC3(
void, SSL_CTX_set_verify, SSL_CTX *
a,
a,
int b,
b,
int (*
c)(
int, X509_STORE_CTX *),
c,
return,
DUMMYARG)
341 #if defined(OPENSSL_VERSION_MAJOR) && OPENSSL_VERSION_MAJOR >= 3
342 DEFINEFUNC(X509 *, SSL_get1_peer_certificate, SSL *
a,
a,
return nullptr,
return)
343 DEFINEFUNC(
int, EVP_PKEY_get_bits,
const EVP_PKEY *pkey, pkey,
return -1,
return)
344 DEFINEFUNC(
int, EVP_PKEY_get_base_id,
const EVP_PKEY *pkey, pkey,
return -1,
return)
346 DEFINEFUNC(X509 *, SSL_get_peer_certificate, SSL *
a,
a,
return nullptr,
return)
347 DEFINEFUNC(
int, EVP_PKEY_base_id, EVP_PKEY *
a,
a,
return NID_undef,
return)
350 DEFINEFUNC(
long, SSL_get_verify_result,
const SSL *
a,
a,
return -1,
return)
351 DEFINEFUNC(SSL *, SSL_new, SSL_CTX *
a,
a,
return nullptr,
return)
352 DEFINEFUNC(SSL_CTX *, SSL_get_SSL_CTX, SSL *
a,
a,
return nullptr,
return)
353 DEFINEFUNC4(
long, SSL_ctrl, SSL *
a,
a,
int cmd, cmd,
long larg, larg,
void *parg, parg,
return -1,
return)
358 DEFINEFUNC(
int, SSL_shutdown, SSL *
a,
a,
return -1,
return)
359 DEFINEFUNC(
int, SSL_in_init,
const SSL *
a,
a,
return 0,
return)
360 DEFINEFUNC(
int, SSL_get_shutdown,
const SSL *ssl, ssl,
return 0,
return)
361 DEFINEFUNC2(
int, SSL_set_session, SSL* to, to, SSL_SESSION *session, session,
return -1,
return)
363 DEFINEFUNC(SSL_SESSION*, SSL_get1_session, SSL *ssl, ssl,
return nullptr,
return)
364 DEFINEFUNC(SSL_SESSION*, SSL_get_session,
const SSL *ssl, ssl,
return nullptr,
return)
366 DEFINEFUNC2(
void *, SSL_get_ex_data,
const SSL *ssl, ssl,
int idx,
idx,
return nullptr,
return)
368 #ifndef OPENSSL_NO_PSK
371 DEFINEFUNC2(
int, SSL_CTX_use_psk_identity_hint, SSL_CTX* ctx, ctx,
const char *hint, hint,
return 0,
return)
374 DEFINEFUNC3(
int, SSL_write, SSL *
a,
a,
const void *
b,
b,
int c,
c,
return -1,
return)
376 DEFINEFUNC4(
int, X509_digest,
const X509 *x509, x509,
const EVP_MD *
type,
type,
unsigned char *md, md,
unsigned int *
len,
len,
return -1,
return)
377 DEFINEFUNC(X509 *, X509_dup, X509 *
a,
a,
return nullptr,
return)
386 DEFINEFUNC4(
void *, X509_get_ext_d2i, X509 *
a,
a,
int b,
b,
int *
c,
c,
int *
d,
d,
return nullptr,
return)
409 DEFINEFUNC4(
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)
419 #if OPENSSL_VERSION_MAJOR < 3
420 DEFINEFUNC3(
int, SSL_CTX_load_verify_locations, SSL_CTX *ctx, ctx,
const char *CAfile, CAfile,
const char *CApath, CApath,
return 0,
return)
422 DEFINEFUNC2(
int, SSL_CTX_load_verify_dir, SSL_CTX *ctx, ctx,
const char *CApath, CApath,
return 0,
return)
425 DEFINEFUNC2(
int, i2d_SSL_SESSION, SSL_SESSION *
in,
in,
unsigned char **pp, pp,
return 0,
return)
426 DEFINEFUNC3(SSL_SESSION *, d2i_SSL_SESSION, SSL_SESSION **
a,
a,
const unsigned char **pp, pp,
long length,
length,
return nullptr,
return)
428 #ifndef OPENSSL_NO_NEXTPROTONEG
429 DEFINEFUNC6(
int, SSL_select_next_proto,
unsigned char **
out,
out,
unsigned char *outlen, outlen,
430 const unsigned char *
in,
in,
unsigned int inlen, inlen,
431 const unsigned char *client, client,
unsigned int client_len, client_len,
434 int (*
cb) (SSL *ssl,
unsigned char **
out,
435 unsigned char *outlen,
437 unsigned int inlen,
void *
arg),
cb,
444 int (*
cb) (SSL *ssl,
const unsigned char **
out,
445 unsigned char *outlen,
447 unsigned int inlen,
void *
arg),
cb,
455 DEFINEFUNC2(
void, SSL_CTX_set_cookie_generate_cb, SSL_CTX *ctx, ctx, CookieGenerateCallback
cb,
cb,
return,
DUMMYARG)
456 DEFINEFUNC2(
void, SSL_CTX_set_cookie_verify_cb, SSL_CTX *ctx, ctx, CookieVerifyCallback
cb,
cb,
return,
DUMMYARG)
469 DEFINEFUNC2(
int, i2d_DHparams, DH *
a,
a,
unsigned char **
p,
p,
return -1,
return)
470 DEFINEFUNC2(
int, DH_check, DH *dh, dh,
int *codes, codes,
return 0,
return)
473 #ifndef OPENSSL_NO_EC
474 DEFINEFUNC2(
size_t, EC_get_builtin_curves, EC_builtin_curve *
r,
r,
size_t nitems, nitems,
return 0,
return)
478 DEFINEFUNC5(
int, PKCS12_parse, PKCS12 *p12, p12,
const char *pass, pass, EVP_PKEY **pkey, pkey, \
480 DEFINEFUNC2(PKCS12 *, d2i_PKCS12_bio, BIO *bio, bio, PKCS12 **pkcs12, pkcs12,
return nullptr,
return);
483 #ifndef OPENSSL_NO_DEPRECATED_3_0
485 DEFINEFUNC4(DSA *, PEM_read_bio_DSA_PUBKEY, BIO *
a,
a, DSA **
b,
b, pem_password_cb *
c,
c,
void *
d,
d,
return nullptr,
return)
486 DEFINEFUNC4(RSA *, PEM_read_bio_RSA_PUBKEY, BIO *
a,
a, RSA **
b,
b, pem_password_cb *
c,
c,
void *
d,
d,
return nullptr,
return)
487 DEFINEFUNC4(DSA *, PEM_read_bio_DSAPrivateKey, BIO *
a,
a, DSA **
b,
b, pem_password_cb *
c,
c,
void *
d,
d,
return nullptr,
return)
488 DEFINEFUNC4(RSA *, PEM_read_bio_RSAPrivateKey, BIO *
a,
a, RSA **
b,
b, pem_password_cb *
c,
c,
void *
d,
d,
return nullptr,
return)
490 DEFINEFUNC2(
int, PEM_write_bio_DSA_PUBKEY, BIO *
a,
a, DSA *
b,
b,
return 0,
return)
491 DEFINEFUNC2(
int, PEM_write_bio_RSA_PUBKEY, BIO *
a,
a, RSA *
b,
b,
return 0,
return)
492 DEFINEFUNC7(
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)
493 DEFINEFUNC7(
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)
495 DEFINEFUNC2(
int, SSL_CTX_use_RSAPrivateKey, SSL_CTX *
a,
a, RSA *
b,
b,
return -1,
return)
505 DEFINEFUNC(
int, DH_bits, DH *dh, dh,
return 0,
return)
507 DEFINEFUNC(DSA *, EVP_PKEY_get1_DSA, EVP_PKEY *
a,
a,
return nullptr,
return)
508 DEFINEFUNC(RSA *, EVP_PKEY_get1_RSA, EVP_PKEY *
a,
a,
return nullptr,
return)
509 DEFINEFUNC(DH *, EVP_PKEY_get1_DH, EVP_PKEY *
a,
a,
return nullptr,
return)
511 DEFINEFUNC2(
int, EVP_PKEY_cmp,
const EVP_PKEY *
a,
a,
const EVP_PKEY *
b,
b,
return -1,
return)
512 DEFINEFUNC3(
int, EVP_PKEY_assign, EVP_PKEY *
a,
a,
int b,
b,
void *
r,
r,
return -1,
return)
514 DEFINEFUNC2(
int, EVP_PKEY_set1_RSA, EVP_PKEY *
a,
a, RSA *
b,
b,
return -1,
return)
515 DEFINEFUNC2(
int, EVP_PKEY_set1_DSA, EVP_PKEY *
a,
a, DSA *
b,
b,
return -1,
return)
516 DEFINEFUNC2(
int, EVP_PKEY_set1_DH, EVP_PKEY *
a,
a, DH *
b,
b,
return -1,
return)
518 #ifndef OPENSSL_NO_EC
520 DEFINEFUNC4(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)
521 DEFINEFUNC4(EC_KEY *, PEM_read_bio_ECPrivateKey, BIO *
a,
a, EC_KEY **
b,
b, pem_password_cb *
c,
c,
void *
d,
d,
return nullptr,
return)
523 DEFINEFUNC2(
int, PEM_write_bio_EC_PUBKEY, BIO *
a,
a, EC_KEY *
b,
b,
return 0,
return)
524 DEFINEFUNC7(
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)
526 DEFINEFUNC(
const EC_GROUP*, EC_KEY_get0_group,
const EC_KEY* k, k,
return nullptr,
return)
527 DEFINEFUNC(
int, EC_GROUP_get_degree,
const EC_GROUP*
g,
g,
return 0,
return)
529 DEFINEFUNC2(
int, EVP_PKEY_set1_EC_KEY, EVP_PKEY *
a,
a, EC_KEY *
b,
b,
return -1,
return)
530 DEFINEFUNC(EC_KEY *, EVP_PKEY_get1_EC_KEY, EVP_PKEY *
a,
a,
return nullptr,
return)
532 DEFINEFUNC(EC_KEY *, EC_KEY_dup,
const EC_KEY *ec, ec,
return nullptr,
return)
533 DEFINEFUNC(EC_KEY *, EC_KEY_new_by_curve_name,
int nid, nid,
return nullptr,
return)
542 #define RESOLVEFUNC(func) \
543 if (!(_q_##func = _q_PTR_##func(libs.ssl->resolve(#func))) \
544 && !(_q_##func = _q_PTR_##func(libs.crypto->resolve(#func)))) \
545 qsslSocketCannotResolveSymbolWarning(#func);
547 #if !defined QT_LINKED_OPENSSL
549 #if !QT_CONFIG(library)
552 qCWarning(lcTlsBackend,
"QSslSocket: unable to resolve symbols. Qt is configured without the "
553 "'library' feature, which means runtime resolving of libraries won't work.");
554 qCWarning(lcTlsBackend,
"Either compile Qt statically or with support for runtime resolving "
561 struct NumericallyLess
563 typedef bool result_type;
581 struct LibGreaterThan
583 typedef bool result_type;
588 Q_ASSERT(lhsparts.count() > 1 && rhsparts.count() > 1);
591 return std::lexicographical_compare(rhsparts.begin() + 1, rhsparts.end(),
592 lhsparts.begin() + 1, lhsparts.end(),
597 #if defined(Q_OS_LINUX) && !defined(Q_OS_ANDROID)
598 static int dlIterateCallback(
struct dl_phdr_info *
info,
size_t size,
void *
data)
604 if (!
path.isEmpty()) {
623 CFBundleGetPackageInfo(CFBundleGetMainBundle(), &packageType,
nullptr);
624 if (packageType == FOUR_CHAR_CODE(
'APPL')) {
626 QUrl frameworksUrl = QUrl::fromCFURL(
QCFType<CFURLRef>(CFBundleCopyPrivateFrameworksURL(CFBundleGetMainBundle())));
637 #if defined(Q_OS_ANDROID)
639 #elif defined(Q_OS_LINUX)
642 dl_iterate_phdr(dlIterateCallback, &loadedPaths);
643 std::move(loadedPaths).appendTo(
paths);
660 std::sort(entryList.begin(), entryList.end(), LibGreaterThan());
681 struct LoadedOpenSsl {
682 std::unique_ptr<QSystemLibrary> ssl, crypto;
687 auto ssleay32 = std::make_unique<QSystemLibrary>(ssleay32LibName);
688 if (!ssleay32->load(
false)) {
692 auto libeay32 = std::make_unique<QSystemLibrary>(libeay32LibName);
693 if (!libeay32->load(
false)) {
697 result.ssl = std::move(ssleay32);
698 result.crypto = std::move(libeay32);
702 static LoadedOpenSsl loadOpenSsl()
710 #if (OPENSSL_VERSION_NUMBER >> 28) < 3
711 #define QT_OPENSSL_VERSION "1_1"
712 #elif OPENSSL_VERSION_MAJOR == 3
713 #define QT_OPENSSL_VERSION "3"
716 #if defined(Q_PROCESSOR_X86_64)
717 #define QT_SSL_SUFFIX "-x64"
718 #elif defined(Q_PROCESSOR_ARM_64)
719 #define QT_SSL_SUFFIX "-arm64"
720 #elif defined(Q_PROCESSOR_ARM_32)
721 #define QT_SSL_SUFFIX "-arm"
723 #define QT_SSL_SUFFIX
726 tryToLoadOpenSslWin32Library(
QLatin1String(
"libssl-" QT_OPENSSL_VERSION QT_SSL_SUFFIX),
734 struct LoadedOpenSsl {
735 std::unique_ptr<QLibrary> ssl, crypto;
738 static LoadedOpenSsl loadOpenSsl()
740 LoadedOpenSsl
result = { std::make_unique<QLibrary>(), std::make_unique<QLibrary>() };
742 # if defined(Q_OS_UNIX)
782 #if defined(SHLIB_VERSION_NUMBER) && !defined(Q_OS_QNX)
786 if (libcrypto->
load() && libssl->
load()) {
802 # if defined(Q_OS_ANDROID)
804 auto openSSLSuffix = [](
const QByteArray &defaultSuffix = {}) {
805 auto suffix = qgetenv(
"ANDROID_OPENSSL_SUFFIX");
806 if (suffix.isEmpty())
807 return defaultSuffix;
819 if (libcrypto->
load() && libssl->
load()) {
832 for (
const QString &crypto : cryptoList) {
835 if (crypto.endsWith(
"libcrypto.dylib"))
839 if (libcrypto->
load()) {
843 for (
const QString &ssl : sslList) {
849 if (libssl->
load()) {
873 static bool triedToResolveSymbols =
false;
882 if (triedToResolveSymbols)
884 triedToResolveSymbols =
true;
886 LoadedOpenSsl libs = loadOpenSsl();
887 if (!libs.ssl || !libs.crypto) {
888 qCWarning(lcTlsBackend,
"Failed to load libssl/libcrypto.");
914 #ifdef TLS1_3_VERSION
945 if (!_q_OpenSSL_version || !_q_OpenSSL_version_num) {
948 qCWarning(lcTlsBackend,
"Incompatible version of OpenSSL");
952 #if OPENSSL_VERSION_NUMBER >= 0x30000000
954 qCWarning(lcTlsBackend,
"Incompatible version of OpenSSL (built with OpenSSL >= 3.x, runtime version is < 3.x)");
959 qCWarning(lcTlsBackend,
"Incompatible version of OpenSSL (built with OpenSSL 1.x, runtime version is >= 3.x)");
1041 #ifndef OPENSSL_NO_DES
1045 #ifndef OPENSSL_NO_RC2
1048 #ifndef OPENSSL_NO_AES
1106 #if defined(OPENSSL_VERSION_MAJOR) && OPENSSL_VERSION_MAJOR >= 3
1115 #ifndef OPENSSL_NO_DEPRECATED_3_0
1148 #ifndef OPENSSL_NO_EC
1185 #ifndef OPENSSL_NO_PSK
1235 #if OPENSSL_VERSION_MAJOR < 3
1243 #ifndef OPENSSL_NO_NEXTPROTONEG
1267 #ifndef OPENSSL_NO_EC
1284 #ifdef QT_NO_OPENSSL
T loadAcquire() const noexcept
void storeRelease(T newValue) noexcept
T loadRelaxed() const noexcept
The QByteArray class provides an array of bytes.
The QDir class provides access to directory structures and their contents.
The QFileInfo class provides system-independent file information.
QString completeSuffix() const
QString absolutePath() const
The QLatin1String class provides a thin wrapper around an US-ASCII/Latin-1 encoded string literal.
The QLibrary class loads shared libraries at runtime.
@ ExportExternalSymbolsHint
void setFileNameAndVersion(const QString &fileName, int verNum)
void setLoadHints(LoadHints hints)
The QMutex class provides access serialization between threads.
The QMutexLocker class is a convenience class that simplifies locking and unlocking mutexes.
The QString class provides a Unicode character string.
static QString fromLatin1(QByteArrayView ba)
QStringList split(const QString &sep, Qt::SplitBehavior behavior=Qt::KeepEmptyParts, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
static QString fromLocal8Bit(QByteArrayView ba)
The QStringList class provides a list of strings.
The QStringView class provides a unified view on UTF-16 strings with a read-only subset of the QStrin...
Q_CORE_EXPORT QList< QStringView > split(QStringView sep, Qt::SplitBehavior behavior=Qt::KeepEmptyParts, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
int toInt(bool *ok=nullptr, int base=10) const
The QUrl class provides a convenient interface for working with URLs.
QUrl resolved(const QUrl &relative) const
QString path(ComponentFormattingOptions options=FullyDecoded) const
constexpr T & operator()(T &v) const
auto it unsigned count const
backing_store_ptr info
[4]
QRhiTextureRenderTarget * rt
void qsslSocketUnresolvedSymbolWarning(const char *functionName)
set set set set set set set macro pixldst1 abits if abits op else op endif endm macro pixldst2 abits if abits op else op endif endm macro pixldst4 abits if abits op else op endif endm macro pixldst0 abits op endm macro pixldst3 mem_operand op endm macro pixldst30 mem_operand op endm macro pixldst abits if abits elseif abits elseif abits elseif abits elseif abits pixldst0 abits else pixldst0 abits pixldst0 abits pixldst0 abits pixldst0 abits endif elseif abits else pixldst0 abits pixldst0 abits endif elseif abits else error unsupported bpp *numpix else pixst endif endm macro vuzp8 reg2 vuzp d d ®2 endm macro vzip8 reg2 vzip d d ®2 endm macro pixdeinterleave basereg basereg basereg basereg basereg endif endm macro pixinterleave basereg basereg basereg basereg basereg endif endm macro PF boost_increment endif if endif PF tst PF addne PF subne PF cmp ORIG_W if endif if endif if endif PF subge ORIG_W PF subges if endif if endif if endif endif endm macro cache_preload_simple endif if dst_r_bpp pld[DST_R, #(PREFETCH_DISTANCE_SIMPLE *dst_r_bpp/8)] endif if mask_bpp pld init[MASK, #(PREFETCH_DISTANCE_SIMPLE *mask_bpp/8)] endif endif endm macro ensure_destination_ptr_alignment process_pixblock_tail_head if beq irp skip1 beq endif SRC MASK if dst_r_bpp DST_R else add endif PF add sub src_basereg pixdeinterleave mask_basereg pixdeinterleave dst_r_basereg process_pixblock_head pixblock_size cache_preload_simple process_pixblock_tail pixinterleave dst_w_basereg irp beq endif process_pixblock_tail_head tst beq irp if pixblock_size chunk_size tst beq pixld SRC pixld MASK if DST_R else pixld DST_R endif if src_basereg pixdeinterleave mask_basereg pixdeinterleave dst_r_basereg process_pixblock_head if pixblock_size cache_preload_simple endif process_pixblock_tail pixinterleave dst_w_basereg irp if pixblock_size chunk_size tst beq if DST_W else pixst DST_W else mov ORIG_W endif add lsl if lsl endif if lsl endif lsl endif lsl endif lsl endif subs mov DST_W if regs_shortage str endif bge start_of_loop_label endm macro generate_composite_function
set set set set set set set macro pixldst1 op
#define Q_BASIC_ATOMIC_INITIALIZER(a)
EGLOutputLayerEXT EGLint EGLAttrib value
#define qCWarning(category,...)
GLenum GLuint GLenum GLsizei length
GLboolean GLboolean GLboolean b
GLint GLint GLint GLint GLint x
[0]
GLenum GLuint GLint level
GLfloat GLfloat GLfloat w
[0]
GLboolean GLboolean GLboolean GLboolean a
[7]
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLsizei const GLuint * paths
GLint GLint GLint GLint GLint GLint GLint GLbitfield GLenum filter
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLdouble GLdouble GLdouble GLdouble q
GLsizei const GLchar *const * path
bool q_resolveOpenSslSymbols()
DEFINEFUNC2(void, OPENSSL_sk_pop_free, OPENSSL_STACK *a, a, void(*b)(void *), b, return, DUMMYARG) using info_callback
DEFINEFUNC6(int, SSL_select_next_proto, unsigned char **out, out, unsigned char *outlen, outlen, const unsigned char *in, in, unsigned int inlen, inlen, const unsigned char *client, client, unsigned int client_len, client_len, return -1, return) DEFINEFUNC3(void
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)
DEFINEFUNC(void, SSL_CONF_CTX_free, SSL_CONF_CTX *a, a, return, return)
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_set_next_proto_select_cb
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 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)
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)
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()
QFileInfo fi("c:/temp/foo")
[newstuff]
gzip write("uncompressed data")
QSettings settings("MySoft", "Star Runner")
[0]
QTextStream out(stdout)
[7]
const QStringList filters({"Image files (*.png *.xpm *.jpg)", "Text files (*.txt)", "Any files (*)" })
[6]
QList< QSslCertificate > cert
[0]
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.