it works; closes #8
This commit is contained in:
@@ -6,7 +6,11 @@ TARGET =
|
||||
DEPENDPATH += .
|
||||
INCLUDEPATH += ../openssl-act-engine ../openssl-act-engine/src . ../qt/qt-everywhere-opensource-src-4.6.3/include ../qt/qt-everywhere-opensource-src-4.6.3/include/Qt
|
||||
|
||||
CONFIG += debug
|
||||
QMAKE_CXXFLAGS+=-pthread
|
||||
QMAKE_LFLAGS+=-pthread
|
||||
|
||||
CONFIG += debug thread
|
||||
LIBS += -lssl
|
||||
|
||||
# Input
|
||||
SOURCES += qtssltest.cpp \
|
||||
|
@@ -6,11 +6,54 @@
|
||||
#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);
|
||||
@@ -20,7 +63,7 @@ int main(int argc, char *argv[])
|
||||
// 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("D:\\QtSmartCardAuth_TMI\\QtSslTest\\swsign_root.pem");
|
||||
QFile caCertsFile("swsign_root.pem");
|
||||
caCertsFile.open(QIODevice::ReadOnly);
|
||||
QList<QSslCertificate> chain( QSslCertificate::fromDevice(&caCertsFile) );
|
||||
|
||||
|
@@ -6,6 +6,8 @@
|
||||
|
||||
#include <string>
|
||||
|
||||
#include <QtCore/QDebug>
|
||||
|
||||
ENGINE* SmartCardAuth::e=NULL;
|
||||
enum_certs_s* SmartCardAuth::certs_found=NULL;
|
||||
QWidget* SmartCardAuth::parent=0;
|
||||
@@ -13,16 +15,20 @@ bool SmartCardAuth::pin_configured=false;
|
||||
bool SmartCardAuth::pin_rejected=false;
|
||||
|
||||
void SmartCardAuth::initialize() {
|
||||
QSslSocketPrivate::ensureInitialized();
|
||||
//QSslSocketPrivate::ensureInitialized();
|
||||
|
||||
q_ENGINE_load_dynamic();
|
||||
e = q_ENGINE_by_id("dynamic");
|
||||
ENGINE_load_dynamic();
|
||||
e = ENGINE_by_id("dynamic");
|
||||
Q_ASSERT(e);
|
||||
|
||||
//! @todo add library-name
|
||||
int r=q_ENGINE_ctrl_cmd_string(e, "SO_PATH", "...library-name...", 0);
|
||||
r=q_ENGINE_ctrl_cmd_string(e, "ID", "act", 0);
|
||||
r=q_ENGINE_ctrl_cmd_string(e, "LIST_ADD", "1", 0);
|
||||
r=q_ENGINE_ctrl_cmd_string(e, "LOAD", NULL, 0);
|
||||
int r=ENGINE_ctrl_cmd_string(e, "SO_PATH", "../openssl-act-engine/src/.libs/libengine_act.so", 0);
|
||||
Q_ASSERT(r);
|
||||
r=ENGINE_ctrl_cmd_string(e, "ID", "act", 0);
|
||||
Q_ASSERT(r);
|
||||
r=ENGINE_ctrl_cmd_string(e, "LIST_ADD", "1", 0);
|
||||
Q_ASSERT(r);
|
||||
r=ENGINE_ctrl_cmd_string(e, "LOAD", NULL, 0);
|
||||
Q_ASSERT(r);
|
||||
|
||||
if(!r)
|
||||
{
|
||||
@@ -34,7 +40,7 @@ void SmartCardAuth::initialize() {
|
||||
}
|
||||
}
|
||||
|
||||
r=q_ENGINE_init(e);
|
||||
r=ENGINE_init(e);
|
||||
|
||||
}
|
||||
|
||||
@@ -59,6 +65,7 @@ int SmartCardAuth::client_cert_cb(SSL *ssl, X509 **x509, EVP_PKEY **pkey)
|
||||
|
||||
// Name has the format "slot-x-name-SwissSign_digSig" for the certificate/key we're looking for
|
||||
std::string name(certs_found->certificate[i].name);
|
||||
qDebug()<<"Certificate:"<<name.c_str();
|
||||
std::string compare("-name-SwissSign_digSig");
|
||||
|
||||
// Compare the rightmost part of the retrieved name to locate the certificate/keypair
|
||||
|
@@ -2,6 +2,7 @@
|
||||
#define SMARTCARDAUTH_H
|
||||
|
||||
#include <Qt/private/qopensslhook_p.h>
|
||||
|
||||
class QWidget;
|
||||
|
||||
struct enum_certs_s;
|
||||
|
Reference in New Issue
Block a user