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();