Added a stroke command to export cached x509 certificates to the console
This commit is contained in:
+24
-1
@@ -288,9 +288,23 @@ static int purge(stroke_keyword_t kw)
|
||||
return send_stroke_msg(&msg);
|
||||
}
|
||||
|
||||
static int export_flags[] = {
|
||||
EXPORT_X509,
|
||||
};
|
||||
|
||||
static int export(stroke_keyword_t kw, char *selector)
|
||||
{
|
||||
stroke_msg_t msg;
|
||||
|
||||
msg.type = STR_EXPORT;
|
||||
msg.length = offsetof(stroke_msg_t, buffer);
|
||||
msg.export.selector = push_string(&msg, selector);
|
||||
msg.export.flags = export_flags[kw - STROKE_EXPORT_FIRST];
|
||||
return send_stroke_msg(&msg);
|
||||
}
|
||||
|
||||
static int leases(stroke_keyword_t kw, char *pool, char *address)
|
||||
{
|
||||
|
||||
stroke_msg_t msg;
|
||||
|
||||
msg.type = STR_LEASES;
|
||||
@@ -361,6 +375,8 @@ static void exit_usage(char *error)
|
||||
printf(" stroke purgeocsp\n");
|
||||
printf(" Purge IKE_SAs without a CHILD_SA:\n");
|
||||
printf(" stroke purgeike\n");
|
||||
printf(" Export credentials to the console:\n");
|
||||
printf(" stroke exportx509 DN\n");
|
||||
printf(" Show leases of a pool:\n");
|
||||
printf(" stroke leases [POOL [ADDRESS]]\n");
|
||||
exit_error(error);
|
||||
@@ -478,6 +494,13 @@ int main(int argc, char *argv[])
|
||||
case STROKE_PURGE_IKE:
|
||||
res = purge(token->kw);
|
||||
break;
|
||||
case STROKE_EXPORT_X509:
|
||||
if (argc != 3)
|
||||
{
|
||||
exit_usage("\"exportx509\" needs a distinguished name");
|
||||
}
|
||||
res = export(token->kw, argv[2]);
|
||||
break;
|
||||
case STROKE_LEASES:
|
||||
res = leases(token->kw, argc > 2 ? argv[2] : NULL,
|
||||
argc > 3 ? argv[3] : NULL);
|
||||
|
||||
@@ -49,12 +49,14 @@ typedef enum {
|
||||
STROKE_REREAD_ALL,
|
||||
STROKE_PURGE_OCSP,
|
||||
STROKE_PURGE_IKE,
|
||||
STROKE_LEASES
|
||||
STROKE_EXPORT_X509,
|
||||
STROKE_LEASES,
|
||||
} stroke_keyword_t;
|
||||
|
||||
#define STROKE_LIST_FIRST STROKE_LIST_PUBKEYS
|
||||
#define STROKE_REREAD_FIRST STROKE_REREAD_SECRETS
|
||||
#define STROKE_PURGE_FIRST STROKE_PURGE_OCSP
|
||||
#define STROKE_EXPORT_FIRST STROKE_EXPORT_X509
|
||||
|
||||
typedef struct stroke_token stroke_token_t;
|
||||
|
||||
|
||||
@@ -56,4 +56,5 @@ rereadcrls, STROKE_REREAD_CRLS
|
||||
rereadall, STROKE_REREAD_ALL
|
||||
purgeocsp, STROKE_PURGE_OCSP
|
||||
purgeike, STROKE_PURGE_IKE
|
||||
exportx509, STROKE_EXPORT_X509
|
||||
leases, STROKE_LEASES
|
||||
|
||||
@@ -109,6 +109,16 @@ enum purge_flag_t {
|
||||
PURGE_IKE = 0x0002,
|
||||
};
|
||||
|
||||
typedef enum export_flag_t export_flag_t;
|
||||
|
||||
/**
|
||||
* Definition of the export flags
|
||||
*/
|
||||
enum export_flag_t {
|
||||
/** export an X509 certificate */
|
||||
EXPORT_X509 = 0x0001,
|
||||
};
|
||||
|
||||
/**
|
||||
* CRL certificate validation policy
|
||||
*/
|
||||
@@ -193,6 +203,8 @@ struct stroke_msg_t {
|
||||
STR_PURGE,
|
||||
/* show pool leases */
|
||||
STR_LEASES,
|
||||
/* export credentials */
|
||||
STR_EXPORT,
|
||||
/* more to come */
|
||||
} type;
|
||||
|
||||
@@ -301,6 +313,12 @@ struct stroke_msg_t {
|
||||
purge_flag_t flags;
|
||||
} purge;
|
||||
|
||||
/* data for STR_EXPORT */
|
||||
struct {
|
||||
export_flag_t flags;
|
||||
char *selector;
|
||||
} export;
|
||||
|
||||
/* data for STR_LEASES */
|
||||
struct {
|
||||
char *pool;
|
||||
|
||||
Reference in New Issue
Block a user