Skip to content
Permalink
Browse files

Remove flawed MX host existence check for cert wizard (#1178)

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 26, 2014
1 parent a429c76 commit abad339fc502c5d1116664bc659d666f80634b47
Showing with 7 additions and 43 deletions.
  1. +7 −40 src/mumble/Cert.cpp
  2. +0 −3 src/mumble/Cert.h
@@ -142,9 +142,6 @@ CertWizard::CertWizard(QWidget *p) : QWizard(p) {

setOption(QWizard::NoCancelButton, false);

bValidDomain = true;
bPendingDns = false;

qwpExport->setCommitPage(true);
qwpExport->setComplete(false);
}
@@ -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;
@@ -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);
}

@@ -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;
@@ -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;
@@ -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.
You can’t perform that action at this time.