Catch and describe IO errors in SslServer::setCertificate.
[quassel.git] / src / core / sslserver.cpp
index 53660f8..8006ebd 100644 (file)
@@ -72,11 +72,19 @@ bool SslServer::setCertificate(const QString &path) {
     return false;
   }
 
-  certFile.open(QIODevice::ReadOnly);
+  if (! certFile.open(QIODevice::ReadOnly)) {
+    qWarning()
+      << "SslServer: Failed to open certificate file" << qPrintable(path)
+      << "error:" << certFile.error();
+    return false;
+  }
   _cert = QSslCertificate(&certFile);
-  certFile.close();
 
-  certFile.open(QIODevice::ReadOnly);
+  if (! certFile.reset()) {
+    qWarning() << "SslServer: IO error reading certificate file";
+    return false;
+  }
+
   _key = QSslKey(&certFile, QSsl::Rsa);
   certFile.close();