|
|
|
#include <QApplication>
|
|
|
|
#include <QtNetwork>
|
|
|
|
#include <QtWebKit>
|
|
|
|
#include <QList>
|
|
|
|
#include <QFile>
|
|
|
|
#include <iostream>
|
|
|
|
#include "smartcardauth.h"
|
|
|
|
|
|
|
|
#include <openssl/engine.h>
|
|
|
|
|
|
|
|
#define CHECK(X) \
|
|
|
|
if (((!(((res=X)))))) { \
|
|
|
|
printf("ERROR: %s\n", #X); \
|
|
|
|
for (unsigned int err(0); err=ERR_get_error();) { \
|
|
|
|
fprintf(stderr,"%s\n", ERR_error_string(err, NULL)); \
|
|
|
|
} \
|
|
|
|
return -1; \
|
|
|
|
}
|
|
|
|
|
|
|
|
SmartCardAuth g_scard_auth;
|
|
|
|
|
|
|
|
int main(int argc, char *argv[])
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
ENGINE* e = NULL;
|
|
|
|
enum_certs_s* certs_found = NULL;
|
|
|
|
|
|
|
|
ENGINE_load_dynamic();
|
|
|
|
e = ENGINE_by_id("dynamic");
|
|
|
|
|
|
|
|
if (!e) {
|
|
|
|
printf("ERROR: No Engine");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
int res(-1);
|
|
|
|
|
|
|
|
// Parameters to set for the dynamic loader
|
|
|
|
CHECK(ENGINE_ctrl_cmd_string(e, "SO_PATH", "./.libs/libengine_act.so", 0));
|
|
|
|
CHECK(ENGINE_ctrl_cmd_string(e, "ID", "act", 0));
|
|
|
|
CHECK(ENGINE_ctrl_cmd_string(e, "LIST_ADD", "1", 0));
|
|
|
|
|
|
|
|
// Now actually load the SecureToken engine.
|
|
|
|
CHECK(ENGINE_ctrl_cmd_string(e, "LOAD", NULL, 0)
|
|
|
|
|| ENGINE_ctrl_cmd_string(e, "SO_PATH", "./src/.libs/libengine_act.so", 0)
|
|
|
|
&& ENGINE_ctrl_cmd_string(e, "LOAD", NULL, 0)
|
|
|
|
|| ENGINE_ctrl_cmd_string(e, "SO_PATH", "../openssl-act-engine/src/.libs/libengine_act.so", 0)
|
|
|
|
&& ENGINE_ctrl_cmd_string(e, "LOAD", NULL, 0));
|
|
|
|
|
|
|
|
// Following control commands go to the SecureToken engine rather than the dynamic loader
|
|
|
|
|
|
|
|
CHECK(ENGINE_init(e));
|
|
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
*/
|
|
|
|
SmartCardAuth::initialize();
|
|
|
|
|
|
|
|
QApplication app(argc, argv);
|
|
|
|
|
|
|
|
QSslConfiguration sslConf(QSslConfiguration::defaultConfiguration());
|
|
|
|
|
|
|
|
// Works even without specifying the root certificate, we just need to add the intermediates,
|
|
|
|
// and that's done in SmartCardAuth.cpp
|
|
|
|
#if 0
|
|
|
|
QFile caCertsFile("swsign_root.pem");
|
|
|
|
caCertsFile.open(QIODevice::ReadOnly);
|
|
|
|
QList<QSslCertificate> chain( QSslCertificate::fromDevice(&caCertsFile) );
|
|
|
|
|
|
|
|
sslConf.setCaCertificates(chain);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
sslConf.setPeerVerifyMode(QSslSocket::QueryPeer);
|
|
|
|
sslConf.setOpenSslHook(&g_scard_auth);
|
|
|
|
QSslConfiguration::setDefaultConfiguration(sslConf);
|
|
|
|
|
|
|
|
// TODO - IMPORTANT: Error reporting!
|
|
|
|
// If there is ANY failure (no network, no host resolution, no SSL connection, timeout) we just see a
|
|
|
|
// blank page!
|
|
|
|
QWebView web;
|
|
|
|
|
|
|
|
// Works - NEEDS AN INTERMEDIATE CERTIFICATE, either loaded from card or from file, see SmartCardAuth
|
|
|
|
web.load(QUrl("https://dev.swisssign.com/test/"));
|
|
|
|
|
|
|
|
// web.load(QUrl("https://e2k7.demo8.cryptovision.com/ssl/"));
|
|
|
|
web.show();
|
|
|
|
|
|
|
|
int rv=app.exec();
|
|
|
|
SmartCardAuth::deinitialize();
|
|
|
|
return rv;
|
|
|
|
}
|