Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Toggle main menu visibility
Loading...
Searching...
No Matches
qsslsocket_openssl_android.cpp
Go to the documentation of this file.
1
// Copyright (C) 2021 The Qt Company Ltd.
2
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
// Qt-Security score:significant reason:default
4
5
/****************************************************************************
6
**
7
** In addition, as a special exception, the copyright holders listed above give
8
** permission to link the code of its release of Qt with the OpenSSL project's
9
** "OpenSSL" library (or modified versions of the "OpenSSL" library that use the
10
** same license as the original version), and distribute the linked executables.
11
**
12
** You must comply with the GNU General Public License version 2 in all
13
** respects for all of the code used other than the "OpenSSL" code. If you
14
** modify this file, you may extend this exception to your version of the file,
15
** but you are not obligated to do so. If you do not wish to do so, delete
16
** this exception statement from your version of this file.
17
**
18
****************************************************************************/
19
20
#
include
<
QtCore
/
QJniEnvironment
>
21
#
include
<
QtCore
/
QJniObject
>
22
#
include
<
QtCore
/
QList
>
23
#
include
<
QtCore
/
QByteArray
>
24
25
QT_BEGIN_NAMESPACE
26
27
namespace
QTlsPrivate
{
28
29
QList
<
QByteArray
>
fetchSslCertificateData
()
30
{
31
QList<QByteArray> certificateData;
32
33
QJniObject certificates = QJniObject::callStaticObjectMethod(
"org/qtproject/qt/android/QtNative"
,
34
"getSSLCertificates"
,
35
"()[[B"
);
36
if
(!certificates.isValid())
37
return
certificateData;
38
39
QJniEnvironment env;
40
jobjectArray jcertificates = certificates.object<jobjectArray>();
41
const
jint nCertificates = env->GetArrayLength(jcertificates);
42
certificateData.reserve(
static_cast
<
int
>(nCertificates));
43
44
for
(
int
i = 0; i < nCertificates; ++i) {
45
jbyteArray jCert =
static_cast
<jbyteArray>(env->GetObjectArrayElement(jcertificates, i));
46
const
uint sz = env->GetArrayLength(jCert);
47
jbyte *buffer = env->GetByteArrayElements(jCert, 0);
48
certificateData.append(QByteArray(
reinterpret_cast
<
char
*>(buffer), sz));
49
50
env->ReleaseByteArrayElements(jCert, buffer, JNI_ABORT);
// don't copy back the elements
51
env->DeleteLocalRef(jCert);
52
}
53
54
return
certificateData;
55
}
56
57
}
// namespace QTlsPrivate
58
59
QT_END_NAMESPACE
QTlsPrivate
Namespace containing onternal types that TLS backends implement.
Definition
qocspresponse.h:41
QTlsPrivate::fetchSslCertificateData
QList< QByteArray > fetchSslCertificateData()
Definition
qsslsocket_openssl_android.cpp:29
qtbase
src
plugins
tls
openssl
qsslsocket_openssl_android.cpp
Generated on
for Qt by
1.18.0