Skip to content

Commit

Permalink
QTlsBackendOpenSSL: optimize QDirListing iteration
Browse files Browse the repository at this point in the history
Looking for certificates, the name filters are {*.pem,*.crt}, so only
list files and symlinks to files.

Change-Id: Ic8cea09e4d8004c35a9ae60dbbee7b41362e2c94
Reviewed-by: Mårten Nordheim <[email protected]>
  • Loading branch information
Ahmad Samir committed Jul 25, 2024
1 parent bcdf678 commit d2afcff
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/plugins/tls/openssl/qtlsbackend_openssl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -392,8 +392,10 @@ QList<QSslCertificate> systemCaCertificates()
QStringLiteral("/usr/local/share/certs/ca-root-nss.crt") // FreeBSD's ca_root_nss
};
static const QStringList nameFilters = {u"*.pem"_s, u"*.crt"_s};
using F = QDirListing::IteratorFlag;
constexpr auto flags = F::FilesOnly | F::ResolveSymlinks; // Files and symlinks to files
for (const auto &directory : directories) {
for (const auto &dirEntry : QDirListing(directory, nameFilters)) {
for (const auto &dirEntry : QDirListing(directory, nameFilters, flags)) {
// use canonical path here to not load the same certificate twice if symlinked
certFiles.insert(dirEntry.canonicalFilePath());
}
Expand Down

0 comments on commit d2afcff

Please sign in to comment.