add example for using QSslCertificate; refs #28

master
Marc Wäckerlin 11 years ago
parent e913a8da13
commit 41d8c55db6
  1. 2
      COPYING
  2. 2
      INSTALL
  3. 2
      configure.in
  4. 4
      doc/examples/makefile.am
  5. 18
      doc/examples/suisse-id-demo.cxx

@ -1 +1 @@
/usr/share/automake-1.11/COPYING /usr/share/automake-1.13/COPYING

@ -1 +1 @@
/usr/share/automake-1.11/INSTALL /usr/share/automake-1.13/INSTALL

@ -94,7 +94,7 @@ AC_CHECK_PROG(have_dot, dot, yes, no)
PKG_PROG_PKG_CONFIG PKG_PROG_PKG_CONFIG
# libraries # libraries
#PKG_CHECK_MODULES([QT], [QtNetwork]) PKG_CHECK_MODULES([QT], [QtNetwork])
AC_ARG_ENABLE(pedantic, AC_ARG_ENABLE(pedantic,
[AS_HELP_STRING([--enable-pedantic], [AS_HELP_STRING([--enable-pedantic],

@ -36,8 +36,8 @@ openssl_engine_demo_SOURCES = openssl-engine-demo.cxx
cardos_demo_SOURCES = cardos-demo.cxx cardos_demo_SOURCES = cardos-demo.cxx
suisse_id_demo_SOURCES = suisse-id-demo.cxx suisse_id_demo_SOURCES = suisse-id-demo.cxx
# moc_suisse-id-demo.cxx # moc_suisse-id-demo.cxx
#suisse_id_demo_CXXFLAGS = ${QT_CFLAGS} suisse_id_demo_CXXFLAGS = ${QT_CFLAGS}
#suisse_id_demo_LDADD = ${QT_LIBS} suisse_id_demo_LDADD = ${QT_LIBS}
moc_%.cxx: %.hxx moc_%.cxx: %.hxx
moc -o $@ $< moc -o $@ $<

@ -8,6 +8,9 @@
#include <suisse-id-demo.hxx> #include <suisse-id-demo.hxx>
#include <mrw/args.hxx> #include <mrw/args.hxx>
#include <QtNetwork/QSslCertificate>
#include <QtCore/QDateTime>
int main(int argc, char** argv) try { int main(int argc, char** argv) try {
std::string lib("libcvP11.so"); std::string lib("libcvP11.so");
mrw::args::parse(argc, argv, mrw::args::parse(argc, argv,
@ -53,6 +56,7 @@ int main(int argc, char** argv) try {
<<" r: remove all certificates"<<std::endl <<" r: remove all certificates"<<std::endl
<<" p: PIN change"<<std::endl <<" p: PIN change"<<std::endl
<<" i: (re-) import certificates"<<std::endl <<" i: (re-) import certificates"<<std::endl
<<" z: show certificates"<<std::endl
<<" q: quit"<<std::endl; <<" q: quit"<<std::endl;
std::cin>>choice; std::cin>>choice;
try { try {
@ -76,6 +80,20 @@ int main(int argc, char** argv) try {
} else if (choice=="i") { } else if (choice=="i") {
TextualCycle check(*card); TextualCycle check(*card);
check.installCerts(true); check.installCerts(true);
} else if (choice=="z") {
for (cryptoki::ObjectList::iterator cert(certs.begin());
cert!=certs.end(); ++cert) {
std::string data(cert->attribute(CKA_VALUE).value);
QByteArray der(QByteArray(data.data(), data.size()));
QSslCertificate c(der, QSsl::Der);
std::cout<<"Certificate info: CN="
<<QString(c.subjectInfo(QSslCertificate::CommonName)
.toUtf8()).toStdString()
<<std::endl
<<" Valid until: "
<<QString(c.expiryDate().toString().toUtf8()).toStdString()
<<std::endl;
}
} else if (choice=="q") { } else if (choice=="q") {
return 0; return 0;
} else { } else {

Loading…
Cancel
Save