[Qt] Use Qt resources for bundling the certificates

This commit is contained in:
Thiago Marcos P. Santos
2015-12-10 16:33:09 -08:00
parent b9bbe68fe0
commit efb96e80ec
6 changed files with 26 additions and 1 deletions

1
configure vendored
View File

@@ -64,6 +64,7 @@ function print_qt_flags {
CONFIG+=" 'qt_cflags%': [], "$LN
CONFIG+=" 'qt_ldflags%': [], "$LN
CONFIG+=" 'qt_moc%': [], "$LN
CONFIG+=" 'qt_rcc%': [], "$LN
}
# Load dependencies

View File

@@ -43,6 +43,7 @@
'../default/string_stdlib.cpp',
'../default/thread.cpp',
'include/qmapboxgl.hpp',
'qmapbox.qrc',
'src/async_task.cpp',
'src/async_task_impl.hpp',
'src/http_file_source.cpp',

5
platform/qt/qmapbox.qrc Normal file
View File

@@ -0,0 +1,5 @@
<!DOCTYPE RCC><RCC version="1.0">
<qresource>
<file alias="ca-bundle.crt">../../common/ca-bundle.crt</file>
</qresource>
</RCC>

View File

@@ -8,5 +8,13 @@
'action': [ '<(qt_moc)', '<(RULE_INPUT_PATH)', '-o', '<(SHARED_INTERMEDIATE_DIR)/<(RULE_INPUT_DIRNAME)/moc_<(RULE_INPUT_ROOT).cpp' ],
'message': 'Generating MOC <(RULE_INPUT_ROOT).cpp',
},
{
'rule_name': 'QRC files',
'extension': 'qrc',
'process_outputs_as_sources': 1,
'outputs': [ '<(SHARED_INTERMEDIATE_DIR)/<(RULE_INPUT_DIRNAME)/qrc_<(RULE_INPUT_ROOT).cpp' ],
'action': [ '<(qt_rcc)', '<(RULE_INPUT_PATH)', '-name', '<(RULE_INPUT_ROOT)', '-o', '<(SHARED_INTERMEDIATE_DIR)/<(RULE_INPUT_DIRNAME)/qrc_<(RULE_INPUT_ROOT).cpp' ],
'message': 'Generating QRC <(RULE_INPUT_ROOT).cpp',
},
],
}

View File

@@ -31,7 +31,9 @@ function print_qt_flags {
QT_VERSION_MAJOR=$(qmake -query QT_VERSION | cut -d. -f1)
if [ ${QT_VERSION_MAJOR} -gt 4 ] ; then
CONFIG+=" 'qt_moc%': '$(pkg-config Qt${QT_VERSION_MAJOR}Core --variable=host_bins)/moc',"$LN
CONFIG+=" 'qt_rcc%': '$(pkg-config Qt${QT_VERSION_MAJOR}Core --variable=host_bins)/rcc',"$LN
else
CONFIG+=" 'qt_moc%': '$(pkg-config QtCore --variable=moc_location)',"$LN
CONFIG+=" 'qt_rcc%': '$(pkg-config QtCore --variable=rcc_location)',"$LN
fi
}

View File

@@ -9,10 +9,18 @@
#include <QNetworkReply>
#include <QSslConfiguration>
// Needs to be on the global namespace
// for linking purposes.
void initResources() {
Q_INIT_RESOURCE(qmapbox);
}
namespace mbgl {
HTTPFileSource::Impl::Impl() : m_manager(new QNetworkAccessManager(this))
{
initResources();
QNetworkProxyFactory::setUseSystemConfiguration(true);
#if QT_VERSION >= 0x050000
@@ -22,7 +30,7 @@ HTTPFileSource::Impl::Impl() : m_manager(new QNetworkAccessManager(this))
m_ssl.setProtocol(QSsl::TlsV1);
#endif
m_ssl.setCaCertificates(QSslCertificate::fromPath("ca-bundle.crt"));
m_ssl.setCaCertificates(QSslCertificate::fromPath(":ca-bundle.crt"));
if (m_ssl.caCertificates().isEmpty()) {
mbgl::Log::Warning(mbgl::Event::HttpRequest, "Could not load list of certificate authorities");
}