0002-Support-some-basic-status-messages-if-ssl-is-not-pos.patch
src/client/clientsyncer.cpp | ||
---|---|---|
216 | 216 | |
217 | 217 |
sslSocket->startClientEncryption(); |
218 | 218 |
} else { |
219 |
emit connectionError(tr("<b>The Quassel Core you are trying to connect to does not support SSL!</b><br />If you want to connect anyways, disable the usage of SSL in the account settings.")); |
|
219 |
if (msg["SslStatusMsg"].toString() == "Unsupported") { |
|
220 |
emit connectionError(tr("<b>The Quassel Core you are trying to connect to does not support SSL!</b><br />If you want to connect anyways, disable the usage of SSL in the account settings.")); |
|
221 |
} else if (msg["SslStatusMsg"].toString() == "CertExpired") { |
|
222 |
emit connectionError(tr("<b>The Quassel Core you are trying to connect has an expired certificate!</b><br />If you want to connect anyways, disable the usage of SSL in the account settings.")); |
|
223 |
} else if (msg["SslStatusMsg"].toString() == "CertNotValidYet") { |
|
224 |
emit connectionError(tr("<b>The Quassel Core you are trying to connect has a certificate which is not valid yet!</b><br />If you want to connect anyways, disable the usage of SSL in the account settings.")); |
|
225 |
} |
|
220 | 226 |
disconnectFromCore(); |
221 | 227 |
} |
222 | 228 |
return; |
src/core/core.cpp | ||
---|---|---|
511 | 511 |
SslServer *sslServer = qobject_cast<SslServer *>(&_server); |
512 | 512 |
QSslSocket *sslSocket = qobject_cast<QSslSocket *>(socket); |
513 | 513 |
bool supportSsl = (bool)sslServer && (bool)sslSocket && sslServer->isCertValid(); |
514 |
QString sslStatusMsg; |
|
515 |
if ((bool)sslServer) { |
|
516 |
sslStatusMsg = sslServer->getSslStatusMsg(); |
|
517 |
} else { |
|
518 |
sslStatusMsg = "Unsupported"; |
|
519 |
} |
|
514 | 520 |
#else |
515 | 521 |
bool supportSsl = false; |
522 |
QString sslStatusMsg = "Unsupported"; |
|
516 | 523 |
#endif |
517 | 524 | |
518 | 525 |
#ifndef QT_NO_COMPRESS |
... | ... | |
522 | 529 |
#endif |
523 | 530 | |
524 | 531 |
reply["SupportSsl"] = supportSsl; |
532 |
reply["SslStatusMsg"] = sslStatusMsg; |
|
525 | 533 |
reply["SupportsCompression"] = supportsCompression; |
526 | 534 |
// switch to ssl/compression after client has been informed about our capabilities (see below) |
527 | 535 |
src/core/sslserver.cpp | ||
---|---|---|
34 | 34 | |
35 | 35 |
SslServer::SslServer(QObject *parent) |
36 | 36 |
: QTcpServer(parent), |
37 |
_isCertValid(false) |
|
37 |
_isCertValid(false), |
|
38 |
_sslStatusMsg("Unsupported") |
|
38 | 39 |
{ |
39 | 40 |
static bool sslWarningShown = false; |
40 | 41 |
if(!setCertificate(Quassel::configDirPath() + "quasselCert.pem")) { |
... | ... | |
106 | 107 | |
107 | 108 |
if (currentTime > _cert.expiryDate()) { |
108 | 109 |
quWarning() << "SslServer: certificate expired"; |
110 |
_sslStatusMsg = "CertExpired"; |
|
109 | 111 |
return false; |
110 | 112 |
} |
111 | 113 |
if (currentTime < _cert.effectiveDate()) { |
112 | 114 |
quWarning() << "SslServer: certificate is not valid yet"; |
115 |
_sslStatusMsg = "CertNotValidYet"; |
|
113 | 116 |
return false; |
114 | 117 |
} |
115 | 118 |
quWarning() << "SslServer: Invalid certificate (unknown reason)"; |
... | ... | |
120 | 123 |
return false; |
121 | 124 |
} |
122 | 125 | |
126 |
_sslStatusMsg = "Supported"; |
|
123 | 127 |
_isCertValid = true; |
124 | 128 | |
125 | 129 |
return _isCertValid; |
src/core/sslserver.h | ||
---|---|---|
27 | 27 |
#include <QSslKey> |
28 | 28 |
#include <QTcpServer> |
29 | 29 |
#include <QLinkedList> |
30 |
#include <QString> |
|
30 | 31 | |
31 | 32 |
class SslServer : public QTcpServer { |
32 | 33 |
Q_OBJECT |
... | ... | |
40 | 41 |
virtual inline const QSslCertificate &certificate() const { return _cert; } |
41 | 42 |
virtual inline const QSslKey &key() const { return _key; } |
42 | 43 |
virtual inline bool isCertValid() const { return _isCertValid; } |
44 |
virtual inline QString getSslStatusMsg() const { return _sslStatusMsg; } |
|
43 | 45 | |
44 | 46 |
protected: |
45 | 47 |
virtual void incomingConnection(int socketDescriptor); |
... | ... | |
50 | 52 |
QSslCertificate _cert; |
51 | 53 |
QSslKey _key; |
52 | 54 |
bool _isCertValid; |
55 |
QString _sslStatusMsg; |
|
53 | 56 |
}; |
54 | 57 | |
55 | 58 |
#endif //HAVE_SSL |
56 |
- |