some minor changes; refs #8
This commit is contained in:
@@ -5,6 +5,16 @@
|
||||
#include <openssl/rsa.h>
|
||||
#include <openssl/engine.h>
|
||||
|
||||
#define CHECK(X) \
|
||||
if (!(res=X)) { \
|
||||
printf("ERROR: %s", #X); \
|
||||
for (unsigned int err(0); err=ERR_get_error();) { \
|
||||
fprintf(stderr,"%s\n", ERR_error_string(err, NULL)); \
|
||||
} \
|
||||
return -1; \
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
ENGINE* e = NULL;
|
||||
@@ -12,22 +22,27 @@ int main(int argc, char* argv[])
|
||||
|
||||
ENGINE_load_dynamic();
|
||||
e = ENGINE_by_id("dynamic");
|
||||
|
||||
if (!e) {
|
||||
printf("ERROR: No Engine");
|
||||
return -1;
|
||||
}
|
||||
|
||||
int res;
|
||||
int res(-1);
|
||||
|
||||
// Parameters to set for the dynamic loader
|
||||
res = ENGINE_ctrl_cmd_string(e, "SO_PATH", "/home/carsten/engine_securetoken/libengine_securetoken.so", 0);
|
||||
res = ENGINE_ctrl_cmd_string(e, "ID", "securetoken", 0);
|
||||
res = ENGINE_ctrl_cmd_string(e, "LIST_ADD", "1", 0);
|
||||
CHECK(ENGINE_ctrl_cmd_string(e, "SO_PATH", "./libengine_act.so", 0));
|
||||
CHECK(ENGINE_ctrl_cmd_string(e, "ID", "securetoken", 0));
|
||||
CHECK(ENGINE_ctrl_cmd_string(e, "LIST_ADD", "1", 0));
|
||||
|
||||
// Now actually load the SecureToken engine.
|
||||
res = ENGINE_ctrl_cmd_string(e, "LOAD", NULL, 0);
|
||||
CHECK(ENGINE_ctrl_cmd_string(e, "LOAD", NULL, 0));
|
||||
|
||||
// Following control commands go to the SecureToken engine rather than the dynamic loader
|
||||
|
||||
res = ENGINE_init(e);
|
||||
CHECK(ENGINE_init(e));
|
||||
|
||||
res = ENGINE_ctrl_cmd(e, "ENUM_CERTS", 0, &certs_found, NULL, 0);
|
||||
CHECK(ENGINE_ctrl_cmd(e, "ENUM_CERTS", 0, &certs_found, NULL, 0));
|
||||
|
||||
printf("Found %d certificates.\n", certs_found->num_certs);
|
||||
|
||||
@@ -76,7 +91,7 @@ int main(int argc, char* argv[])
|
||||
|
||||
|
||||
|
||||
res = ENGINE_finish(e);
|
||||
CHECK(ENGINE_finish(e));
|
||||
|
||||
ENGINE_cleanup();
|
||||
|
||||
|
Reference in New Issue
Block a user