diff options
author | BogDan Vatra <bogdan@kde.org> | 2013-02-08 10:09:09 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-02-08 17:37:51 +0100 |
commit | 934afb5c57fce6d28ce0d7ae8ac1450e8d833b17 (patch) | |
tree | 4e4343851e02892a08be450f31c24686b2784163 /src | |
parent | 2be39c68320ab058ac5428ed1a9f0bb69a6c5893 (diff) |
Fix loading of SSL certificate of DER files.
DER certificates should not be opened as text files, so we
only pass the QIODevice::Text flag when the format is
QSsl::Pem.
Change-Id: I4bad98023c397b967d5beeec0aaa6c414e06fd9c
Reviewed-by: Richard J. Moore <rich@kde.org>
Diffstat (limited to 'src')
-rw-r--r-- | src/network/ssl/qsslcertificate.cpp | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/src/network/ssl/qsslcertificate.cpp b/src/network/ssl/qsslcertificate.cpp index db20f5618b..8b5be7ae00 100644 --- a/src/network/ssl/qsslcertificate.cpp +++ b/src/network/ssl/qsslcertificate.cpp @@ -876,8 +876,11 @@ QList<QSslCertificate> QSslCertificate::fromPath(const QString &path, // Check if the path is a file. if (QFileInfo(sourcePath).isFile()) { QFile file(sourcePath); - if (file.open(QIODevice::ReadOnly | QIODevice::Text)) - return QSslCertificate::fromData(file.readAll(),format); + QIODevice::OpenMode openMode = QIODevice::ReadOnly; + if (format == QSsl::Pem) + openMode |= QIODevice::Text; + if (file.open(openMode)) + return QSslCertificate::fromData(file.readAll(), format); return QList<QSslCertificate>(); } } @@ -899,8 +902,11 @@ QList<QSslCertificate> QSslCertificate::fromPath(const QString &path, continue; QFile file(filePath); - if (file.open(QIODevice::ReadOnly | QIODevice::Text)) - certs += QSslCertificate::fromData(file.readAll(),format); + QIODevice::OpenMode openMode = QIODevice::ReadOnly; + if (format == QSsl::Pem) + openMode |= QIODevice::Text; + if (file.open(openMode)) + certs += QSslCertificate::fromData(file.readAll(), format); } return certs; } |