Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
QtSslCertificates.java
Go to the documentation of this file.
1// Copyright (C) 2026 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
4package org.qtproject.qt.android.multimedia.qffmpeg;
5
6import java.security.KeyStore;
7import java.security.cert.X509Certificate;
8import java.util.ArrayList;
9import javax.net.ssl.TrustManager;
10import javax.net.ssl.TrustManagerFactory;
11import javax.net.ssl.X509TrustManager;
12
13import android.util.Log;
14
15import org.qtproject.qt.android.UsedFromNativeCode;
16
17// Provides Android's system trust anchors (DER-encoded) to the FFmpeg backend, so it can
18// build a CA bundle for FFmpeg's tls_openssl protocol. Reimplements the logic of
19// org.qtproject.qt.android.QtNative.getSSLCertificates(), which is private and unreachable
20// from here, to avoid a new QtNetwork dependency.
21class QtSslCertificates {
22
23 private static final String TAG = "QtSslCertificates";
24
25 @UsedFromNativeCode
26 static byte[][] getCertificates() {
27 ArrayList<byte[]> certificateList = new ArrayList<>();
28
29 try {
30 TrustManagerFactory factory =
31 TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
32 factory.init((KeyStore) null);
33
34 for (TrustManager manager : factory.getTrustManagers()) {
35 if (manager instanceof X509TrustManager) {
36 X509TrustManager trustManager = (X509TrustManager) manager;
37
38 for (X509Certificate certificate : trustManager.getAcceptedIssuers())
39 certificateList.add(certificate.getEncoded());
40 }
41 }
42 } catch (Exception e) {
43 Log.e(TAG, "Failed to get system CA certificates", e);
44 }
45
46 return certificateList.toArray(new byte[certificateList.size()][]);
47 }
48}
QItemEditorFactory * factory
QNetworkAccessManager manager
[0]