ported parts of two-sim branch
[strongswan.git] / src / charon / plugins / stroke / stroke_list.c
1 /*
2 * Copyright (C) 2008 Martin Willi
3 * Hochschule fuer Technik Rapperswil
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License as published by the
7 * Free Software Foundation; either version 2 of the License, or (at your
8 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
9 *
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13 * for more details.
14 *
15 * $Id$
16 */
17
18 #include "stroke_list.h"
19
20 #include <daemon.h>
21 #include <utils/linked_list.h>
22 #include <credentials/certificates/x509.h>
23 #include <credentials/certificates/ac.h>
24 #include <credentials/certificates/crl.h>
25 #include <config/peer_cfg.h>
26
27 /* warning intervals for list functions */
28 #define CERT_WARNING_INTERVAL 30 /* days */
29 #define CRL_WARNING_INTERVAL 7 /* days */
30 #define AC_WARNING_INTERVAL 1 /* day */
31
32 typedef struct private_stroke_list_t private_stroke_list_t;
33
34 /**
35 * private data of stroke_list
36 */
37 struct private_stroke_list_t {
38
39 /**
40 * public functions
41 */
42 stroke_list_t public;
43
44 /**
45 * timestamp of daemon start
46 */
47 time_t uptime;
48 };
49
50 /**
51 * get the authentication class of a config
52 */
53 auth_class_t get_auth_class(peer_cfg_t *config)
54 {
55 auth_class_t *class;
56 auth_info_t *auth_info;
57
58 auth_info = config->get_auth(config);
59 if (auth_info->get_item(auth_info, AUTHN_AUTH_CLASS, (void**)&class))
60 {
61 return *class;
62 }
63 /* fallback to pubkey authentication */
64 return AUTH_CLASS_PUBKEY;
65 }
66
67 /**
68 * log an IKE_SA to out
69 */
70 static void log_ike_sa(FILE *out, ike_sa_t *ike_sa, bool all)
71 {
72 ike_sa_id_t *id = ike_sa->get_id(ike_sa);
73
74 fprintf(out, "%12s[%d]: %N, %H[%D]...%H[%D]\n",
75 ike_sa->get_name(ike_sa), ike_sa->get_unique_id(ike_sa),
76 ike_sa_state_names, ike_sa->get_state(ike_sa),
77 ike_sa->get_my_host(ike_sa), ike_sa->get_my_id(ike_sa),
78 ike_sa->get_other_host(ike_sa), ike_sa->get_other_id(ike_sa));
79
80 if (all)
81 {
82 char *ike_proposal = ike_sa->get_proposal(ike_sa);
83
84 fprintf(out, "%12s[%d]: IKE SPIs: %.16llx_i%s %.16llx_r%s",
85 ike_sa->get_name(ike_sa), ike_sa->get_unique_id(ike_sa),
86 id->get_initiator_spi(id), id->is_initiator(id) ? "*" : "",
87 id->get_responder_spi(id), id->is_initiator(id) ? "" : "*");
88
89
90 if (ike_sa->get_state(ike_sa) == IKE_ESTABLISHED)
91 {
92 u_int32_t rekey = ike_sa->get_statistic(ike_sa, STAT_REKEY_TIME);
93 u_int32_t reauth = ike_sa->get_statistic(ike_sa, STAT_REAUTH_TIME);
94
95 if (rekey)
96 {
97 fprintf(out, ", rekeying in %V", &rekey);
98 }
99 if (reauth)
100 {
101 fprintf(out, ", %N reauthentication in %V", auth_class_names,
102 get_auth_class(ike_sa->get_peer_cfg(ike_sa)), &reauth);
103 }
104 if (!rekey && !reauth)
105 {
106 fprintf(out, ", rekeying disabled");
107 }
108 }
109 fprintf(out, "\n");
110
111 if (ike_proposal)
112 {
113 fprintf(out, "%12s[%d]: IKE proposal: %s\n",
114 ike_sa->get_name(ike_sa), ike_sa->get_unique_id(ike_sa),
115 ike_proposal);
116 }
117 }
118 }
119
120 /**
121 * log an CHILD_SA to out
122 */
123 static void log_child_sa(FILE *out, child_sa_t *child_sa, bool all)
124 {
125 u_int32_t rekey, now = time(NULL);
126 u_int32_t use_in, use_out, use_fwd;
127 encryption_algorithm_t encr_alg;
128 integrity_algorithm_t int_alg;
129 size_t encr_len, int_len;
130 mode_t mode;
131
132 child_sa->get_stats(child_sa, &mode, &encr_alg, &encr_len,
133 &int_alg, &int_len, &rekey, &use_in, &use_out,
134 &use_fwd);
135
136 fprintf(out, "%12s{%d}: %N, %N",
137 child_sa->get_name(child_sa), child_sa->get_reqid(child_sa),
138 child_sa_state_names, child_sa->get_state(child_sa),
139 mode_names, mode);
140
141 if (child_sa->get_state(child_sa) == CHILD_INSTALLED)
142 {
143 u_int16_t my_cpi = child_sa->get_cpi(child_sa, TRUE);
144 u_int16_t other_cpi = child_sa->get_cpi(child_sa, FALSE);
145
146 fprintf(out, ", %N SPIs: %.8x_i %.8x_o",
147 protocol_id_names, child_sa->get_protocol(child_sa),
148 ntohl(child_sa->get_spi(child_sa, TRUE)),
149 ntohl(child_sa->get_spi(child_sa, FALSE)));
150
151 /* Is IPCOMP activated ? */
152 if (my_cpi && other_cpi)
153 {
154 fprintf(out, ", IPCOMP CPIs: %.4x_i %.4x_o",
155 ntohs(my_cpi), ntohs(other_cpi));
156 }
157
158 if (all)
159 {
160 fprintf(out, "\n%12s{%d}: ", child_sa->get_name(child_sa),
161 child_sa->get_reqid(child_sa));
162
163
164 if (child_sa->get_protocol(child_sa) == PROTO_ESP)
165 {
166 fprintf(out, "%N", encryption_algorithm_names, encr_alg);
167
168 if (encr_len)
169 {
170 fprintf(out, "-%d", encr_len);
171 }
172 if (int_alg != AUTH_UNDEFINED)
173 {
174 fprintf(out, "/");
175 }
176 }
177
178 if (int_alg != AUTH_UNDEFINED)
179 {
180 fprintf(out, "%N", integrity_algorithm_names, int_alg);
181 if (int_len)
182 {
183 fprintf(out, "-%d", int_len);
184 }
185 }
186 fprintf(out, ", rekeying ");
187
188 if (rekey)
189 {
190 fprintf(out, "in %#V", &now, &rekey);
191 }
192 else
193 {
194 fprintf(out, "disabled");
195 }
196
197 fprintf(out, ", last use: ");
198 use_in = max(use_in, use_fwd);
199 if (use_in)
200 {
201 fprintf(out, "%ds_i ", now - use_in);
202 }
203 else
204 {
205 fprintf(out, "no_i ");
206 }
207 if (use_out)
208 {
209 fprintf(out, "%ds_o ", now - use_out);
210 }
211 else
212 {
213 fprintf(out, "no_o ");
214 }
215 }
216 }
217
218 fprintf(out, "\n%12s{%d}: %#R=== %#R\n",
219 child_sa->get_name(child_sa), child_sa->get_reqid(child_sa),
220 child_sa->get_traffic_selectors(child_sa, TRUE),
221 child_sa->get_traffic_selectors(child_sa, FALSE));
222 }
223
224 /**
225 * Implementation of stroke_list_t.status.
226 */
227 static void status(private_stroke_list_t *this, stroke_msg_t *msg, FILE *out, bool all)
228 {
229 enumerator_t *enumerator, *children;
230 iterator_t *iterator;
231 host_t *host;
232 peer_cfg_t *peer_cfg;
233 ike_cfg_t *ike_cfg;
234 child_cfg_t *child_cfg;
235 ike_sa_t *ike_sa;
236 char *name = NULL, *plugin;
237 bool found = FALSE;
238 u_int32_t dpd;
239 time_t uptime;
240
241 name = msg->status.name;
242
243 if (all)
244 {
245 uptime = time(NULL) - this->uptime;
246 fprintf(out, "Performance:\n");
247 fprintf(out, " uptime: %V, since %#T\n", &uptime, &this->uptime, FALSE);
248 fprintf(out, " worker threads: %d idle of %d,",
249 charon->processor->get_idle_threads(charon->processor),
250 charon->processor->get_total_threads(charon->processor));
251 fprintf(out, " job queue load: %d,",
252 charon->processor->get_job_load(charon->processor));
253 fprintf(out, " scheduled events: %d\n",
254 charon->scheduler->get_job_load(charon->scheduler));
255 fprintf(out, " loaded plugins: ");
256 enumerator = lib->plugins->create_plugin_enumerator(lib->plugins);
257 while (enumerator->enumerate(enumerator, &plugin))
258 {
259 fprintf(out, "%s ", plugin);
260 }
261 enumerator->destroy(enumerator);
262 fprintf(out, "\n");
263
264 iterator = charon->kernel_interface->create_address_iterator(
265 charon->kernel_interface);
266 fprintf(out, "Listening IP addresses:\n");
267 while (iterator->iterate(iterator, (void**)&host))
268 {
269 fprintf(out, " %H\n", host);
270 }
271 iterator->destroy(iterator);
272
273 fprintf(out, "Connections:\n");
274 enumerator = charon->backends->create_peer_cfg_enumerator(charon->backends);
275 while (enumerator->enumerate(enumerator, (void**)&peer_cfg))
276 {
277 if (peer_cfg->get_ike_version(peer_cfg) != 2 ||
278 (name && !streq(name, peer_cfg->get_name(peer_cfg))))
279 {
280 continue;
281 }
282
283 ike_cfg = peer_cfg->get_ike_cfg(peer_cfg);
284 fprintf(out, "%12s: %s[%D]...%s[%D]\n", peer_cfg->get_name(peer_cfg),
285 ike_cfg->get_my_addr(ike_cfg), peer_cfg->get_my_id(peer_cfg),
286 ike_cfg->get_other_addr(ike_cfg), peer_cfg->get_other_id(peer_cfg));
287 fprintf(out, "%12s: %N authentication", peer_cfg->get_name(peer_cfg),
288 auth_class_names, get_auth_class(peer_cfg));
289 dpd = peer_cfg->get_dpd(peer_cfg);
290 if (dpd)
291 {
292 fprintf(out, ", dpddelay=%us", dpd);
293 }
294 fprintf(out, "\n");
295 /* TODO: list CAs and groups */
296 children = peer_cfg->create_child_cfg_enumerator(peer_cfg);
297 while (children->enumerate(children, &child_cfg))
298 {
299 linked_list_t *my_ts, *other_ts;
300
301 my_ts = child_cfg->get_traffic_selectors(child_cfg, TRUE, NULL, NULL);
302 other_ts = child_cfg->get_traffic_selectors(child_cfg, FALSE, NULL, NULL);
303 fprintf(out, "%12s: %#R=== %#R", child_cfg->get_name(child_cfg),
304 my_ts, other_ts);
305 my_ts->destroy_offset(my_ts, offsetof(traffic_selector_t, destroy));
306 other_ts->destroy_offset(other_ts, offsetof(traffic_selector_t, destroy));
307
308 if (dpd)
309 {
310 fprintf(out, ", dpdaction=%N", action_names,
311 child_cfg->get_dpd_action(child_cfg));
312 }
313 fprintf(out, "\n");
314 }
315 children->destroy(children);
316 }
317 enumerator->destroy(enumerator);
318 }
319
320 fprintf(out, "Security Associations:\n");
321 enumerator = charon->controller->create_ike_sa_enumerator(charon->controller);
322 while (enumerator->enumerate(enumerator, &ike_sa))
323 {
324 bool ike_printed = FALSE;
325 child_sa_t *child_sa;
326 iterator_t *children = ike_sa->create_child_sa_iterator(ike_sa);
327
328 if (name == NULL || streq(name, ike_sa->get_name(ike_sa)))
329 {
330 log_ike_sa(out, ike_sa, all);
331 found = TRUE;
332 ike_printed = TRUE;
333 }
334
335 while (children->iterate(children, (void**)&child_sa))
336 {
337 if (name == NULL || streq(name, child_sa->get_name(child_sa)))
338 {
339 if (!ike_printed)
340 {
341 log_ike_sa(out, ike_sa, all);
342 found = TRUE;
343 ike_printed = TRUE;
344 }
345 log_child_sa(out, child_sa, all);
346 }
347 }
348 children->destroy(children);
349 }
350 enumerator->destroy(enumerator);
351
352 if (!found)
353 {
354 if (name)
355 {
356 fprintf(out, " no match\n");
357 }
358 else
359 {
360 fprintf(out, " none\n");
361 }
362 }
363 }
364
365 /**
366 * create a unique certificate list without duplicates
367 * certicates having the same issuer are grouped together.
368 */
369 static linked_list_t* create_unique_cert_list(certificate_type_t type)
370 {
371 linked_list_t *list = linked_list_create();
372 enumerator_t *enumerator = charon->credentials->create_cert_enumerator(
373 charon->credentials, type, KEY_ANY,
374 NULL, FALSE);
375 certificate_t *cert;
376
377 while (enumerator->enumerate(enumerator, (void**)&cert))
378 {
379 iterator_t *iterator = list->create_iterator(list, TRUE);
380 identification_t *issuer = cert->get_issuer(cert);
381 bool previous_same, same = FALSE, last = TRUE;
382 certificate_t *list_cert;
383
384 while (iterator->iterate(iterator, (void**)&list_cert))
385 {
386 /* exit if we have a duplicate? */
387 if (list_cert->equals(list_cert, cert))
388 {
389 last = FALSE;
390 break;
391 }
392 /* group certificates with same issuer */
393 previous_same = same;
394 same = list_cert->has_issuer(list_cert, issuer);
395 if (previous_same && !same)
396 {
397 iterator->insert_before(iterator, (void *)cert->get_ref(cert));
398 last = FALSE;
399 break;
400 }
401 }
402 iterator->destroy(iterator);
403
404 if (last)
405 {
406 list->insert_last(list, (void *)cert->get_ref(cert));
407 }
408 }
409 enumerator->destroy(enumerator);
410 return list;
411 }
412
413 /**
414 * list all X.509 certificates matching the flags
415 */
416 static void stroke_list_certs(linked_list_t *list, char *label,
417 x509_flag_t flags, bool utc, FILE *out)
418 {
419 bool first = TRUE;
420 time_t now = time(NULL);
421 enumerator_t *enumerator = list->create_enumerator(list);
422 certificate_t *cert;
423
424 while (enumerator->enumerate(enumerator, (void**)&cert))
425 {
426 x509_t *x509 = (x509_t*)cert;
427 x509_flag_t x509_flags = x509->get_flags(x509);
428
429 /* list only if flag is set, or flags == 0 (ignoring self-signed) */
430 if ((x509_flags & flags) || (flags == (x509_flags & ~X509_SELF_SIGNED)))
431 {
432 enumerator_t *enumerator;
433 identification_t *altName;
434 bool first_altName = TRUE;
435 chunk_t serial = x509->get_serial(x509);
436 identification_t *authkey = x509->get_authKeyIdentifier(x509);
437 time_t notBefore, notAfter;
438 public_key_t *public = cert->get_public_key(cert);
439
440 if (first)
441 {
442 fprintf(out, "\n");
443 fprintf(out, "List of %s:\n", label);
444 first = FALSE;
445 }
446 fprintf(out, "\n");
447
448 /* list subjectAltNames */
449 enumerator = x509->create_subjectAltName_enumerator(x509);
450 while (enumerator->enumerate(enumerator, (void**)&altName))
451 {
452 if (first_altName)
453 {
454 fprintf(out, " altNames: ");
455 first_altName = FALSE;
456 }
457 else
458 {
459 fprintf(out, ", ");
460 }
461 fprintf(out, "%D", altName);
462 }
463 if (!first_altName)
464 {
465 fprintf(out, "\n");
466 }
467 enumerator->destroy(enumerator);
468
469 fprintf(out, " subject: \"%D\"\n", cert->get_subject(cert));
470 fprintf(out, " issuer: \"%D\"\n", cert->get_issuer(cert));
471 fprintf(out, " serial: %#B\n", &serial);
472
473 /* list validity */
474 cert->get_validity(cert, &now, &notBefore, &notAfter);
475 fprintf(out, " validity: not before %#T, ", &notBefore, utc);
476 if (now < notBefore)
477 {
478 fprintf(out, "not valid yet (valid in %#V)\n", &now, &notBefore);
479 }
480 else
481 {
482 fprintf(out, "ok\n");
483 }
484 fprintf(out, " not after %#T, ", &notAfter, utc);
485 if (now > notAfter)
486 {
487 fprintf(out, "expired (%#V ago)\n", &now, &notAfter);
488 }
489 else
490 {
491 fprintf(out, "ok");
492 if (now > notAfter - CERT_WARNING_INTERVAL * 60 * 60 * 24)
493 {
494 fprintf(out, " (expires in %#V)", &now, &notAfter);
495 }
496 fprintf(out, " \n");
497 }
498
499 /* list public key information */
500 if (public)
501 {
502 private_key_t *private = NULL;
503 identification_t *id, *keyid;
504
505 id = public->get_id(public, ID_PUBKEY_SHA1);
506 keyid = public->get_id(public, ID_PUBKEY_INFO_SHA1);
507
508 private = charon->credentials->get_private(
509 charon->credentials,
510 public->get_type(public), keyid, NULL);
511 fprintf(out, " pubkey: %N %d bits%s\n",
512 key_type_names, public->get_type(public),
513 public->get_keysize(public) * 8,
514 private ? ", has private key" : "");
515 fprintf(out, " keyid: %D\n", keyid);
516 fprintf(out, " subjkey: %D\n", id);
517 DESTROY_IF(private);
518 public->destroy(public);
519 }
520
521 /* list optional authorityKeyIdentifier */
522 if (authkey)
523 {
524 fprintf(out, " authkey: %D\n", authkey);
525 }
526 }
527 }
528 enumerator->destroy(enumerator);
529 }
530
531 /**
532 * list all X.509 attribute certificates
533 */
534 static void stroke_list_acerts(linked_list_t *list, bool utc, FILE *out)
535 {
536 bool first = TRUE;
537 time_t thisUpdate, nextUpdate, now = time(NULL);
538 enumerator_t *enumerator = list->create_enumerator(list);
539 certificate_t *cert;
540
541 while (enumerator->enumerate(enumerator, (void**)&cert))
542 {
543 ac_t *ac = (ac_t*)cert;
544 chunk_t serial = ac->get_serial(ac);
545 chunk_t holderSerial = ac->get_holderSerial(ac);
546 identification_t *holderIssuer = ac->get_holderIssuer(ac);
547 identification_t *authkey = ac->get_authKeyIdentifier(ac);
548 identification_t *entityName = cert->get_subject(cert);
549
550 if (first)
551 {
552 fprintf(out, "\n");
553 fprintf(out, "List of X.509 Attribute Certificates:\n");
554 first = FALSE;
555 }
556 fprintf(out, "\n");
557
558 if (entityName)
559 {
560 fprintf(out, " holder: \"%D\"\n", entityName);
561 }
562 if (holderIssuer)
563 {
564 fprintf(out, " hissuer: \"%D\"\n", holderIssuer);
565 }
566 if (holderSerial.ptr)
567 {
568 fprintf(out, " hserial: %#B\n", &holderSerial);
569 }
570 fprintf(out, " issuer: \"%D\"\n", cert->get_issuer(cert));
571 fprintf(out, " serial: %#B\n", &serial);
572
573 /* list validity */
574 cert->get_validity(cert, &now, &thisUpdate, &nextUpdate);
575 fprintf(out, " updates: this %#T\n", &thisUpdate, utc);
576 fprintf(out, " next %#T, ", &nextUpdate, utc);
577 if (now > nextUpdate)
578 {
579 fprintf(out, "expired (%#V ago)\n", &now, &nextUpdate);
580 }
581 else
582 {
583 fprintf(out, "ok");
584 if (now > nextUpdate - AC_WARNING_INTERVAL * 60 * 60 * 24)
585 {
586 fprintf(out, " (expires in %#V)", &now, &nextUpdate);
587 }
588 fprintf(out, " \n");
589 }
590
591 /* list optional authorityKeyIdentifier */
592 if (authkey)
593 {
594 fprintf(out, " authkey: %D\n", authkey);
595 }
596 }
597 enumerator->destroy(enumerator);
598 }
599
600 /**
601 * list all X.509 CRLs
602 */
603 static void stroke_list_crls(linked_list_t *list, bool utc, FILE *out)
604 {
605 bool first = TRUE;
606 time_t thisUpdate, nextUpdate, now = time(NULL);
607 enumerator_t *enumerator = list->create_enumerator(list);
608 certificate_t *cert;
609
610 while (enumerator->enumerate(enumerator, (void**)&cert))
611 {
612 crl_t *crl = (crl_t*)cert;
613 chunk_t serial = crl->get_serial(crl);
614 identification_t *authkey = crl->get_authKeyIdentifier(crl);
615
616 if (first)
617 {
618 fprintf(out, "\n");
619 fprintf(out, "List of X.509 CRLs:\n");
620 first = FALSE;
621 }
622 fprintf(out, "\n");
623
624 fprintf(out, " issuer: \"%D\"\n", cert->get_issuer(cert));
625
626 /* list optional crlNumber */
627 if (serial.ptr)
628 {
629 fprintf(out, " serial: %#B\n", &serial);
630 }
631
632 /* count the number of revoked certificates */
633 {
634 int count = 0;
635 enumerator_t *enumerator = crl->create_enumerator(crl);
636
637 while (enumerator->enumerate(enumerator, NULL, NULL, NULL))
638 {
639 count++;
640 }
641 fprintf(out, " revoked: %d certificate%s\n", count,
642 (count == 1)? "" : "s");
643 enumerator->destroy(enumerator);
644 }
645
646 /* list validity */
647 cert->get_validity(cert, &now, &thisUpdate, &nextUpdate);
648 fprintf(out, " updates: this %#T\n", &thisUpdate, utc);
649 fprintf(out, " next %#T, ", &nextUpdate, utc);
650 if (now > nextUpdate)
651 {
652 fprintf(out, "expired (%#V ago)\n", &now, &nextUpdate);
653 }
654 else
655 {
656 fprintf(out, "ok");
657 if (now > nextUpdate - CRL_WARNING_INTERVAL * 60 * 60 * 24)
658 {
659 fprintf(out, " (expires in %#V)", &now, &nextUpdate);
660 }
661 fprintf(out, " \n");
662 }
663
664 /* list optional authorityKeyIdentifier */
665 if (authkey)
666 {
667 fprintf(out, " authkey: %D\n", authkey);
668 }
669 }
670 enumerator->destroy(enumerator);
671 }
672
673 /**
674 * list all OCSP responses
675 */
676 static void stroke_list_ocsp(linked_list_t* list, bool utc, FILE *out)
677 {
678 bool first = TRUE;
679 enumerator_t *enumerator = list->create_enumerator(list);
680 certificate_t *cert;
681
682 while (enumerator->enumerate(enumerator, (void**)&cert))
683 {
684 if (first)
685 {
686 fprintf(out, "\n");
687 fprintf(out, "List of OCSP responses:\n");
688 fprintf(out, "\n");
689 first = FALSE;
690 }
691
692 fprintf(out, " signer: \"%D\"\n", cert->get_issuer(cert));
693 }
694 enumerator->destroy(enumerator);
695 }
696
697 /**
698 * Implementation of stroke_list_t.list.
699 */
700 static void list(private_stroke_list_t *this, stroke_msg_t *msg, FILE *out)
701 {
702 linked_list_t *cert_list = NULL;
703
704 if (msg->list.flags & (LIST_CERTS | LIST_CACERTS | LIST_OCSPCERTS | LIST_AACERTS))
705 {
706 cert_list = create_unique_cert_list(CERT_X509);
707 }
708 if (msg->list.flags & LIST_CERTS)
709 {
710 stroke_list_certs(cert_list, "X.509 End Entity Certificates",
711 0, msg->list.utc, out);
712 }
713 if (msg->list.flags & LIST_CACERTS)
714 {
715 stroke_list_certs(cert_list, "X.509 CA Certificates",
716 X509_CA, msg->list.utc, out);
717 }
718 if (msg->list.flags & LIST_OCSPCERTS)
719 {
720 stroke_list_certs(cert_list, "X.509 OCSP Signer Certificates",
721 X509_OCSP_SIGNER, msg->list.utc, out);
722 }
723 if (msg->list.flags & LIST_AACERTS)
724 {
725 stroke_list_certs(cert_list, "X.509 AA Certificates",
726 X509_AA, msg->list.utc, out);
727 }
728 if (msg->list.flags & LIST_ACERTS)
729 {
730 linked_list_t *ac_list = create_unique_cert_list(CERT_X509_AC);
731
732 stroke_list_acerts(ac_list, msg->list.utc, out);
733 ac_list->destroy_offset(ac_list, offsetof(certificate_t, destroy));
734 }
735 if (msg->list.flags & LIST_CRLS)
736 {
737 linked_list_t *crl_list = create_unique_cert_list(CERT_X509_CRL);
738
739 stroke_list_crls(crl_list, msg->list.utc, out);
740 crl_list->destroy_offset(crl_list, offsetof(certificate_t, destroy));
741 }
742 if (msg->list.flags & LIST_OCSP)
743 {
744 linked_list_t *ocsp_list = create_unique_cert_list(CERT_X509_OCSP_RESPONSE);
745
746 stroke_list_ocsp(ocsp_list, msg->list.utc, out);
747 ocsp_list->destroy_offset(ocsp_list, offsetof(certificate_t, destroy));
748 }
749 DESTROY_OFFSET_IF(cert_list, offsetof(certificate_t, destroy));
750 }
751
752 /**
753 * Implementation of stroke_list_t.destroy
754 */
755 static void destroy(private_stroke_list_t *this)
756 {
757 free(this);
758 }
759
760 /*
761 * see header file
762 */
763 stroke_list_t *stroke_list_create()
764 {
765 private_stroke_list_t *this = malloc_thing(private_stroke_list_t);
766
767 this->public.list = (void(*)(stroke_list_t*, stroke_msg_t *msg, FILE *out))list;
768 this->public.status = (void(*)(stroke_list_t*, stroke_msg_t *msg, FILE *out,bool))status;
769 this->public.destroy = (void(*)(stroke_list_t*))destroy;
770
771 this->uptime = time(NULL);
772
773 return &this->public;
774 }
775