aboutsummaryrefslogtreecommitdiffstats
path: root/src/libcharon/plugins/stroke
diff options
context:
space:
mode:
authorMartin Willi <martin@revosec.ch>2010-08-10 16:57:14 +0200
committerMartin Willi <martin@revosec.ch>2010-08-10 18:46:30 +0200
commit3d711a68fb3fc2a9bc3cb88ffd8f4db4c0a09ac5 (patch)
treeef2a8287d61741ed966cfef705c895b48aa36160 /src/libcharon/plugins/stroke
parenta944d2092bb8663be21f863bbe27fa475966c9d9 (diff)
downloadstrongswan-3d711a68fb3fc2a9bc3cb88ffd8f4db4c0a09ac5.tar.bz2
strongswan-3d711a68fb3fc2a9bc3cb88ffd8f4db4c0a09ac5.tar.xz
Added a stroke command to export cached x509 certificates to the console
Diffstat (limited to 'src/libcharon/plugins/stroke')
-rw-r--r--src/libcharon/plugins/stroke/stroke_socket.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/src/libcharon/plugins/stroke/stroke_socket.c b/src/libcharon/plugins/stroke/stroke_socket.c
index 18afa5af4..fc54472ee 100644
--- a/src/libcharon/plugins/stroke/stroke_socket.c
+++ b/src/libcharon/plugins/stroke/stroke_socket.c
@@ -353,6 +353,37 @@ static void stroke_purge(private_stroke_socket_t *this,
}
/**
+ * Export in-memory credentials
+ */
+static void stroke_export(private_stroke_socket_t *this,
+ stroke_msg_t *msg, FILE *out)
+{
+ pop_string(msg, &msg->export.selector);
+
+ if (msg->purge.flags & EXPORT_X509)
+ {
+ enumerator_t *enumerator;
+ identification_t *id;
+ certificate_t *cert;
+ chunk_t encoded;
+
+ id = identification_create_from_string(msg->export.selector);
+ enumerator = lib->credmgr->create_cert_enumerator(lib->credmgr,
+ CERT_X509, KEY_ANY, id, FALSE);
+ while (enumerator->enumerate(enumerator, &cert))
+ {
+ if (cert->get_encoding(cert, CERT_PEM, &encoded))
+ {
+ fprintf(out, "%.*s", encoded.len, encoded.ptr);
+ free(encoded.ptr);
+ }
+ }
+ enumerator->destroy(enumerator);
+ id->destroy(id);
+ }
+}
+
+/**
* list pool leases
*/
static void stroke_leases(private_stroke_socket_t *this,
@@ -525,6 +556,9 @@ static job_requeue_t process(stroke_job_context_t *ctx)
case STR_PURGE:
stroke_purge(this, msg, out);
break;
+ case STR_EXPORT:
+ stroke_export(this, msg, out);
+ break;
case STR_LEASES:
stroke_leases(this, msg, out);
break;