charon-tkm: Register TKM private key on startup

This commit is contained in:
Reto Buerki
2013-03-19 15:23:49 +01:00
committed by Tobias Brunner
parent 08d199fa3d
commit c457128ab6
+13
View File
@@ -32,6 +32,7 @@
#include <utils/backtrace.h>
#include <threading/thread.h>
#include <sa/keymat.h>
#include <credentials/sets/mem_cred.h>
#include "tkm.h"
#include "tkm_nonceg.h"
@@ -40,6 +41,7 @@
#include "tkm_listener.h"
#include "tkm_kernel_ipsec.h"
#include "tkm_public_key.h"
#include "tkm_private_key.h"
/**
* TKM bus listener for IKE authorize events.
@@ -238,6 +240,10 @@ int main(int argc, char *argv[])
dmn_name = "charon-tkm";
}
/* credential set and TKM private key */
mem_cred_t *creds;
tkm_private_key_t *key;
struct sigaction action;
int status = SS_RC_INITIALIZATION_FAILED;
@@ -341,6 +347,12 @@ int main(int argc, char *argv[])
listener = tkm_listener_create();
charon->bus->add_listener(charon->bus, &listener->listener);
/* register TKM private key */
creds = mem_cred_create();
key = tkm_private_key_init();
creds->add_key(creds, (private_key_t *)key);
lib->credmgr->add_set(lib->credmgr, (credential_set_t*)creds);
/* add handler for SEGV and ILL,
* INT and TERM are handled by sigwait() in run() */
action.sa_handler = segv_handler;
@@ -366,6 +378,7 @@ int main(int argc, char *argv[])
status = 0;
charon->bus->remove_listener(charon->bus, &listener->listener);
listener->destroy(listener);
creds->destroy(creds);
deinit:
libcharon_deinit();