Catch and describe IO errors in SslServer::setCertificate.
authorJoshua T Corbin <jcorbin@wunjo.org>
Thu, 8 Jan 2009 23:52:57 +0000 (18:52 -0500)
committerManuel Nickschas <sputnick@quassel-irc.org>
Fri, 16 Jan 2009 19:47:10 +0000 (20:47 +0100)
src/core/sslserver.cpp

index 7fee3ca..8006ebd 100644 (file)
@@ -72,10 +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.reset();
+  if (! certFile.reset()) {
+    qWarning() << "SslServer: IO error reading certificate file";
+    return false;
+  }
+
   _key = QSslKey(&certFile, QSsl::Rsa);
   certFile.close();