Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
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
4/****************************************************************************
5**
6** In addition, as a special exception, the copyright holders listed above give
7** permission to link the code of its release of Qt with the OpenSSL project's
8** "OpenSSL" library (or modified versions of the "OpenSSL" library that use the
9** same license as the original version), and distribute the linked executables.
10**
11** You must comply with the GNU General Public License version 2 in all
12** respects for all of the code used other than the "OpenSSL" code. If you
13** modify this file, you may extend this exception to your version of the file,
14** but you are not obligated to do so. If you do not wish to do so, delete
15** this exception statement from your version of this file.
16**
17****************************************************************************/
18
19#include <QtCore/QJniEnvironment>
20#include <QtCore/QJniObject>
21#include <QtCore/QList>
22#include <QtCore/QByteArray>
23
25
26namespace QTlsPrivate {
27
28QList<QByteArray> fetchSslCertificateData()
29{
30 QList<QByteArray> certificateData;
31
32 QJniObject certificates = QJniObject::callStaticObjectMethod("org/qtproject/qt/android/QtNative",
33 "getSSLCertificates",
34 "()[[B");
35 if (!certificates.isValid())
36 return certificateData;
37
39 jobjectArray jcertificates = certificates.object<jobjectArray>();
40 const jint nCertificates = env->GetArrayLength(jcertificates);
41 certificateData.reserve(static_cast<int>(nCertificates));
42
43 for (int i = 0; i < nCertificates; ++i) {
44 jbyteArray jCert = static_cast<jbyteArray>(env->GetObjectArrayElement(jcertificates, i));
45 const uint sz = env->GetArrayLength(jCert);
46 jbyte *buffer = env->GetByteArrayElements(jCert, 0);
47 certificateData.append(QByteArray(reinterpret_cast<char*>(buffer), sz));
48
49 env->ReleaseByteArrayElements(jCert, buffer, JNI_ABORT); // don't copy back the elements
50 env->DeleteLocalRef(jCert);
51 }
52
53 return certificateData;
54}
55
56} // namespace QTlsPrivate
57
\inmodule QtCore
\inmodule QtCore
Combined button and popup list for selecting options.
Namespace containing onternal types that TLS backends implement.
QList< QByteArray > fetchSslCertificateData()
typedef QByteArray(EGLAPIENTRYP PFNQGSGETDISPLAYSPROC)()
GLenum GLuint buffer
unsigned int uint
Definition qtypes.h:34