read more than one certificate from a file; take file names in command line arguments

master
Marc Wäckerlin 9 years ago
parent 8609ef4a54
commit a3dd647879
  1. 26
      src/certman.hxx

@ -35,21 +35,21 @@ class CertMan: public QMainWindow, protected Ui::CertMan {
SLOT(certificate(QUrl, QSslCertificate))); SLOT(certificate(QUrl, QSslCertificate)));
} }
bool open(const QString& fileName) { bool open(const QString& fileName) {
bool status(true); bool status(false);
QFile file(fileName); QFile file(fileName);
file.open(QIODevice::ReadOnly); file.open(QIODevice::ReadOnly);
while (!file.atEnd()) { if (file.error()!=QFileDevice::NoError) {
QSslCertificate c(&file); qDebug()<<"Error open file"<<fileName<<file.errorString();
if (!c.isNull()) { return false;
Certificate* win(new Certificate(_mdi)); }
_mdi->addSubWindow(win)->setWindowTitle(QFileInfo(fileName).fileName()); for (const QSslCertificate& c: QSslCertificate::fromDevice(&file)) {
win->show(); Certificate* win(new Certificate(_mdi));
win->certificate(c); _mdi->addSubWindow(win)->setWindowTitle
} else { (c.subjectInfo(QSslCertificate::CommonName).join(", ")
status = false; +" ("+QFileInfo(fileName).fileName()+")");
qDebug()<<QObject::trUtf8("Cannot read PEM certificate from file: %1") win->show();
.arg(fileName); win->certificate(c);
} status = true;
} }
file.close(); file.close();
return status; return status;

Loading…
Cancel
Save