qsslsocket_openssl_symbols.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/network/ssl/qsslsocket_openssl_symbols.cpp
Source codeSwitch to Preprocessed file
LineSourceCount
1/****************************************************************************-
2**-
3** Copyright (C) 2016 The Qt Company Ltd.-
4** Copyright (C) 2014 BlackBerry Limited. All rights reserved.-
5** Contact: https://www.qt.io/licensing/-
6**-
7** This file is part of the QtNetwork module of the Qt Toolkit.-
8**-
9** $QT_BEGIN_LICENSE:LGPL$-
10** Commercial License Usage-
11** Licensees holding valid commercial Qt licenses may use this file in-
12** accordance with the commercial license agreement provided with the-
13** Software or, alternatively, in accordance with the terms contained in-
14** a written agreement between you and The Qt Company. For licensing terms-
15** and conditions see https://www.qt.io/terms-conditions. For further-
16** information use the contact form at https://www.qt.io/contact-us.-
17**-
18** GNU Lesser General Public License Usage-
19** Alternatively, this file may be used under the terms of the GNU Lesser-
20** General Public License version 3 as published by the Free Software-
21** Foundation and appearing in the file LICENSE.LGPL3 included in the-
22** packaging of this file. Please review the following information to-
23** ensure the GNU Lesser General Public License version 3 requirements-
24** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.-
25**-
26** GNU General Public License Usage-
27** Alternatively, this file may be used under the terms of the GNU-
28** General Public License version 2.0 or (at your option) the GNU General-
29** Public license version 3 or any later version approved by the KDE Free-
30** Qt Foundation. The licenses are as published by the Free Software-
31** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3-
32** included in the packaging of this file. Please review the following-
33** information to ensure the GNU General Public License requirements will-
34** be met: https://www.gnu.org/licenses/gpl-2.0.html and-
35** https://www.gnu.org/licenses/gpl-3.0.html.-
36**-
37** $QT_END_LICENSE$-
38**-
39****************************************************************************/-
40-
41/****************************************************************************-
42**-
43** In addition, as a special exception, the copyright holders listed above give-
44** permission to link the code of its release of Qt with the OpenSSL project's-
45** "OpenSSL" library (or modified versions of the "OpenSSL" library that use the-
46** same license as the original version), and distribute the linked executables.-
47**-
48** You must comply with the GNU General Public License version 2 in all-
49** respects for all of the code used other than the "OpenSSL" code. If you-
50** modify this file, you may extend this exception to your version of the file,-
51** but you are not obligated to do so. If you do not wish to do so, delete-
52** this exception statement from your version of this file.-
53**-
54****************************************************************************/-
55-
56#include "qssl_p.h"-
57#include "qsslsocket_openssl_symbols_p.h"-
58-
59#ifdef Q_OS_WIN-
60# include <private/qsystemlibrary_p.h>-
61#else-
62# include <QtCore/qlibrary.h>-
63#endif-
64#include <QtCore/qmutex.h>-
65#include <private/qmutexpool_p.h>-
66#include <QtCore/qdatetime.h>-
67#if defined(Q_OS_UNIX)-
68#include <QtCore/qdir.h>-
69#endif-
70#if defined(Q_OS_LINUX) && !defined(Q_OS_ANDROID)-
71#include <link.h>-
72#endif-
73#ifdef Q_OS_DARWIN-
74#include "private/qcore_mac_p.h"-
75#endif-
76-
77#include <algorithm>-
78-
79QT_BEGIN_NAMESPACE-
80-
81/*-
82 Note to maintainer:-
83 --------------------
84-
85 We load OpenSSL symbols dynamically. Because symbols are known to-
86 disappear, and signatures sometimes change, between releases, we need to-
87 be careful about how this is done. To ensure we don't end up dereferencing-
88 null function pointers, and continue running even if certain functions are-
89 missing, we define helper functions for each of the symbols we load from-
90 OpenSSL, all prefixed with "q_" (declared in-
91 qsslsocket_openssl_symbols_p.h). So instead of calling SSL_connect-
92 directly, we call q_SSL_connect, which is a function that checks if the-
93 actual SSL_connect fptr is null, and returns a failure if it is, or calls-
94 SSL_connect if it isn't.-
95-
96 This requires a somewhat tedious process of declaring each function we-
97 want to call in OpenSSL thrice: once with the q_, in _p.h, once using the-
98 DEFINEFUNC macros below, and once in the function that actually resolves-
99 the symbols, below the DEFINEFUNC declarations below.-
100-
101 There's one DEFINEFUNC macro declared for every number of arguments-
102 exposed by OpenSSL (feel free to extend when needed). The easiest thing to-
103 do is to find an existing entry that matches the arg count of the function-
104 you want to import, and do the same.-
105-
106 The first macro arg is the function return type. The second is the-
107 verbatim name of the function/symbol. Then follows a list of N pairs of-
108 argument types with a variable name, and just the variable name (char *a,-
109 a, char *b, b, etc). Finally there's two arguments - a suitable return-
110 statement for the error case (for an int function, return 0 or return -1-
111 is usually right). Then either just "return" or DUMMYARG, the latter being-
112 for void functions.-
113-
114 Note: Take into account that these macros and declarations are processed-
115 at compile-time, and the result depends on the OpenSSL headers the-
116 compiling host has installed, but the symbols are resolved at run-time,-
117 possibly with a different version of OpenSSL.-
118*/-
119-
120#ifndef QT_LINKED_OPENSSL-
121-
122namespace {-
123void qsslSocketUnresolvedSymbolWarning(const char *functionName)-
124{-
125 qCWarning(lcSsl, "QSslSocket: cannot call unresolved function %s", functionName);-
126}-
127-
128#ifndef QT_NO_LIBRARY-
129void qsslSocketCannotResolveSymbolWarning(const char *functionName)-
130{-
131 qCWarning(lcSsl, "QSslSocket: cannot resolve %s", functionName);-
132}-
133#endif-
134-
135}-
136-
137#endif // QT_LINKED_OPENSSL-
138-
139#ifdef SSLEAY_MACROS-
140DEFINEFUNC3(void *, ASN1_dup, i2d_of_void *a, a, d2i_of_void *b, b, char *c, c, return 0, return)-
141#endif-
142DEFINEFUNC(long, ASN1_INTEGER_get, ASN1_INTEGER *a, a, return 0, return)-
143DEFINEFUNC(unsigned char *, ASN1_STRING_data, ASN1_STRING *a, a, return 0, return)-
144DEFINEFUNC(int, ASN1_STRING_length, ASN1_STRING *a, a, return 0, return)-
145DEFINEFUNC2(int, ASN1_STRING_to_UTF8, unsigned char **a, a, ASN1_STRING *b, b, return 0, return);-
146DEFINEFUNC4(long, BIO_ctrl, BIO *a, a, int b, b, long c, c, void *d, d, return -1, return)-
147DEFINEFUNC(int, BIO_free, BIO *a, a, return 0, return)-
148DEFINEFUNC(BIO *, BIO_new, BIO_METHOD *a, a, return 0, return)-
149DEFINEFUNC2(BIO *, BIO_new_mem_buf, void *a, a, int b, b, return 0, return)-
150DEFINEFUNC3(int, BIO_read, BIO *a, a, void *b, b, int c, c, return -1, return)-
151DEFINEFUNC(BIO_METHOD *, BIO_s_mem, void, DUMMYARG, return 0, return)-
152DEFINEFUNC3(int, BIO_write, BIO *a, a, const void *b, b, int c, c, return -1, return)-
153DEFINEFUNC(int, BN_num_bits, const BIGNUM *a, a, return 0, return)-
154#ifndef OPENSSL_NO_EC-
155DEFINEFUNC(const EC_GROUP*, EC_KEY_get0_group, const EC_KEY* k, k, return 0, return)-
156DEFINEFUNC(int, EC_GROUP_get_degree, const EC_GROUP* g, g, return 0, return)-
157#endif-
158DEFINEFUNC(int, CRYPTO_num_locks, DUMMYARG, DUMMYARG, return 0, return)-
159DEFINEFUNC(void, CRYPTO_set_locking_callback, void (*a)(int, int, const char *, int), a, return, DUMMYARG)-
160DEFINEFUNC(void, CRYPTO_set_id_callback, unsigned long (*a)(), a, return, DUMMYARG)-
161DEFINEFUNC(void, CRYPTO_free, void *a, a, return, DUMMYARG)-
162DEFINEFUNC(DSA *, DSA_new, DUMMYARG, DUMMYARG, return 0, return)-
163DEFINEFUNC(void, DSA_free, DSA *a, a, return, DUMMYARG)-
164DEFINEFUNC3(X509 *, d2i_X509, X509 **a, a, const unsigned char **b, b, long c, c, return 0, return)-
165DEFINEFUNC2(char *, ERR_error_string, unsigned long a, a, char *b, b, return 0, return)-
166DEFINEFUNC(unsigned long, ERR_get_error, DUMMYARG, DUMMYARG, return 0, return)-
167DEFINEFUNC(void, ERR_free_strings, void, DUMMYARG, return, DUMMYARG)-
168DEFINEFUNC(void, EVP_CIPHER_CTX_cleanup, EVP_CIPHER_CTX *a, a, return, DUMMYARG)-
169DEFINEFUNC(void, EVP_CIPHER_CTX_init, EVP_CIPHER_CTX *a, a, return, DUMMYARG)-
170DEFINEFUNC4(int, EVP_CIPHER_CTX_ctrl, EVP_CIPHER_CTX *ctx, ctx, int type, type, int arg, arg, void *ptr, ptr, return 0, return);-
171DEFINEFUNC2(int, EVP_CIPHER_CTX_set_key_length, EVP_CIPHER_CTX *ctx, ctx, int keylen, keylen, return 0, return)-
172DEFINEFUNC5(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);-
173DEFINEFUNC5(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);-
174DEFINEFUNC3(int, EVP_CipherFinal, EVP_CIPHER_CTX *ctx, ctx, unsigned char *out, out, int *outl, outl, return 0, return);-
175DEFINEFUNC(const EVP_CIPHER *, EVP_des_cbc, DUMMYARG, DUMMYARG, return 0, return)-
176DEFINEFUNC(const EVP_CIPHER *, EVP_des_ede3_cbc, DUMMYARG, DUMMYARG, return 0, return)-
177DEFINEFUNC(const EVP_CIPHER *, EVP_rc2_cbc, DUMMYARG, DUMMYARG, return 0, return)-
178DEFINEFUNC3(int, EVP_PKEY_assign, EVP_PKEY *a, a, int b, b, char *c, c, return -1, return)-
179DEFINEFUNC2(int, EVP_PKEY_set1_RSA, EVP_PKEY *a, a, RSA *b, b, return -1, return)-
180DEFINEFUNC2(int, EVP_PKEY_set1_DSA, EVP_PKEY *a, a, DSA *b, b, return -1, return)-
181#ifndef OPENSSL_NO_EC-
182DEFINEFUNC2(int, EVP_PKEY_set1_EC_KEY, EVP_PKEY *a, a, EC_KEY *b, b, return -1, return)-
183#endif-
184DEFINEFUNC(void, EVP_PKEY_free, EVP_PKEY *a, a, return, DUMMYARG)-
185DEFINEFUNC(DSA *, EVP_PKEY_get1_DSA, EVP_PKEY *a, a, return 0, return)-
186DEFINEFUNC(RSA *, EVP_PKEY_get1_RSA, EVP_PKEY *a, a, return 0, return)-
187#ifndef OPENSSL_NO_EC-
188DEFINEFUNC(EC_KEY *, EVP_PKEY_get1_EC_KEY, EVP_PKEY *a, a, return 0, return)-
189#endif-
190DEFINEFUNC(EVP_PKEY *, EVP_PKEY_new, DUMMYARG, DUMMYARG, return 0, return)-
191DEFINEFUNC(int, EVP_PKEY_type, int a, a, return NID_undef, return)-
192DEFINEFUNC2(int, i2d_X509, X509 *a, a, unsigned char **b, b, return -1, return)-
193DEFINEFUNC(const char *, OBJ_nid2sn, int a, a, return 0, return)-
194DEFINEFUNC(const char *, OBJ_nid2ln, int a, a, return 0, return)-
195DEFINEFUNC(int, OBJ_sn2nid, const char *s, s, return 0, return)-
196DEFINEFUNC(int, OBJ_ln2nid, const char *s, s, return 0, return)-
197DEFINEFUNC3(int, i2t_ASN1_OBJECT, char *a, a, int b, b, ASN1_OBJECT *c, c, return -1, return)-
198DEFINEFUNC4(int, OBJ_obj2txt, char *a, a, int b, b, ASN1_OBJECT *c, c, int d, d, return -1, return)-
199-
200DEFINEFUNC(int, OBJ_obj2nid, const ASN1_OBJECT *a, a, return NID_undef, return)-
201#ifdef SSLEAY_MACROS-
202DEFINEFUNC6(void *, PEM_ASN1_read_bio, d2i_of_void *a, a, const char *b, b, BIO *c, c, void **d, d, pem_password_cb *e, e, void *f, f, return 0, return)-
203DEFINEFUNC6(void *, PEM_ASN1_write_bio, d2i_of_void *a, a, const char *b, b, BIO *c, c, void **d, d, pem_password_cb *e, e, void *f, f, return 0, return)-
204#else-
205DEFINEFUNC4(DSA *, PEM_read_bio_DSAPrivateKey, BIO *a, a, DSA **b, b, pem_password_cb *c, c, void *d, d, return 0, return)-
206DEFINEFUNC4(RSA *, PEM_read_bio_RSAPrivateKey, BIO *a, a, RSA **b, b, pem_password_cb *c, c, void *d, d, return 0, return)-
207#ifndef OPENSSL_NO_EC-
208DEFINEFUNC4(EC_KEY *, PEM_read_bio_ECPrivateKey, BIO *a, a, EC_KEY **b, b, pem_password_cb *c, c, void *d, d, return 0, return)-
209#endif-
210DEFINEFUNC7(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)-
211DEFINEFUNC7(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)-
212#ifndef OPENSSL_NO_EC-
213DEFINEFUNC7(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)-
214#endif-
215#endif-
216DEFINEFUNC4(DSA *, PEM_read_bio_DSA_PUBKEY, BIO *a, a, DSA **b, b, pem_password_cb *c, c, void *d, d, return 0, return)-
217DEFINEFUNC4(RSA *, PEM_read_bio_RSA_PUBKEY, BIO *a, a, RSA **b, b, pem_password_cb *c, c, void *d, d, return 0, return)-
218#ifndef OPENSSL_NO_EC-
219DEFINEFUNC4(EC_KEY *, PEM_read_bio_EC_PUBKEY, BIO *a, a, EC_KEY **b, b, pem_password_cb *c, c, void *d, d, return 0, return)-
220#endif-
221DEFINEFUNC2(int, PEM_write_bio_DSA_PUBKEY, BIO *a, a, DSA *b, b, return 0, return)-
222DEFINEFUNC2(int, PEM_write_bio_RSA_PUBKEY, BIO *a, a, RSA *b, b, return 0, return)-
223#ifndef OPENSSL_NO_EC-
224DEFINEFUNC2(int, PEM_write_bio_EC_PUBKEY, BIO *a, a, EC_KEY *b, b, return 0, return)-
225#endif-
226DEFINEFUNC2(void, RAND_seed, const void *a, a, int b, b, return, DUMMYARG)-
227DEFINEFUNC(int, RAND_status, void, DUMMYARG, return -1, return)-
228DEFINEFUNC(RSA *, RSA_new, DUMMYARG, DUMMYARG, return 0, return)-
229DEFINEFUNC(void, RSA_free, RSA *a, a, return, DUMMYARG)-
230DEFINEFUNC(int, sk_num, STACK *a, a, return -1, return)-
231DEFINEFUNC2(void, sk_pop_free, STACK *a, a, void (*b)(void*), b, return, DUMMYARG)-
232#if OPENSSL_VERSION_NUMBER >= 0x10000000L-
233DEFINEFUNC(_STACK *, sk_new_null, DUMMYARG, DUMMYARG, return 0, return)-
234DEFINEFUNC2(void, sk_push, _STACK *a, a, void *b, b, return, DUMMYARG)-
235DEFINEFUNC(void, sk_free, _STACK *a, a, return, DUMMYARG)-
236DEFINEFUNC2(void *, sk_value, STACK *a, a, int b, b, return 0, return)-
237#else-
238DEFINEFUNC(STACK *, sk_new_null, DUMMYARG, DUMMYARG, return 0, return)-
239DEFINEFUNC2(void, sk_push, STACK *a, a, char *b, b, return, DUMMYARG)-
240DEFINEFUNC(void, sk_free, STACK *a, a, return, DUMMYARG)-
241DEFINEFUNC2(char *, sk_value, STACK *a, a, int b, b, return 0, return)-
242#endif-
243DEFINEFUNC(int, SSL_accept, SSL *a, a, return -1, return)-
244DEFINEFUNC(int, SSL_clear, SSL *a, a, return -1, return)-
245DEFINEFUNC3(char *, SSL_CIPHER_description, SSL_CIPHER *a, a, char *b, b, int c, c, return 0, return)-
246DEFINEFUNC2(int, SSL_CIPHER_get_bits, SSL_CIPHER *a, a, int *b, b, return 0, return)-
247DEFINEFUNC(int, SSL_connect, SSL *a, a, return -1, return)-
248DEFINEFUNC(int, SSL_CTX_check_private_key, const SSL_CTX *a, a, return -1, return)-
249DEFINEFUNC4(long, SSL_CTX_ctrl, SSL_CTX *a, a, int b, b, long c, c, void *d, d, return -1, return)-
250DEFINEFUNC(void, SSL_CTX_free, SSL_CTX *a, a, return, DUMMYARG)-
251#if OPENSSL_VERSION_NUMBER >= 0x10000000L-
252DEFINEFUNC(SSL_CTX *, SSL_CTX_new, const SSL_METHOD *a, a, return 0, return)-
253#else-
254DEFINEFUNC(SSL_CTX *, SSL_CTX_new, SSL_METHOD *a, a, return 0, return)-
255#endif-
256DEFINEFUNC2(int, SSL_CTX_set_cipher_list, SSL_CTX *a, a, const char *b, b, return -1, return)-
257DEFINEFUNC(int, SSL_CTX_set_default_verify_paths, SSL_CTX *a, a, return -1, return)-
258DEFINEFUNC3(void, SSL_CTX_set_verify, SSL_CTX *a, a, int b, b, int (*c)(int, X509_STORE_CTX *), c, return, DUMMYARG)-
259DEFINEFUNC2(void, SSL_CTX_set_verify_depth, SSL_CTX *a, a, int b, b, return, DUMMYARG)-
260DEFINEFUNC2(int, SSL_CTX_use_certificate, SSL_CTX *a, a, X509 *b, b, return -1, return)-
261DEFINEFUNC3(int, SSL_CTX_use_certificate_file, SSL_CTX *a, a, const char *b, b, int c, c, return -1, return)-
262DEFINEFUNC2(int, SSL_CTX_use_PrivateKey, SSL_CTX *a, a, EVP_PKEY *b, b, return -1, return)-
263DEFINEFUNC2(int, SSL_CTX_use_RSAPrivateKey, SSL_CTX *a, a, RSA *b, b, return -1, return)-
264DEFINEFUNC3(int, SSL_CTX_use_PrivateKey_file, SSL_CTX *a, a, const char *b, b, int c, c, return -1, return)-
265DEFINEFUNC(X509_STORE *, SSL_CTX_get_cert_store, const SSL_CTX *a, a, return 0, return)-
266DEFINEFUNC(void, SSL_free, SSL *a, a, return, DUMMYARG)-
267DEFINEFUNC(STACK_OF(SSL_CIPHER) *, SSL_get_ciphers, const SSL *a, a, return 0, return)-
268#if OPENSSL_VERSION_NUMBER >= 0x10000000L-
269DEFINEFUNC(const SSL_CIPHER *, SSL_get_current_cipher, SSL *a, a, return 0, return)-
270#else-
271DEFINEFUNC(SSL_CIPHER *, SSL_get_current_cipher, SSL *a, a, return 0, return)-
272#endif-
273DEFINEFUNC(int, SSL_version, const SSL *a, a, return 0, return)-
274DEFINEFUNC2(int, SSL_get_error, SSL *a, a, int b, b, return -1, return)-
275DEFINEFUNC(STACK_OF(X509) *, SSL_get_peer_cert_chain, SSL *a, a, return 0, return)-
276DEFINEFUNC(X509 *, SSL_get_peer_certificate, SSL *a, a, return 0, return)-
277#if OPENSSL_VERSION_NUMBER >= 0x00908000L-
278// 0.9.8 broke SC and BC by changing this function's signature.-
279DEFINEFUNC(long, SSL_get_verify_result, const SSL *a, a, return -1, return)-
280#else-
281DEFINEFUNC(long, SSL_get_verify_result, SSL *a, a, return -1, return)-
282#endif-
283DEFINEFUNC(int, SSL_library_init, void, DUMMYARG, return -1, return)-
284DEFINEFUNC(void, SSL_load_error_strings, void, DUMMYARG, return, DUMMYARG)-
285DEFINEFUNC(SSL *, SSL_new, SSL_CTX *a, a, return 0, return)-
286DEFINEFUNC4(long, SSL_ctrl, SSL *a, a, int cmd, cmd, long larg, larg, void *parg, parg, return -1, return)-
287DEFINEFUNC3(int, SSL_read, SSL *a, a, void *b, b, int c, c, return -1, return)-
288DEFINEFUNC3(void, SSL_set_bio, SSL *a, a, BIO *b, b, BIO *c, c, return, DUMMYARG)-
289DEFINEFUNC(void, SSL_set_accept_state, SSL *a, a, return, DUMMYARG)-
290DEFINEFUNC(void, SSL_set_connect_state, SSL *a, a, return, DUMMYARG)-
291DEFINEFUNC(int, SSL_shutdown, SSL *a, a, return -1, return)-
292DEFINEFUNC2(int, SSL_set_session, SSL* to, to, SSL_SESSION *session, session, return -1, return)-
293DEFINEFUNC(void, SSL_SESSION_free, SSL_SESSION *ses, ses, return, DUMMYARG)-
294DEFINEFUNC(SSL_SESSION*, SSL_get1_session, SSL *ssl, ssl, return 0, return)-
295DEFINEFUNC(SSL_SESSION*, SSL_get_session, const SSL *ssl, ssl, return 0, return)-
296#if OPENSSL_VERSION_NUMBER >= 0x10001000L-
297DEFINEFUNC5(int, SSL_get_ex_new_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)-
298DEFINEFUNC3(int, SSL_set_ex_data, SSL *ssl, ssl, int idx, idx, void *arg, arg, return 0, return)-
299DEFINEFUNC2(void *, SSL_get_ex_data, const SSL *ssl, ssl, int idx, idx, return NULL, return)-
300#endif-
301#if OPENSSL_VERSION_NUMBER >= 0x10001000L && !defined(OPENSSL_NO_PSK)-
302DEFINEFUNC2(void, SSL_set_psk_client_callback, SSL* ssl, ssl, q_psk_client_callback_t callback, callback, return, DUMMYARG)-
303#endif-
304#if OPENSSL_VERSION_NUMBER >= 0x10000000L-
305#ifndef OPENSSL_NO_SSL2-
306DEFINEFUNC(const SSL_METHOD *, SSLv2_client_method, DUMMYARG, DUMMYARG, return 0, return)-
307#endif-
308#ifndef OPENSSL_NO_SSL3_METHOD-
309DEFINEFUNC(const SSL_METHOD *, SSLv3_client_method, DUMMYARG, DUMMYARG, return 0, return)-
310#endif-
311DEFINEFUNC(const SSL_METHOD *, SSLv23_client_method, DUMMYARG, DUMMYARG, return 0, return)-
312DEFINEFUNC(const SSL_METHOD *, TLSv1_client_method, DUMMYARG, DUMMYARG, return 0, return)-
313#if OPENSSL_VERSION_NUMBER >= 0x10001000L-
314DEFINEFUNC(const SSL_METHOD *, TLSv1_1_client_method, DUMMYARG, DUMMYARG, return 0, return)-
315DEFINEFUNC(const SSL_METHOD *, TLSv1_2_client_method, DUMMYARG, DUMMYARG, return 0, return)-
316#endif-
317#ifndef OPENSSL_NO_SSL2-
318DEFINEFUNC(const SSL_METHOD *, SSLv2_server_method, DUMMYARG, DUMMYARG, return 0, return)-
319#endif-
320#ifndef OPENSSL_NO_SSL3_METHOD-
321DEFINEFUNC(const SSL_METHOD *, SSLv3_server_method, DUMMYARG, DUMMYARG, return 0, return)-
322#endif-
323DEFINEFUNC(const SSL_METHOD *, SSLv23_server_method, DUMMYARG, DUMMYARG, return 0, return)-
324DEFINEFUNC(const SSL_METHOD *, TLSv1_server_method, DUMMYARG, DUMMYARG, return 0, return)-
325#if OPENSSL_VERSION_NUMBER >= 0x10001000L-
326DEFINEFUNC(const SSL_METHOD *, TLSv1_1_server_method, DUMMYARG, DUMMYARG, return 0, return)-
327DEFINEFUNC(const SSL_METHOD *, TLSv1_2_server_method, DUMMYARG, DUMMYARG, return 0, return)-
328#endif-
329#else-
330#ifndef OPENSSL_NO_SSL2-
331DEFINEFUNC(SSL_METHOD *, SSLv2_client_method, DUMMYARG, DUMMYARG, return 0, return)-
332#endif-
333#ifndef OPENSSL_NO_SSL3_METHOD-
334DEFINEFUNC(SSL_METHOD *, SSLv3_client_method, DUMMYARG, DUMMYARG, return 0, return)-
335#endif-
336DEFINEFUNC(SSL_METHOD *, SSLv23_client_method, DUMMYARG, DUMMYARG, return 0, return)-
337DEFINEFUNC(SSL_METHOD *, TLSv1_client_method, DUMMYARG, DUMMYARG, return 0, return)-
338#ifndef OPENSSL_NO_SSL2-
339DEFINEFUNC(SSL_METHOD *, SSLv2_server_method, DUMMYARG, DUMMYARG, return 0, return)-
340#endif-
341#ifndef OPENSSL_NO_SSL3_METHOD-
342DEFINEFUNC(SSL_METHOD *, SSLv3_server_method, DUMMYARG, DUMMYARG, return 0, return)-
343#endif-
344DEFINEFUNC(SSL_METHOD *, SSLv23_server_method, DUMMYARG, DUMMYARG, return 0, return)-
345DEFINEFUNC(SSL_METHOD *, TLSv1_server_method, DUMMYARG, DUMMYARG, return 0, return)-
346#endif-
347DEFINEFUNC3(int, SSL_write, SSL *a, a, const void *b, b, int c, c, return -1, return)-
348DEFINEFUNC2(int, X509_cmp, X509 *a, a, X509 *b, b, return -1, return)-
349#ifndef SSLEAY_MACROS-
350DEFINEFUNC(X509 *, X509_dup, X509 *a, a, return 0, return)-
351#endif-
352DEFINEFUNC2(void, X509_print, BIO *a, a, X509 *b, b, return, DUMMYARG);-
353DEFINEFUNC(ASN1_OBJECT *, X509_EXTENSION_get_object, X509_EXTENSION *a, a, return 0, return)-
354DEFINEFUNC(void, X509_free, X509 *a, a, return, DUMMYARG)-
355DEFINEFUNC2(X509_EXTENSION *, X509_get_ext, X509 *a, a, int b, b, return 0, return)-
356DEFINEFUNC(int, X509_get_ext_count, X509 *a, a, return 0, return)-
357DEFINEFUNC4(void *, X509_get_ext_d2i, X509 *a, a, int b, b, int *c, c, int *d, d, return 0, return)-
358DEFINEFUNC(const X509V3_EXT_METHOD *, X509V3_EXT_get, X509_EXTENSION *a, a, return 0, return)-
359DEFINEFUNC(void *, X509V3_EXT_d2i, X509_EXTENSION *a, a, return 0, return)-
360DEFINEFUNC(int, X509_EXTENSION_get_critical, X509_EXTENSION *a, a, return 0, return)-
361DEFINEFUNC(ASN1_OCTET_STRING *, X509_EXTENSION_get_data, X509_EXTENSION *a, a, return 0, return)-
362DEFINEFUNC(void, BASIC_CONSTRAINTS_free, BASIC_CONSTRAINTS *a, a, return, DUMMYARG)-
363DEFINEFUNC(void, AUTHORITY_KEYID_free, AUTHORITY_KEYID *a, a, return, DUMMYARG)-
364#if OPENSSL_VERSION_NUMBER >= 0x10000000L-
365DEFINEFUNC2(int, ASN1_STRING_print, BIO *a, a, const ASN1_STRING *b, b, return 0, return)-
366#else-
367DEFINEFUNC2(int, ASN1_STRING_print, BIO *a, a, ASN1_STRING *b, b, return 0, return)-
368#endif-
369DEFINEFUNC2(int, X509_check_issued, X509 *a, a, X509 *b, b, return -1, return)-
370DEFINEFUNC(X509_NAME *, X509_get_issuer_name, X509 *a, a, return 0, return)-
371DEFINEFUNC(X509_NAME *, X509_get_subject_name, X509 *a, a, return 0, return)-
372DEFINEFUNC(int, X509_verify_cert, X509_STORE_CTX *a, a, return -1, return)-
373DEFINEFUNC(int, X509_NAME_entry_count, X509_NAME *a, a, return 0, return)-
374DEFINEFUNC2(X509_NAME_ENTRY *, X509_NAME_get_entry, X509_NAME *a, a, int b, b, return 0, return)-
375DEFINEFUNC(ASN1_STRING *, X509_NAME_ENTRY_get_data, X509_NAME_ENTRY *a, a, return 0, return)-
376DEFINEFUNC(ASN1_OBJECT *, X509_NAME_ENTRY_get_object, X509_NAME_ENTRY *a, a, return 0, return)-
377DEFINEFUNC(EVP_PKEY *, X509_PUBKEY_get, X509_PUBKEY *a, a, return 0, return)-
378DEFINEFUNC(void, X509_STORE_free, X509_STORE *a, a, return, DUMMYARG)-
379DEFINEFUNC(X509_STORE *, X509_STORE_new, DUMMYARG, DUMMYARG, return 0, return)-
380DEFINEFUNC2(int, X509_STORE_add_cert, X509_STORE *a, a, X509 *b, b, return 0, return)-
381DEFINEFUNC(void, X509_STORE_CTX_free, X509_STORE_CTX *a, a, return, DUMMYARG)-
382DEFINEFUNC4(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)-
383DEFINEFUNC2(int, X509_STORE_CTX_set_purpose, X509_STORE_CTX *a, a, int b, b, return -1, return)-
384DEFINEFUNC(int, X509_STORE_CTX_get_error, X509_STORE_CTX *a, a, return -1, return)-
385DEFINEFUNC(int, X509_STORE_CTX_get_error_depth, X509_STORE_CTX *a, a, return -1, return)-
386DEFINEFUNC(X509 *, X509_STORE_CTX_get_current_cert, X509_STORE_CTX *a, a, return 0, return)-
387DEFINEFUNC(STACK_OF(X509) *, X509_STORE_CTX_get_chain, X509_STORE_CTX *a, a, return 0, return)-
388DEFINEFUNC(X509_STORE_CTX *, X509_STORE_CTX_new, DUMMYARG, DUMMYARG, return 0, return)-
389#ifdef SSLEAY_MACROS-
390DEFINEFUNC2(int, i2d_DSAPrivateKey, const DSA *a, a, unsigned char **b, b, return -1, return)-
391DEFINEFUNC2(int, i2d_RSAPrivateKey, const RSA *a, a, unsigned char **b, b, return -1, return)-
392#ifndef OPENSSL_NO_EC-
393DEFINEFUNC2(int, i2d_ECPrivateKey, const EC_KEY *a, a, unsigned char **b, b, return -1, return)-
394#endif-
395DEFINEFUNC3(RSA *, d2i_RSAPrivateKey, RSA **a, a, unsigned char **b, b, long c, c, return 0, return)-
396DEFINEFUNC3(DSA *, d2i_DSAPrivateKey, DSA **a, a, unsigned char **b, b, long c, c, return 0, return)-
397#ifndef OPENSSL_NO_EC-
398DEFINEFUNC3(EC_KEY *, d2i_ECPrivateKey, EC_KEY **a, a, unsigned char **b, b, long c, c, return 0, return)-
399#endif-
400#endif-
401DEFINEFUNC(void, OPENSSL_add_all_algorithms_noconf, void, DUMMYARG, return, DUMMYARG)-
402DEFINEFUNC(void, OPENSSL_add_all_algorithms_conf, void, DUMMYARG, return, DUMMYARG)-
403DEFINEFUNC3(int, SSL_CTX_load_verify_locations, SSL_CTX *ctx, ctx, const char *CAfile, CAfile, const char *CApath, CApath, return 0, return)-
404DEFINEFUNC(long, SSLeay, void, DUMMYARG, return 0, return)-
405DEFINEFUNC(const char *, SSLeay_version, int a, a, return 0, return)-
406DEFINEFUNC2(int, i2d_SSL_SESSION, SSL_SESSION *in, in, unsigned char **pp, pp, return 0, return)-
407DEFINEFUNC3(SSL_SESSION *, d2i_SSL_SESSION, SSL_SESSION **a, a, const unsigned char **pp, pp, long length, length, return 0, return)-
408#if OPENSSL_VERSION_NUMBER >= 0x1000100fL && !defined(OPENSSL_NO_NEXTPROTONEG)-
409DEFINEFUNC6(int, SSL_select_next_proto, unsigned char **out, out, unsigned char *outlen, outlen,-
410 const unsigned char *in, in, unsigned int inlen, inlen,-
411 const unsigned char *client, client, unsigned int client_len, client_len,-
412 return -1, return)-
413DEFINEFUNC3(void, SSL_CTX_set_next_proto_select_cb, SSL_CTX *s, s,-
414 int (*cb) (SSL *ssl, unsigned char **out,-
415 unsigned char *outlen,-
416 const unsigned char *in,-
417 unsigned int inlen, void *arg), cb,-
418 void *arg, arg, return, DUMMYARG)-
419DEFINEFUNC3(void, SSL_get0_next_proto_negotiated, const SSL *s, s,-
420 const unsigned char **data, data, unsigned *len, len, return, DUMMYARG)-
421#endif // OPENSSL_VERSION_NUMBER >= 0x1000100fL ...-
422DEFINEFUNC(DH *, DH_new, DUMMYARG, DUMMYARG, return 0, return)-
423DEFINEFUNC(void, DH_free, DH *dh, dh, return, DUMMYARG)-
424DEFINEFUNC3(DH *, d2i_DHparams, DH**a, a, const unsigned char **pp, pp, long length, length, return 0, return)-
425DEFINEFUNC3(BIGNUM *, BN_bin2bn, const unsigned char *s, s, int len, len, BIGNUM *ret, ret, return 0, return)-
426#ifndef OPENSSL_NO_EC-
427DEFINEFUNC(EC_KEY *, EC_KEY_dup, const EC_KEY *ec, ec, return 0, return)-
428DEFINEFUNC(EC_KEY *, EC_KEY_new_by_curve_name, int nid, nid, return 0, return)-
429DEFINEFUNC(void, EC_KEY_free, EC_KEY *ecdh, ecdh, return, DUMMYARG)-
430DEFINEFUNC2(size_t, EC_get_builtin_curves, EC_builtin_curve * r, r, size_t nitems, nitems, return 0, return)-
431#if OPENSSL_VERSION_NUMBER >= 0x10002000L-
432DEFINEFUNC(int, EC_curve_nist2nid, const char *name, name, return 0, return)-
433#endif // OPENSSL_VERSION_NUMBER >= 0x10002000L-
434#endif // OPENSSL_NO_EC-
435-
436DEFINEFUNC5(int, PKCS12_parse, PKCS12 *p12, p12, const char *pass, pass, EVP_PKEY **pkey, pkey, \-
437 X509 **cert, cert, STACK_OF(X509) **ca, ca, return 1, return);-
438DEFINEFUNC2(PKCS12 *, d2i_PKCS12_bio, BIO *bio, bio, PKCS12 **pkcs12, pkcs12, return 0, return);-
439DEFINEFUNC(void, PKCS12_free, PKCS12 *pkcs12, pkcs12, return, DUMMYARG)-
440-
441#define RESOLVEFUNC(func) \-
442 if (!(_q_##func = _q_PTR_##func(libs.first->resolve(#func))) \-
443 && !(_q_##func = _q_PTR_##func(libs.second->resolve(#func)))) \-
444 qsslSocketCannotResolveSymbolWarning(#func);-
445-
446#if !defined QT_LINKED_OPENSSL-
447-
448#ifdef QT_NO_LIBRARY-
449bool q_resolveOpenSslSymbols()-
450{-
451 qCWarning(lcSsl, "QSslSocket: unable to resolve symbols. "-
452 "QT_NO_LIBRARY is defined which means runtime resolving of "-
453 "libraries won't work.");-
454 qCWarning(lcSsl, "Either compile Qt statically or with support for runtime resolving "-
455 "of libraries.");-
456 return false;-
457}-
458#else-
459-
460# ifdef Q_OS_UNIX-
461struct NumericallyLess-
462{-
463 typedef bool result_type;-
464 result_type operator()(const QStringRef &lhs, const QStringRef &rhs) const-
465 {-
466 bool ok = false;-
467 int b = 0;-
468 int a = lhs.toInt(&ok);-
469 if (ok)-
470 b = rhs.toInt(&ok);-
471 if (ok) {-
472 // both toInt succeeded-
473 return a < b;-
474 } else {-
475 // compare as strings;-
476 return lhs < rhs;-
477 }-
478 }-
479};-
480-
481struct LibGreaterThan-
482{-
483 typedef bool result_type;-
484 result_type operator()(const QString &lhs, const QString &rhs) const-
485 {-
486 const QVector<QStringRef> lhsparts = lhs.splitRef(QLatin1Char('.'));-
487 const QVector<QStringRef> rhsparts = rhs.splitRef(QLatin1Char('.'));-
488 Q_ASSERT(lhsparts.count() > 1 && rhsparts.count() > 1);-
489-
490 // note: checking rhs < lhs, the same as lhs > rhs-
491 return std::lexicographical_compare(rhsparts.begin() + 1, rhsparts.end(),-
492 lhsparts.begin() + 1, lhsparts.end(),-
493 NumericallyLess());-
494 }-
495};-
496-
497#if defined(Q_OS_LINUX) && !defined(Q_OS_ANDROID)-
498static int dlIterateCallback(struct dl_phdr_info *info, size_t size, void *data)-
499{-
500 if (size < sizeof (info->dlpi_addr) + sizeof (info->dlpi_name))-
501 return 1;-
502 QSet<QString> *paths = (QSet<QString> *)data;-
503 QString path = QString::fromLocal8Bit(info->dlpi_name);-
504 if (!path.isEmpty()) {-
505 QFileInfo fi(path);-
506 path = fi.absolutePath();-
507 if (!path.isEmpty())-
508 paths->insert(path);-
509 }-
510 return 0;-
511}-
512#endif-
513-
514static QStringList libraryPathList()-
515{-
516 QStringList paths;-
517# ifdef Q_OS_DARWIN-
518 paths = QString::fromLatin1(qgetenv("DYLD_LIBRARY_PATH"))-
519 .split(QLatin1Char(':'), QString::SkipEmptyParts);-
520-
521 // search in .app/Contents/Frameworks-
522 UInt32 packageType;-
523 CFBundleGetPackageInfo(CFBundleGetMainBundle(), &packageType, NULL);-
524 if (packageType == FOUR_CHAR_CODE('APPL')) {-
525 QUrl bundleUrl = QUrl::fromCFURL(QCFType<CFURLRef>(CFBundleCopyBundleURL(CFBundleGetMainBundle())));-
526 QUrl frameworksUrl = QUrl::fromCFURL(QCFType<CFURLRef>(CFBundleCopyPrivateFrameworksURL(CFBundleGetMainBundle())));-
527 paths << bundleUrl.resolved(frameworksUrl).path();-
528 }-
529# else-
530 paths = QString::fromLatin1(qgetenv("LD_LIBRARY_PATH"))-
531 .split(QLatin1Char(':'), QString::SkipEmptyParts);-
532# endif-
533 paths << QLatin1String("/lib") << QLatin1String("/usr/lib") << QLatin1String("/usr/local/lib");-
534 paths << QLatin1String("/lib64") << QLatin1String("/usr/lib64") << QLatin1String("/usr/local/lib64");-
535 paths << QLatin1String("/lib32") << QLatin1String("/usr/lib32") << QLatin1String("/usr/local/lib32");-
536-
537#if defined(Q_OS_ANDROID)-
538 paths << QLatin1String("/system/lib");-
539#elif defined(Q_OS_LINUX)-
540 // discover paths of already loaded libraries-
541 QSet<QString> loadedPaths;-
542 dl_iterate_phdr(dlIterateCallback, &loadedPaths);-
543 paths.append(loadedPaths.toList());-
544#endif-
545-
546 return paths;-
547}-
548-
549Q_NEVER_INLINE-
550static QStringList findAllLibs(QLatin1String filter)-
551{-
552 const QStringList paths = libraryPathList();-
553 QStringList found;-
554 const QStringList filters((QString(filter)));-
555-
556 foreachfor (const QString &path ,: paths) {-
557 QDir dir(path);-
558 QStringList entryList = dir.entryList(filters, QDir::Files);-
559-
560 std::sort(entryList.begin(), entryList.end(), LibGreaterThan());-
561 foreachfor (const QString &entry ,: qAsConst(entryList)))-
562 found << path + QLatin1Char('/') + entry;
never executed: found << path + QLatin1Char('/') + entry;
0
563 }
never executed: end of block
0
564-
565 return found;
never executed: return found;
0
566}-
567-
568static QStringList findAllLibSsl()-
569{-
570 return findAllLibs(QLatin1String("libssl.*"));-
571}-
572-
573static QStringList findAllLibCrypto()-
574{-
575 return findAllLibs(QLatin1String("libcrypto.*"));-
576}-
577# endif-
578-
579#ifdef Q_OS_WIN-
580static bool tryToLoadOpenSslWin32Library(QLatin1String ssleay32LibName, QLatin1String libeay32LibName, QPair<QSystemLibrary*, QSystemLibrary*> &pair)-
581{-
582 pair.first = 0;-
583 pair.second = 0;-
584-
585 QSystemLibrary *ssleay32 = new QSystemLibrary(ssleay32LibName);-
586 if (!ssleay32->load(false)) {-
587 delete ssleay32;-
588 return FALSE;-
589 }-
590-
591 QSystemLibrary *libeay32 = new QSystemLibrary(libeay32LibName);-
592 if (!libeay32->load(false)) {-
593 delete ssleay32;-
594 delete libeay32;-
595 return FALSE;-
596 }-
597-
598 pair.first = ssleay32;-
599 pair.second = libeay32;-
600 return TRUE;-
601}-
602-
603static QPair<QSystemLibrary*, QSystemLibrary*> loadOpenSslWin32()-
604{-
605 QPair<QSystemLibrary*,QSystemLibrary*> pair;-
606 pair.first = 0;-
607 pair.second = 0;-
608-
609 // When OpenSSL is built using MSVC then the libraries are named 'ssleay32.dll' and 'libeay32'dll'.-
610 // When OpenSSL is built using GCC then different library names are used (depending on the OpenSSL version)-
611 // The oldest version of a GCC-based OpenSSL which can be detected by the code below is 0.9.8g (released in 2007)-
612 if (!tryToLoadOpenSslWin32Library(QLatin1String("ssleay32"), QLatin1String("libeay32"), pair)) {-
613 if (!tryToLoadOpenSslWin32Library(QLatin1String("libssl-10"), QLatin1String("libcrypto-10"), pair)) {-
614 if (!tryToLoadOpenSslWin32Library(QLatin1String("libssl-8"), QLatin1String("libcrypto-8"), pair)) {-
615 tryToLoadOpenSslWin32Library(QLatin1String("libssl-7"), QLatin1String("libcrypto-7"), pair);-
616 }-
617 }-
618 }-
619-
620 return pair;-
621}-
622#else-
623-
624static QPair<QLibrary*, QLibrary*> loadOpenSsl()-
625{-
626 QPair<QLibrary*,QLibrary*> pair;-
627-
628# if defined(Q_OS_UNIX)-
629 QLibrary *&libssl = pair.first;-
630 QLibrary *&libcrypto = pair.second;-
631 libssl = new QLibrary;-
632 libcrypto = new QLibrary;-
633-
634 // Try to find the libssl library on the system.-
635 //-
636 // Up until Qt 4.3, this only searched for the "ssl" library at version -1, that-
637 // is, libssl.so on most Unix systems. However, the .so file isn't present in-
638 // user installations because it's considered a development file.-
639 //-
640 // The right thing to do is to load the library at the major version we know how-
641 // to work with: the SHLIB_VERSION_NUMBER version (macro defined in opensslv.h)-
642 //-
643 // However, OpenSSL is a well-known case of binary-compatibility breakage. To-
644 // avoid such problems, many system integrators and Linux distributions change-
645 // the soname of the binary, letting the full version number be the soname. So-
646 // we'll find libssl.so.0.9.7, libssl.so.0.9.8, etc. in the system. For that-
647 // reason, we will search a few common paths (see findAllLibSsl() above) in hopes-
648 // we find one that works.-
649 //-
650 // It is important, however, to try the canonical name and the unversioned name-
651 // without going through the loop. By not specifying a path, we let the system-
652 // dlopen(3) function determine it for us. This will include any DT_RUNPATH or-
653 // DT_RPATH tags on our library header as well as other system-specific search-
654 // paths. See the man page for dlopen(3) on your system for more information.-
655-
656#ifdef Q_OS_OPENBSD-
657 libcrypto->setLoadHints(QLibrary::ExportExternalSymbolsHint);-
658#endif-
659#if defined(SHLIB_VERSION_NUMBER) && !defined(Q_OS_QNX) // on QNX, the libs are always libssl.so and libcrypto.so-
660 // first attempt: the canonical name is libssl.so.<SHLIB_VERSION_NUMBER>-
661 libssl->setFileNameAndVersion(QLatin1String("ssl"), QLatin1String(SHLIB_VERSION_NUMBER));-
662 libcrypto->setFileNameAndVersion(QLatin1String("crypto"), QLatin1String(SHLIB_VERSION_NUMBER));-
663 if (libcrypto->load() && libssl->load()) {
libcrypto->load()Description
TRUEevaluated 16 times by 16 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QXmlInputSource
  • tst_Spdy
  • tst_qsslcertificate - unknown status
  • tst_qsslellipticcurve - unknown status
  • tst_qsslerror - unknown status
  • tst_qsslkey - unknown status
  • tst_qsslsocket - unknown status
  • tst_qsslsocket_onDemandCertificates_member - unknown status
  • tst_qsslsocket_onDemandCertificates_static - unknown status
  • tst_qtcpsocket - unknown status
FALSEnever evaluated
libssl->load()Description
TRUEevaluated 16 times by 16 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QXmlInputSource
  • tst_Spdy
  • tst_qsslcertificate - unknown status
  • tst_qsslellipticcurve - unknown status
  • tst_qsslerror - unknown status
  • tst_qsslkey - unknown status
  • tst_qsslsocket - unknown status
  • tst_qsslsocket_onDemandCertificates_member - unknown status
  • tst_qsslsocket_onDemandCertificates_static - unknown status
  • tst_qtcpsocket - unknown status
FALSEnever evaluated
0-16
664 // libssl.so.<SHLIB_VERSION_NUMBER> and libcrypto.so.<SHLIB_VERSION_NUMBER> found-
665 return pair;
executed 16 times by 16 tests: return pair;
Executed by:
  • tst_NetworkSelfTest
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QXmlInputSource
  • tst_Spdy
  • tst_qsslcertificate - unknown status
  • tst_qsslellipticcurve - unknown status
  • tst_qsslerror - unknown status
  • tst_qsslkey - unknown status
  • tst_qsslsocket - unknown status
  • tst_qsslsocket_onDemandCertificates_member - unknown status
  • tst_qsslsocket_onDemandCertificates_static - unknown status
  • tst_qtcpsocket - unknown status
16
666 } else {-
667 libssl->unload();-
668 libcrypto->unload();-
669 }
never executed: end of block
0
670#endif-
671-
672#ifndef Q_OS_DARWIN-
673 // second attempt: find the development files libssl.so and libcrypto.so-
674 //-
675 // disabled on OS X/iOS:-
676 // OS X's /usr/lib/libssl.dylib, /usr/lib/libcrypto.dylib will be picked up in the third-
677 // attempt, _after_ <bundle>/Contents/Frameworks has been searched.-
678 // iOS does not ship a system libssl.dylib, libcrypto.dylib in the first place.-
679 libssl->setFileNameAndVersion(QLatin1String("ssl"), -1);-
680 libcrypto->setFileNameAndVersion(QLatin1String("crypto"), -1);-
681 if (libcrypto->load() && libssl->load()) {
libcrypto->load()Description
TRUEnever evaluated
FALSEnever evaluated
libssl->load()Description
TRUEnever evaluated
FALSEnever evaluated
0
682 // libssl.so.0 and libcrypto.so.0 found-
683 return pair;
never executed: return pair;
0
684 } else {-
685 libssl->unload();-
686 libcrypto->unload();-
687 }
never executed: end of block
0
688#endif-
689-
690 // third attempt: loop on the most common library paths and find libssl-
691 const QStringList sslList = findAllLibSsl();-
692 const QStringList cryptoList = findAllLibCrypto();-
693-
694 foreachfor (const QString &crypto ,: cryptoList) {-
695 libcrypto->setFileNameAndVersion(crypto, -1);-
696 if (libcrypto->load()) {
libcrypto->load()Description
TRUEnever evaluated
FALSEnever evaluated
0
697 QFileInfo fi(crypto);-
698 QString version = fi.completeSuffix();-
699-
700 foreachfor (const QString &ssl ,: sslList) {-
701 if (!ssl.endsWith(version))
!ssl.endsWith(version)Description
TRUEnever evaluated
FALSEnever evaluated
0
702 continue;
never executed: continue;
0
703-
704 libssl->setFileNameAndVersion(ssl, -1);-
705-
706 if (libssl->load()) {
libssl->load()Description
TRUEnever evaluated
FALSEnever evaluated
0
707 // libssl.so.x and libcrypto.so.x found-
708 return pair;
never executed: return pair;
0
709 } else {-
710 libssl->unload();-
711 }
never executed: end of block
0
712 }-
713 }
never executed: end of block
0
714 libcrypto->unload();-
715 }
never executed: end of block
0
716-
717 // failed to load anything-
718 delete libssl;-
719 delete libcrypto;-
720 libssl = libcrypto = 0;-
721 return pair;
never executed: return pair;
0
722-
723# else-
724 // not implemented for this platform yet-
725 return pair;-
726# endif-
727}-
728#endif-
729-
730bool q_resolveOpenSslSymbols()-
731{-
732 static bool symbolsResolved = false;-
733 static bool triedToResolveSymbols = false;-
734#ifndef QT_NO_THREAD-
735 QMutexLocker locker(QMutexPool::globalInstanceGet((void *)&q_SSL_library_init));-
736#endif-
737 if (symbolsResolved)-
738 return true;-
739 if (triedToResolveSymbols)-
740 return false;-
741 triedToResolveSymbols = true;-
742-
743#ifdef Q_OS_WIN-
744 QPair<QSystemLibrary *, QSystemLibrary *> libs = loadOpenSslWin32();-
745#else-
746 QPair<QLibrary *, QLibrary *> libs = loadOpenSsl();-
747#endif-
748 if (!libs.first || !libs.second)-
749 // failed to load them-
750 return false;-
751-
752#ifdef SSLEAY_MACROS-
753 RESOLVEFUNC(ASN1_dup)-
754#endif-
755 RESOLVEFUNC(ASN1_INTEGER_get)-
756 RESOLVEFUNC(ASN1_STRING_data)-
757 RESOLVEFUNC(ASN1_STRING_length)-
758 RESOLVEFUNC(ASN1_STRING_to_UTF8)-
759 RESOLVEFUNC(BIO_ctrl)-
760 RESOLVEFUNC(BIO_free)-
761 RESOLVEFUNC(BIO_new)-
762 RESOLVEFUNC(BIO_new_mem_buf)-
763 RESOLVEFUNC(BIO_read)-
764 RESOLVEFUNC(BIO_s_mem)-
765 RESOLVEFUNC(BIO_write)-
766#ifndef OPENSSL_NO_EC-
767 RESOLVEFUNC(EC_KEY_get0_group)-
768 RESOLVEFUNC(EC_GROUP_get_degree)-
769#endif-
770 RESOLVEFUNC(BN_num_bits)-
771 RESOLVEFUNC(CRYPTO_free)-
772 RESOLVEFUNC(CRYPTO_num_locks)-
773 RESOLVEFUNC(CRYPTO_set_id_callback)-
774 RESOLVEFUNC(CRYPTO_set_locking_callback)-
775 RESOLVEFUNC(DSA_new)-
776 RESOLVEFUNC(DSA_free)-
777 RESOLVEFUNC(ERR_error_string)-
778 RESOLVEFUNC(ERR_get_error)-
779 RESOLVEFUNC(ERR_free_strings)-
780 RESOLVEFUNC(EVP_CIPHER_CTX_cleanup)-
781 RESOLVEFUNC(EVP_CIPHER_CTX_init)-
782 RESOLVEFUNC(EVP_CIPHER_CTX_ctrl)-
783 RESOLVEFUNC(EVP_CIPHER_CTX_set_key_length)-
784 RESOLVEFUNC(EVP_CipherInit)-
785 RESOLVEFUNC(EVP_CipherUpdate)-
786 RESOLVEFUNC(EVP_CipherFinal)-
787 RESOLVEFUNC(EVP_des_cbc)-
788 RESOLVEFUNC(EVP_des_ede3_cbc)-
789 RESOLVEFUNC(EVP_rc2_cbc)-
790 RESOLVEFUNC(EVP_PKEY_assign)-
791 RESOLVEFUNC(EVP_PKEY_set1_RSA)-
792 RESOLVEFUNC(EVP_PKEY_set1_DSA)-
793#ifndef OPENSSL_NO_EC-
794 RESOLVEFUNC(EVP_PKEY_set1_EC_KEY)-
795#endif-
796 RESOLVEFUNC(EVP_PKEY_free)-
797 RESOLVEFUNC(EVP_PKEY_get1_DSA)-
798 RESOLVEFUNC(EVP_PKEY_get1_RSA)-
799#ifndef OPENSSL_NO_EC-
800 RESOLVEFUNC(EVP_PKEY_get1_EC_KEY)-
801#endif-
802 RESOLVEFUNC(EVP_PKEY_new)-
803 RESOLVEFUNC(EVP_PKEY_type)-
804 RESOLVEFUNC(OBJ_nid2sn)-
805 RESOLVEFUNC(OBJ_nid2ln)-
806 RESOLVEFUNC(OBJ_sn2nid)-
807 RESOLVEFUNC(OBJ_ln2nid)-
808 RESOLVEFUNC(i2t_ASN1_OBJECT)-
809 RESOLVEFUNC(OBJ_obj2txt)-
810 RESOLVEFUNC(OBJ_obj2nid)-
811#ifdef SSLEAY_MACROS // ### verify-
812 RESOLVEFUNC(PEM_ASN1_read_bio)-
813#else-
814 RESOLVEFUNC(PEM_read_bio_DSAPrivateKey)-
815 RESOLVEFUNC(PEM_read_bio_RSAPrivateKey)-
816#ifndef OPENSSL_NO_EC-
817 RESOLVEFUNC(PEM_read_bio_ECPrivateKey)-
818#endif-
819 RESOLVEFUNC(PEM_write_bio_DSAPrivateKey)-
820 RESOLVEFUNC(PEM_write_bio_RSAPrivateKey)-
821#ifndef OPENSSL_NO_EC-
822 RESOLVEFUNC(PEM_write_bio_ECPrivateKey)-
823#endif-
824#endif-
825 RESOLVEFUNC(PEM_read_bio_DSA_PUBKEY)-
826 RESOLVEFUNC(PEM_read_bio_RSA_PUBKEY)-
827#ifndef OPENSSL_NO_EC-
828 RESOLVEFUNC(PEM_read_bio_EC_PUBKEY)-
829#endif-
830 RESOLVEFUNC(PEM_write_bio_DSA_PUBKEY)-
831 RESOLVEFUNC(PEM_write_bio_RSA_PUBKEY)-
832#ifndef OPENSSL_NO_EC-
833 RESOLVEFUNC(PEM_write_bio_EC_PUBKEY)-
834#endif-
835 RESOLVEFUNC(RAND_seed)-
836 RESOLVEFUNC(RAND_status)-
837 RESOLVEFUNC(RSA_new)-
838 RESOLVEFUNC(RSA_free)-
839 RESOLVEFUNC(sk_new_null)-
840 RESOLVEFUNC(sk_push)-
841 RESOLVEFUNC(sk_free)-
842 RESOLVEFUNC(sk_num)-
843 RESOLVEFUNC(sk_pop_free)-
844 RESOLVEFUNC(sk_value)-
845 RESOLVEFUNC(SSL_CIPHER_description)-
846 RESOLVEFUNC(SSL_CIPHER_get_bits)-
847 RESOLVEFUNC(SSL_CTX_check_private_key)-
848 RESOLVEFUNC(SSL_CTX_ctrl)-
849 RESOLVEFUNC(SSL_CTX_free)-
850 RESOLVEFUNC(SSL_CTX_new)-
851 RESOLVEFUNC(SSL_CTX_set_cipher_list)-
852 RESOLVEFUNC(SSL_CTX_set_default_verify_paths)-
853 RESOLVEFUNC(SSL_CTX_set_verify)-
854 RESOLVEFUNC(SSL_CTX_set_verify_depth)-
855 RESOLVEFUNC(SSL_CTX_use_certificate)-
856 RESOLVEFUNC(SSL_CTX_use_certificate_file)-
857 RESOLVEFUNC(SSL_CTX_use_PrivateKey)-
858 RESOLVEFUNC(SSL_CTX_use_RSAPrivateKey)-
859 RESOLVEFUNC(SSL_CTX_use_PrivateKey_file)-
860 RESOLVEFUNC(SSL_CTX_get_cert_store);-
861 RESOLVEFUNC(SSL_accept)-
862 RESOLVEFUNC(SSL_clear)-
863 RESOLVEFUNC(SSL_connect)-
864 RESOLVEFUNC(SSL_free)-
865 RESOLVEFUNC(SSL_get_ciphers)-
866 RESOLVEFUNC(SSL_get_current_cipher)-
867 RESOLVEFUNC(SSL_version)-
868 RESOLVEFUNC(SSL_get_error)-
869 RESOLVEFUNC(SSL_get_peer_cert_chain)-
870 RESOLVEFUNC(SSL_get_peer_certificate)-
871 RESOLVEFUNC(SSL_get_verify_result)-
872 RESOLVEFUNC(SSL_library_init)-
873 RESOLVEFUNC(SSL_load_error_strings)-
874 RESOLVEFUNC(SSL_new)-
875 RESOLVEFUNC(SSL_ctrl)-
876 RESOLVEFUNC(SSL_read)-
877 RESOLVEFUNC(SSL_set_accept_state)-
878 RESOLVEFUNC(SSL_set_bio)-
879 RESOLVEFUNC(SSL_set_connect_state)-
880 RESOLVEFUNC(SSL_shutdown)-
881 RESOLVEFUNC(SSL_set_session)-
882 RESOLVEFUNC(SSL_SESSION_free)-
883 RESOLVEFUNC(SSL_get1_session)-
884 RESOLVEFUNC(SSL_get_session)-
885#if OPENSSL_VERSION_NUMBER >= 0x10001000L-
886 RESOLVEFUNC(SSL_get_ex_new_index)-
887 RESOLVEFUNC(SSL_set_ex_data)-
888 RESOLVEFUNC(SSL_get_ex_data)-
889#endif-
890#if OPENSSL_VERSION_NUMBER >= 0x10001000L && !defined(OPENSSL_NO_PSK)-
891 RESOLVEFUNC(SSL_set_psk_client_callback)-
892#endif-
893 RESOLVEFUNC(SSL_write)-
894#ifndef OPENSSL_NO_SSL2-
895 RESOLVEFUNC(SSLv2_client_method)-
896#endif-
897#ifndef OPENSSL_NO_SSL3_METHOD-
898 RESOLVEFUNC(SSLv3_client_method)-
899#endif-
900 RESOLVEFUNC(SSLv23_client_method)-
901 RESOLVEFUNC(TLSv1_client_method)-
902#if OPENSSL_VERSION_NUMBER >= 0x10001000L-
903 RESOLVEFUNC(TLSv1_1_client_method)-
904 RESOLVEFUNC(TLSv1_2_client_method)-
905#endif-
906#ifndef OPENSSL_NO_SSL2-
907 RESOLVEFUNC(SSLv2_server_method)-
908#endif-
909#ifndef OPENSSL_NO_SSL3_METHOD-
910 RESOLVEFUNC(SSLv3_server_method)-
911#endif-
912 RESOLVEFUNC(SSLv23_server_method)-
913 RESOLVEFUNC(TLSv1_server_method)-
914#if OPENSSL_VERSION_NUMBER >= 0x10001000L-
915 RESOLVEFUNC(TLSv1_1_server_method)-
916 RESOLVEFUNC(TLSv1_2_server_method)-
917#endif-
918 RESOLVEFUNC(X509_NAME_entry_count)-
919 RESOLVEFUNC(X509_NAME_get_entry)-
920 RESOLVEFUNC(X509_NAME_ENTRY_get_data)-
921 RESOLVEFUNC(X509_NAME_ENTRY_get_object)-
922 RESOLVEFUNC(X509_PUBKEY_get)-
923 RESOLVEFUNC(X509_STORE_free)-
924 RESOLVEFUNC(X509_STORE_new)-
925 RESOLVEFUNC(X509_STORE_add_cert)-
926 RESOLVEFUNC(X509_STORE_CTX_free)-
927 RESOLVEFUNC(X509_STORE_CTX_init)-
928 RESOLVEFUNC(X509_STORE_CTX_new)-
929 RESOLVEFUNC(X509_STORE_CTX_set_purpose)-
930 RESOLVEFUNC(X509_STORE_CTX_get_error)-
931 RESOLVEFUNC(X509_STORE_CTX_get_error_depth)-
932 RESOLVEFUNC(X509_STORE_CTX_get_current_cert)-
933 RESOLVEFUNC(X509_STORE_CTX_get_chain)-
934 RESOLVEFUNC(X509_cmp)-
935#ifndef SSLEAY_MACROS-
936 RESOLVEFUNC(X509_dup)-
937#endif-
938 RESOLVEFUNC(X509_print)-
939 RESOLVEFUNC(X509_EXTENSION_get_object)-
940 RESOLVEFUNC(X509_free)-
941 RESOLVEFUNC(X509_get_ext)-
942 RESOLVEFUNC(X509_get_ext_count)-
943 RESOLVEFUNC(X509_get_ext_d2i)-
944 RESOLVEFUNC(X509V3_EXT_get)-
945 RESOLVEFUNC(X509V3_EXT_d2i)-
946 RESOLVEFUNC(X509_EXTENSION_get_critical)-
947 RESOLVEFUNC(X509_EXTENSION_get_data)-
948 RESOLVEFUNC(BASIC_CONSTRAINTS_free)-
949 RESOLVEFUNC(AUTHORITY_KEYID_free)-
950 RESOLVEFUNC(ASN1_STRING_print)-
951 RESOLVEFUNC(X509_check_issued)-
952 RESOLVEFUNC(X509_get_issuer_name)-
953 RESOLVEFUNC(X509_get_subject_name)-
954 RESOLVEFUNC(X509_verify_cert)-
955 RESOLVEFUNC(d2i_X509)-
956 RESOLVEFUNC(i2d_X509)-
957#ifdef SSLEAY_MACROS-
958 RESOLVEFUNC(i2d_DSAPrivateKey)-
959 RESOLVEFUNC(i2d_RSAPrivateKey)-
960 RESOLVEFUNC(d2i_DSAPrivateKey)-
961 RESOLVEFUNC(d2i_RSAPrivateKey)-
962#endif-
963 RESOLVEFUNC(OPENSSL_add_all_algorithms_noconf)-
964 RESOLVEFUNC(OPENSSL_add_all_algorithms_conf)-
965 RESOLVEFUNC(SSL_CTX_load_verify_locations)-
966 RESOLVEFUNC(SSLeay)-
967 RESOLVEFUNC(SSLeay_version)-
968 RESOLVEFUNC(i2d_SSL_SESSION)-
969 RESOLVEFUNC(d2i_SSL_SESSION)-
970#if OPENSSL_VERSION_NUMBER >= 0x1000100fL && !defined(OPENSSL_NO_NEXTPROTONEG)-
971 RESOLVEFUNC(SSL_select_next_proto)-
972 RESOLVEFUNC(SSL_CTX_set_next_proto_select_cb)-
973 RESOLVEFUNC(SSL_get0_next_proto_negotiated)-
974#endif // OPENSSL_VERSION_NUMBER >= 0x1000100fL ...-
975 RESOLVEFUNC(DH_new)-
976 RESOLVEFUNC(DH_free)-
977 RESOLVEFUNC(d2i_DHparams)-
978 RESOLVEFUNC(BN_bin2bn)-
979#ifndef OPENSSL_NO_EC-
980 RESOLVEFUNC(EC_KEY_dup)-
981 RESOLVEFUNC(EC_KEY_new_by_curve_name)-
982 RESOLVEFUNC(EC_KEY_free)-
983 RESOLVEFUNC(EC_get_builtin_curves)-
984#if OPENSSL_VERSION_NUMBER >= 0x10002000L-
985 if (q_SSLeay() >= 0x10002000L)-
986 RESOLVEFUNC(EC_curve_nist2nid)-
987#endif // OPENSSL_VERSION_NUMBER >= 0x10002000L-
988#endif // OPENSSL_NO_EC-
989 RESOLVEFUNC(PKCS12_parse)-
990 RESOLVEFUNC(d2i_PKCS12_bio)-
991 RESOLVEFUNC(PKCS12_free)-
992-
993 symbolsResolved = true;-
994 delete libs.first;-
995 delete libs.second;-
996 return true;-
997}-
998#endif // QT_NO_LIBRARY-
999-
1000#else // !defined QT_LINKED_OPENSSL-
1001-
1002bool q_resolveOpenSslSymbols()-
1003{-
1004#ifdef QT_NO_OPENSSL-
1005 return false;-
1006#endif-
1007 return true;-
1008}-
1009#endif // !defined QT_LINKED_OPENSSL-
1010-
1011//==============================================================================-
1012// contributed by Jay Case of Sarvega, Inc.; http://sarvega.com/-
1013// Based on X509_cmp_time() for intitial buffer hacking.-
1014//==============================================================================-
1015QDateTime q_getTimeFromASN1(const ASN1_TIME *aTime)-
1016{-
1017 size_t lTimeLength = aTime->length;-
1018 char *pString = (char *) aTime->data;-
1019-
1020 if (aTime->type == V_ASN1_UTCTIME) {-
1021-
1022 char lBuffer[24];-
1023 char *pBuffer = lBuffer;-
1024-
1025 if ((lTimeLength < 11) || (lTimeLength > 17))-
1026 return QDateTime();-
1027-
1028 memcpy(pBuffer, pString, 10);-
1029 pBuffer += 10;-
1030 pString += 10;-
1031-
1032 if ((*pString == 'Z') || (*pString == '-') || (*pString == '+')) {-
1033 *pBuffer++ = '0';-
1034 *pBuffer++ = '0';-
1035 } else {-
1036 *pBuffer++ = *pString++;-
1037 *pBuffer++ = *pString++;-
1038 // Skip any fractional seconds...-
1039 if (*pString == '.') {-
1040 pString++;-
1041 while ((*pString >= '0') && (*pString <= '9'))-
1042 pString++;-
1043 }-
1044 }-
1045-
1046 *pBuffer++ = 'Z';-
1047 *pBuffer++ = '\0';-
1048-
1049 time_t lSecondsFromUCT;-
1050 if (*pString == 'Z') {-
1051 lSecondsFromUCT = 0;-
1052 } else {-
1053 if ((*pString != '+') && (*pString != '-'))-
1054 return QDateTime();-
1055-
1056 lSecondsFromUCT = ((pString[1] - '0') * 10 + (pString[2] - '0')) * 60;-
1057 lSecondsFromUCT += (pString[3] - '0') * 10 + (pString[4] - '0');-
1058 lSecondsFromUCT *= 60;-
1059 if (*pString == '-')-
1060 lSecondsFromUCT = -lSecondsFromUCT;-
1061 }-
1062-
1063 tm lTime;-
1064 lTime.tm_sec = ((lBuffer[10] - '0') * 10) + (lBuffer[11] - '0');-
1065 lTime.tm_min = ((lBuffer[8] - '0') * 10) + (lBuffer[9] - '0');-
1066 lTime.tm_hour = ((lBuffer[6] - '0') * 10) + (lBuffer[7] - '0');-
1067 lTime.tm_mday = ((lBuffer[4] - '0') * 10) + (lBuffer[5] - '0');-
1068 lTime.tm_mon = (((lBuffer[2] - '0') * 10) + (lBuffer[3] - '0')) - 1;-
1069 lTime.tm_year = ((lBuffer[0] - '0') * 10) + (lBuffer[1] - '0');-
1070 if (lTime.tm_year < 50)-
1071 lTime.tm_year += 100; // RFC 2459-
1072-
1073 QDate resDate(lTime.tm_year + 1900, lTime.tm_mon + 1, lTime.tm_mday);-
1074 QTime resTime(lTime.tm_hour, lTime.tm_min, lTime.tm_sec);-
1075-
1076 QDateTime result(resDate, resTime, Qt::UTC);-
1077 result = result.addSecs(lSecondsFromUCT);-
1078 return result;-
1079-
1080 } else if (aTime->type == V_ASN1_GENERALIZEDTIME) {-
1081-
1082 if (lTimeLength < 15)-
1083 return QDateTime(); // hopefully never triggered-
1084-
1085 // generalized time is always YYYYMMDDHHMMSSZ (RFC 2459, section 4.1.2.5.2)-
1086 tm lTime;-
1087 lTime.tm_sec = ((pString[12] - '0') * 10) + (pString[13] - '0');-
1088 lTime.tm_min = ((pString[10] - '0') * 10) + (pString[11] - '0');-
1089 lTime.tm_hour = ((pString[8] - '0') * 10) + (pString[9] - '0');-
1090 lTime.tm_mday = ((pString[6] - '0') * 10) + (pString[7] - '0');-
1091 lTime.tm_mon = (((pString[4] - '0') * 10) + (pString[5] - '0'));-
1092 lTime.tm_year = ((pString[0] - '0') * 1000) + ((pString[1] - '0') * 100) +-
1093 ((pString[2] - '0') * 10) + (pString[3] - '0');-
1094-
1095 QDate resDate(lTime.tm_year, lTime.tm_mon, lTime.tm_mday);-
1096 QTime resTime(lTime.tm_hour, lTime.tm_min, lTime.tm_sec);-
1097-
1098 QDateTime result(resDate, resTime, Qt::UTC);-
1099 return result;-
1100-
1101 } else {-
1102 qCWarning(lcSsl, "unsupported date format detected");-
1103 return QDateTime();-
1104 }-
1105-
1106}-
1107-
1108QT_END_NAMESPACE-
Source codeSwitch to Preprocessed file

Generated by Squish Coco Non-Commercial 4.3.0-BETA-master-30-08-2018-4cb69e9