If the key won't load as an RSA key, attempt to load it again as an
EC key. DSA support was not added because DSA is obsolete and no-
one should be using it.
Note that this only works with Qt5.5 and up as EC support was added
in that version (https://github.com/qt/qtbase/commit/
962ea569). An
if macro has been used to allow for continued compilation under Qt4
and Qt5<5.5.
Closes GH-344.
#endif
#include <QDateTime>
-#include <QFile>
#include "logger.h"
#include "quassel.h"
return false;
}
- untestedKey = QSslKey(&keyFile, QSsl::Rsa);
+ untestedKey = loadKey(&keyFile);
keyFile.close();
} else {
- untestedKey = QSslKey(&certFile, QSsl::Rsa);
+ untestedKey = loadKey(&certFile);
}
certFile.close();
}
+QSslKey SslServer::loadKey(QFile *keyFile)
+{
+ QSslKey key;
+ key = QSslKey(keyFile, QSsl::Rsa);
+#if QT_VERSION >= 0x050500
+ if (key.isNull()) {
+ if (!keyFile->reset()) {
+ quWarning() << "SslServer: IO error reading key file";
+ return key;
+ }
+ key = QSslKey(keyFile, QSsl::Ec);
+ }
+#endif
+ return key;
+}
+
+
#endif // HAVE_SSL
#include <QSslKey>
#include <QTcpServer>
#include <QLinkedList>
+#include <QFile>
class SslServer : public QTcpServer
{
* @return True if certificates loaded successfully, otherwise false.
*/
bool loadCerts();
+ QSslKey loadKey(QFile *keyFile);
QLinkedList<QTcpSocket *> _pendingConnections;
QSslCertificate _cert;