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