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

master
Marc Wäckerlin 9 years ago
parent 21f3f0e590
commit 8609ef4a54
  1. 2
      ax_init_standard_project.m4
  2. 14
      bootstrap.sh
  3. 4
      build-in-docker.conf
  4. 13
      resolve-rpmbuilddeps.sh
  5. 33
      src/certman.hxx
  6. 6
      src/main.cxx

@ -181,6 +181,8 @@ AC_DEFUN([AX_INIT_STANDARD_PROJECT], [
_AM_SUBST_NOTMAKE([AUTHOR]) _AM_SUBST_NOTMAKE([AUTHOR])
DISTRO=$(lsb_release -sc 2>/dev/null || uname -s 2>/dev/null) DISTRO=$(lsb_release -sc 2>/dev/null || uname -s 2>/dev/null)
AX_SUBST(DISTRO) AX_SUBST(DISTRO)
ARCH=$((@<:@@<:@ $(uname -sm) =~ 64 @:>@@:>@ && echo amd64) || (@<:@@<:@ $(uname -sm) =~ 'i?86' @:>@@:>@ && echo i386 || uname -sm))
AX_SUBST(ARCH)
DISTRIBUTOR=$(lsb_release -si 2>/dev/null || uname -s 2>/dev/null) DISTRIBUTOR=$(lsb_release -si 2>/dev/null || uname -s 2>/dev/null)
case "${DISTRIBUTOR// /-}" in case "${DISTRIBUTOR// /-}" in
(Ubuntu) UBUNTU=1; AX_SUBST(UBUNTU);; (Ubuntu) UBUNTU=1; AX_SUBST(UBUNTU);;

@ -31,8 +31,9 @@ while test $# -gt 0; do
(--configure|-c) configure=1;; (--configure|-c) configure=1;;
(--docker|-d) docker=1;; (--docker|-d) docker=1;;
(--build|-b) configure=1; build=1; buildtarget+=" distcheck";; (--build|-b) configure=1; build=1; buildtarget+=" distcheck";;
(--target|-t) shift; configure=1; build=1; buildtarget+=" $1";; (--all|-a) shift; configure=1; build=1; buildtarget+=" all";;
(--clean) shift; configure=1; build=1; buildtarget+=" maintainer-clean";; (--clean) shift; configure=1; build=1; buildtarget+=" maintainer-clean";;
(--target|-t) shift; configure=1; build=1; buildtarget+=" $1";;
(--overwrite|-o) overwrite=1;; (--overwrite|-o) overwrite=1;;
(--rebuild|-r) rebuild=1;; (--rebuild|-r) rebuild=1;;
(--rebuild-file|-f) shift; rebuildfiles+=("$1");; (--rebuild-file|-f) shift; rebuildfiles+=("$1");;
@ -51,6 +52,8 @@ OPTIONS
--configure, -c call ./configure after initialization --configure, -c call ./configure after initialization
--docker, -d build and run tests in a docker instance --docker, -d build and run tests in a docker instance
--build, -b build, also call ./configure && make distcheck --build, -b build, also call ./configure && make distcheck
--all, -a same as -b, but make target all
--clean same as -b, but make target maintainer-clean
--target, -t <target> same as -b, but specify target instead of distcheck --target, -t <target> same as -b, but specify target instead of distcheck
--overwrite, -o overwrite all basic files (bootstrap.sh, m4-macros) --overwrite, -o overwrite all basic files (bootstrap.sh, m4-macros)
--rebuild, -r force rebuild of generated files, even if modified --rebuild, -r force rebuild of generated files, even if modified
@ -129,6 +132,7 @@ GENERATED FILES
* resolve-debbuilddeps.sh - script to install debian package dependencies * resolve-debbuilddeps.sh - script to install debian package dependencies
* resolve-rpmbuilddeps.sh - script to install RPM package dependencies * resolve-rpmbuilddeps.sh - script to install RPM package dependencies
* build-in-docker.sh - script to build the project encapsulated in a docker container * build-in-docker.sh - script to build the project encapsulated in a docker container
* build-in-docker.conf - additional configuration for build-in-docker.sh
* build-resource-file.sh - build resource.qrc file from a resource directory * build-resource-file.sh - build resource.qrc file from a resource directory
* sql-to-dot.sed - script to convert SQL schema files to graphviz dot in doxygen * sql-to-dot.sed - script to convert SQL schema files to graphviz dot in doxygen
* mac-create-app-bundle.sh - script to create apple mac os-x app-bundle * mac-create-app-bundle.sh - script to create apple mac os-x app-bundle
@ -845,7 +849,7 @@ if testtag AX_USE_DOXYGEN; then
doxyreplace PROJECT_NAME "@PACKAGE_NAME@" doxyreplace PROJECT_NAME "@PACKAGE_NAME@"
doxyreplace PROJECT_NUMBER "@PACKAGE_VERSION@" doxyreplace PROJECT_NUMBER "@PACKAGE_VERSION@"
doxyreplace PROJECT_BRIEF "@DESCRIPTION@" doxyreplace PROJECT_BRIEF "@DESCRIPTION@"
doxyreplace PROJECT_LOGO "@top_srcdir@/@PACKACE_LOGO@" doxyreplace PROJECT_LOGO "@top_srcdir@/@PACKAGE_LOGO@"
doxyreplace INLINE_INHERITED_MEMB YES doxyreplace INLINE_INHERITED_MEMB YES
doxyreplace MULTILINE_CPP_IS_BRIEF YES doxyreplace MULTILINE_CPP_IS_BRIEF YES
doxyreplace TAB_SIZE 2 doxyreplace TAB_SIZE 2
@ -1162,6 +1166,12 @@ Libs: -L\${libdir} -l${PACKAGE_NAME#lib} @LDFLAGS@
Cflags: -I\${includedir} @CPPFLAGS@ Cflags: -I\${includedir} @CPPFLAGS@
Requires: @PKG_REQUIREMENTS@ Requires: @PKG_REQUIREMENTS@
EOF EOF
to build-in-docker.conf <<EOF
repos+=("Debian|Ubuntu-precise::::::universe")
repos+=("Ubuntu-precise:::'deb http://archive.ubuntu.com/ubuntu precise universe'")
envs+=("-e 'HOME=\${HOME}'")
dirs+=("-v \${HOME}/.gnupg:\${HOME}/.gnupg:ro")
EOF
#### Cleanup If Makefile Exists #### #### Cleanup If Makefile Exists ####
if test -f makefile; then if test -f makefile; then

@ -0,0 +1,4 @@
repos+=("Debian|Ubuntu-precise::::::universe")
repos+=("Ubuntu-precise:::'deb http://archive.ubuntu.com/ubuntu precise universe'")
envs+=("-e 'HOME=${HOME}'")
dirs+=("-v ${HOME}/.gnupg:${HOME}/.gnupg:ro")

@ -12,10 +12,17 @@
SCHROOTNAME="$1" SCHROOTNAME="$1"
PACKAGE_NAME=$(sed -n 's/^ *m4_define(x_package_name, \(.*\)).*/\1/p' configure.ac) PACKAGE_NAME=$(sed -n 's/^ *m4_define(x_package_name, \(.*\)).*/\1/p' configure.ac)
PKGCONFIGS="${2:-epel-release}" # packages to configure yum
if test -n "${SCHROOTNAME}"; then if test -n "${SCHROOTNAME}"; then
FILES=$(LANG= schroot -c ${SCHROOTNAME} -- rpmbuild -bb --clean --nobuild --define "_topdir ." --define "_sourcedir ." ${PACKAGE_NAME}.spec 2>&1 | sed -n 's, is needed by.*,,p') FILES=$(LANG= schroot -c ${SCHROOTNAME} -- rpmbuild -bb --clean --nobuild --define "_topdir ." --define "_sourcedir ." ${PACKAGE_NAME}.spec 2>&1 | sed -n 's, is needed by.*,,p')
if test -n "${FILES}"; then if test -n "${FILES}"; then
FIRST=$(echo "${FILES}" | egrep -o "${PKGCONFIGS// /|}")
if test -n "${FIRST}"; then
schroot -c ${SCHROOTNAME} -u root -- yum install -y ${FIRST} || \
schroot -c ${SCHROOTNAME} -u root -- zypper install -y ${FIRST} || \
schroot -c ${SCHROOTNAME} -u root -- dnf install -y ${FIRST}
fi
schroot -c ${SCHROOTNAME} -u root -- yum install -y ${FILES} || \ schroot -c ${SCHROOTNAME} -u root -- yum install -y ${FILES} || \
schroot -c ${SCHROOTNAME} -u root -- zypper install -y ${FILES} || \ schroot -c ${SCHROOTNAME} -u root -- zypper install -y ${FILES} || \
schroot -c ${SCHROOTNAME} -u root -- dnf install -y ${FILES} schroot -c ${SCHROOTNAME} -u root -- dnf install -y ${FILES}
@ -23,6 +30,12 @@ if test -n "${SCHROOTNAME}"; then
else else
FILES=$(LANG= rpmbuild -bb --clean --nobuild --define "_topdir ." --define "_sourcedir ." ${PACKAGE_NAME}.spec 2>&1 | sed -n 's, is needed by.*,,p') FILES=$(LANG= rpmbuild -bb --clean --nobuild --define "_topdir ." --define "_sourcedir ." ${PACKAGE_NAME}.spec 2>&1 | sed -n 's, is needed by.*,,p')
if test -n "${FILES}"; then if test -n "${FILES}"; then
FIRST=$(echo "${FILES}" | egrep -o "${PKGCONFIGS// /|}")
if test -n "${FIRST}"; then
yum install -y ${FIRST} || \
zypper install -y ${FIRST} || \
dnf install -y ${FIRST}
fi
yum install -y ${FILES} || \ yum install -y ${FILES} || \
zypper install -y ${FILES} || \ zypper install -y ${FILES} || \
dnf install -y ${FILES} dnf install -y ${FILES}

@ -17,6 +17,7 @@
#include <QMainWindow> #include <QMainWindow>
#include <QFileDialog> #include <QFileDialog>
#include <QFileInfo> #include <QFileInfo>
#include <QMessageBox>
#include <QRegExp> #include <QRegExp>
#include <QDebug> #include <QDebug>
@ -33,24 +34,34 @@ class CertMan: public QMainWindow, protected Ui::CertMan {
connect(&_openFromURL, SIGNAL(certificate(QUrl, QSslCertificate)), connect(&_openFromURL, SIGNAL(certificate(QUrl, QSslCertificate)),
SLOT(certificate(QUrl, QSslCertificate))); SLOT(certificate(QUrl, QSslCertificate)));
} }
virtual ~CertMan() {} bool open(const QString& fileName) {
protected slots: bool status(true);
void on__actionOpenCertificate_triggered() {
QString fileName = QFileDialog::getOpenFileName(this);
if (fileName.isEmpty()) return;
QFile file(fileName); QFile file(fileName);
file.open(QIODevice::ReadOnly); file.open(QIODevice::ReadOnly);
while (!file.atEnd()) {
QSslCertificate c(&file); QSslCertificate c(&file);
file.close(); if (!c.isNull()) {
if (c.isNull()) {
qDebug()<<QObject::trUtf8("Cannot read PEM certificate from file: %1")
.arg(fileName);
return;
}
Certificate* win(new Certificate(_mdi)); Certificate* win(new Certificate(_mdi));
_mdi->addSubWindow(win)->setWindowTitle(QFileInfo(fileName).fileName()); _mdi->addSubWindow(win)->setWindowTitle(QFileInfo(fileName).fileName());
win->show(); win->show();
win->certificate(c); win->certificate(c);
} else {
status = false;
qDebug()<<QObject::trUtf8("Cannot read PEM certificate from file: %1")
.arg(fileName);
}
}
file.close();
return status;
}
virtual ~CertMan() {}
protected slots:
void on__actionOpenCertificate_triggered() {
QString fileName = QFileDialog::getOpenFileName(this);
if (fileName.isEmpty()) return;
if (!open(fileName))
QMessageBox::warning(this, "Error Loading File",
QString("Error loading file:\n%1").arg(fileName));
} }
void on__actionOpenFromURL_triggered() { void on__actionOpenFromURL_triggered() {
if (_openFromURL.exec()==QDialog::Accepted) { if (_openFromURL.exec()==QDialog::Accepted) {

@ -18,8 +18,12 @@ int main(int argc, char *argv[]) try {
QCommandLineParser parser; QCommandLineParser parser;
parser.addHelpOption(); parser.addHelpOption();
parser.process(a); parser.process(a);
QStringList scripts(parser.positionalArguments()); QStringList files(parser.positionalArguments());
CertMan w; CertMan w;
for (const QString& file: files) {
if (!w.open(file))
std::cerr<<"Error reading file: "<<file.toStdString()<<std::endl;
}
w.show(); w.show();
return a.exec(); return a.exec();
} catch (std::exception &x) { } catch (std::exception &x) {

Loading…
Cancel
Save