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. 20
      src/certman.hxx

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

Loading…
Cancel
Save