X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fcore%2Fsslserver.cpp;h=7fee3ca59dd98e73f9251f6291f91548d419e60e;hp=203ec76115292f20da937ab744b1f21cece513a3;hb=4faeafb743766b345d5cadc5289840a981413853;hpb=ffcc8befd931340321e3aa2029cb5667373fd584 diff --git a/src/core/sslserver.cpp b/src/core/sslserver.cpp index 203ec761..7fee3ca5 100644 --- a/src/core/sslserver.cpp +++ b/src/core/sslserver.cpp @@ -60,20 +60,31 @@ void SslServer::incomingConnection(int socketDescriptor) { } bool SslServer::setCertificate(const QString &path) { + _certIsValid = false; + + if (path.isNull()) { + return false; + } + QFile certFile(path); + if (! certFile.exists()) { + qWarning() << "SslServer: Certificate file" << qPrintable(path) << "does not exist"; + return false; + } + certFile.open(QIODevice::ReadOnly); _cert = QSslCertificate(&certFile); - certFile.close(); - certFile.open(QIODevice::ReadOnly); + certFile.reset(); _key = QSslKey(&certFile, QSsl::Rsa); certFile.close(); - _certIsValid = !_cert.isNull() && _cert.isValid() && !_key.isNull(); - if(!_certIsValid) { + if(_cert.isNull() || !_cert.isValid() || _key.isNull()) { qWarning() << "SslServer: SSL Certificate is either missing or has a wrong format!\n" << " Quassel Core will still work, but cannot provide SSL for client connections.\n" << " Please see http://quassel-irc.org/faq/cert to learn how to enable SSL support."; + } else { + _certIsValid = true; } return _certIsValid;