Skip to content

Commit

Permalink
Remove flawed MX host existence check for cert wizard (#1178)
Browse files Browse the repository at this point in the history
The certificate wizard tried to verify the host of email addresses
input by users by resolving their A record. This is flawed as
a host isn't required to have an A record for receiving mail. The
correct way would be to check the MX record instead. This isn't
possible in Qt 4. As the feature is of dubious value anyways this
patch simply removes it. Now every email matching (.+)@(.+) is
accepted.
  • Loading branch information
hacst committed Apr 27, 2014
1 parent a429c76 commit abad339
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 43 deletions.
47 changes: 7 additions & 40 deletions src/mumble/Cert.cpp
Expand Up @@ -142,9 +142,6 @@ CertWizard::CertWizard(QWidget *p) : QWizard(p) {

setOption(QWizard::NoCancelButton, false);

bValidDomain = true;
bPendingDns = false;

qwpExport->setCommitPage(true);
qwpExport->setComplete(false);
}
Expand Down Expand Up @@ -218,24 +215,14 @@ void CertWizard::initializePage(int id) {

bool CertWizard::validateCurrentPage() {
if (currentPage() == qwpNew) {
if (! bValidDomain) {
QRegExp ereg(QLatin1String("(.+)@(.+)"), Qt::CaseInsensitive, QRegExp::RegExp2);
if (ereg.exactMatch(qleEmail->text())) {
const QString &domain = ereg.cap(2);
if (! domain.isEmpty()) {
qlError->setText(tr("Resolving domain %1.").arg(domain));
bPendingDns = true;
iLookupId = QHostInfo::lookupHost(domain, this, SLOT(lookedUp(QHostInfo)));
} else
bValidDomain = true;
} else
qlError->setText(tr("Unable to validate email.<br />Enter a valid (or blank) email to continue."));
if (! bValidDomain) {
qwpNew->setComplete(false);
return false;
}
QRegExp ereg(QLatin1String("(^$)|((.+)@(.+))"), Qt::CaseInsensitive, QRegExp::RegExp2);
if (!ereg.exactMatch(qleEmail->text())) {
qlError->setText(tr("Unable to validate email.<br />Enter a valid (or blank) email to continue."));
qwpNew->setComplete(false);
return false;
} else {
kpNew = generateNewCert(qleName->text(), qleEmail->text());

if (! validateCert(kpNew)) {
qlError->setText(tr("There was an error generating your certificate.<br />Please try again."));
return false;
Expand Down Expand Up @@ -285,13 +272,7 @@ bool CertWizard::validateCurrentPage() {
return QWizard::validateCurrentPage();
}

void CertWizard::on_qleEmail_textChanged(const QString &email) {
bValidDomain = email.isEmpty();
if (bPendingDns) {
qlError->setText(QString());
QHostInfo::abortHostLookup(iLookupId);
bPendingDns = false;
}
void CertWizard::on_qleEmail_textChanged(const QString &) {
qwpNew->setComplete(true);
}

Expand Down Expand Up @@ -381,20 +362,6 @@ void CertWizard::on_qlIntroText_linkActivated(const QString &url) {
QDesktopServices::openUrl(QUrl(url));
}

void CertWizard::lookedUp(QHostInfo info) {
bPendingDns = false;
if (info.error() == QHostInfo::NoError) {
bValidDomain = true;
qlError->setText(QString());
qwpNew->setComplete(true);
next();
} else {
bValidDomain = false;
qlError->setText(tr("Unable to resolve domain."));
qwpNew->setComplete(false);
}
}

static int add_ext(X509 * crt, int nid, char *value) {
X509_EXTENSION *ex;
X509V3_CTX ctx;
Expand Down
3 changes: 0 additions & 3 deletions src/mumble/Cert.h
Expand Up @@ -67,8 +67,6 @@ class CertWizard : public QWizard, public Ui::Certificates {
Q_DISABLE_COPY(CertWizard)
protected:
Settings::KeyPair kpCurrent, kpNew;
bool bValidDomain, bPendingDns;
int iLookupId;
public:
CertWizard(QWidget *p = NULL);
int nextId() const;
Expand All @@ -86,7 +84,6 @@ class CertWizard : public QWizard, public Ui::Certificates {
void on_qleImportFile_textChanged(const QString &);
void on_qlePassword_textChanged(const QString &);
void on_qlIntroText_linkActivated(const QString &);
void lookedUp(QHostInfo);
};

#endif

0 comments on commit abad339

Please sign in to comment.