read more than one certificate from a file; take file names in command line arguments
This commit is contained in:
		| @@ -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; | ||||
|   | ||||
		Reference in New Issue
	
	Block a user