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