]> git.ipfire.org Git - thirdparty/strongswan.git/commitdiff
stroke: List loaded CGA parameters in "ipsec listcerts"
authorMartin Willi <martin@revosec.ch>
Wed, 28 Jan 2015 17:20:55 +0000 (18:20 +0100)
committerMartin Willi <martin@revosec.ch>
Tue, 24 Feb 2015 16:13:57 +0000 (17:13 +0100)
src/libcharon/plugins/stroke/stroke_list.c

index 490983100e44c02d5c94f055c9332f328c90a228..bae3c1edd47db7ea3a3edcbef4487f6eab8c34ba 100644 (file)
@@ -881,6 +881,38 @@ static void stroke_list_pgp(linked_list_t *list,bool utc, FILE *out)
        enumerator->destroy(enumerator);
 }
 
+/**
+ * list CGA parameters
+ */
+static void stroke_list_cga(linked_list_t *list, FILE *out)
+{
+       enumerator_t *enumerator;
+       certificate_t *cert;
+       bool first = TRUE;
+
+       enumerator = list->create_enumerator(list);
+       while (enumerator->enumerate(enumerator, &cert))
+       {
+               public_key_t *public;
+
+               if (first)
+               {
+                       fprintf(out, "\n");
+                       fprintf(out, "List of CGA parameters:\n");
+                       first = FALSE;
+               }
+               fprintf(out, "\n");
+               fprintf(out, "  CGA:       %Y\n", cert->get_subject(cert));
+               public = cert->get_public_key(cert);
+               if (public)
+               {
+                       list_public_key(public, out);
+                       public->destroy(public);
+               }
+       }
+       enumerator->destroy(enumerator);
+}
+
 /**
  * list all X.509 certificates matching the flags
  */
@@ -1452,6 +1484,14 @@ METHOD(stroke_list_t, list, void,
                stroke_list_pgp(pgp_list, msg->list.utc, out);
                pgp_list->destroy_offset(pgp_list, offsetof(certificate_t, destroy));
        }
+       if (msg->list.flags & LIST_CERTS)
+       {
+               linked_list_t *cgas;
+
+               cgas = create_unique_cert_list(CERT_CGA_PARAMS);
+               stroke_list_cga(cgas, out);
+               cgas->destroy_offset(cgas, offsetof(certificate_t, destroy));
+       }
        if (msg->list.flags & (LIST_CERTS | LIST_CACERTS | LIST_OCSPCERTS | LIST_AACERTS))
        {
                cert_list = create_unique_cert_list(CERT_X509);