summaryrefslogtreecommitdiff
path: root/src/libstrongswan/crypto/ca.c
blob: 07413e805e1ce73c2c6093c449f7ec9ffe065599 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
/**
 * @file ca.c
 * 
 * @brief Implementation of ca_info_t.
 * 
 */

/*
 * Copyright (C) 2007 Andreas Steffen
 * Hochschule fuer Technik Rapperswil
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License as published by the
 * Free Software Foundation; either version 2 of the License, or (at your
 * option) any later version.  See <http://www.fsf.org/copyleft/gpl.txt>.
 *
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
 * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 * for more details.
 */

#include <sys/stat.h>
#include <unistd.h>
#include <string.h>
#include <stdio.h>
#include <pthread.h>

#include "x509.h"
#include "crl.h"
#include "ca.h"
#include "ac.h"
#include "certinfo.h"
#include "ocsp.h"

#include <library.h>
#include <debug.h>
#include <utils/linked_list.h>
#include <utils/identification.h>
#include <utils/fetcher.h>

typedef struct private_ca_info_t private_ca_info_t;

/**
 * Private data of a ca_info_t object.
 */
struct private_ca_info_t {
	/**
	 * Public interface for this ca info record
	 */
	ca_info_t public;
	
	/**
	 * Name of the ca info record
	 */
	char *name;

	/**
	 * Time when ca info record was installed
	 */
	time_t installed;

	/**
	 * Distinguished Name of the CA
	 */
	x509_t *cacert;
	
	/**
	 * List of attribute certificates
	 */
	linked_list_t *attrcerts;

	/**
	 * List of crl URIs
	 */
	linked_list_t *crluris;

	/**
	 * List of ocsp URIs
	 */
	linked_list_t *ocspuris;

	/**
	 * CRL issued by this ca
	 */
	crl_t *crl;

	/**
	 * List of certificate info records
	 */
	linked_list_t *certinfos;

	/**
	 * mutex controls access to the elements:
	 * name, crluris, ocspuris, crl, and certinfos
	 */
	pthread_mutex_t mutex;
};

/**
 * static options set by ca_info_set_options()
 */
static strict_t strict_crl_policy = STRICT_NO;
static bool cache_crls = FALSE;
static u_int crl_check_interval = 0;

/**
 * Implements ca_info_t.equals
 */
static bool equals(const private_ca_info_t *this, const private_ca_info_t *that)
{
	return chunk_equals(this->cacert->get_keyid(this->cacert),
						that->cacert->get_keyid(that->cacert));
}

/**
 * Implements ca_info_t.equals_name_release_info
 */
static bool equals_name_release_info(private_ca_info_t *this, const char *name)
{
	bool found;

	pthread_mutex_lock(&(this->mutex));
	found = this->name != NULL && streq(this->name, name);

	if (found)
	{
		this->crluris->destroy_offset(this->crluris,
									  offsetof(identification_t, destroy));
		this->crluris = linked_list_create();

		this->ocspuris->destroy_offset(this->ocspuris,
									   offsetof(identification_t, destroy));
		this->ocspuris = linked_list_create();

		free(this->name);
		this->name = NULL;
	}

	pthread_mutex_unlock(&(this->mutex));
	return found;
}

/**
 * Implements ca_info_t.is_crl_issuer
 */
static bool is_cert_issuer(private_ca_info_t *this, const x509_t *cert)
{
	return cert->is_issuer(cert, this->cacert);
}

/**
 * Implements ca_info_t.is_crl_issuer
 */
static bool is_crl_issuer(private_ca_info_t *this, const crl_t *crl)
{
	return crl->is_issuer(crl, this->cacert);
}

/**
 * Implements ca_info_t.is_ca
 */
static bool is_ca(private_ca_info_t *this)
{
	return this->cacert->is_ca(this->cacert);
}

/**
 * Implements ca_info_t.is_strict
 */
static bool is_strict(private_ca_info_t *this)
{
	bool strict = strict_crl_policy != STRICT_NO;

	if (strict_crl_policy == STRICT_IFURI)
	{
		pthread_mutex_lock(&(this->mutex));
		strict = this->crluris->get_count(this->crluris)   > 0 ||
				 this->ocspuris->get_count(this->ocspuris) > 0;
		pthread_mutex_unlock(&(this->mutex));
	}
	return strict;
}

/**
 * Implements ca_info_t.has_crl
 */
static bool has_crl(private_ca_info_t *this)
{
	bool found;

	pthread_mutex_lock(&(this->mutex));
	found = this->crl != NULL;
	pthread_mutex_unlock(&(this->mutex));

	return found;
}

/**
 * Implements ca_info_t.has_certinfos
 */
static bool has_certinfos(private_ca_info_t *this)
{
	bool found;

	pthread_mutex_lock(&(this->mutex));
	found = this->certinfos->get_count(this->certinfos) > 0;
	pthread_mutex_unlock(&(this->mutex));

	return found;
}

/**
 * Implements ca_info_t.add_crl
 */
static void add_crl(private_ca_info_t *this, crl_t *crl)
{
	pthread_mutex_lock(&(this->mutex));

	if (this->crl)
	{
		if (crl->is_newer(crl, this->crl))
		{
			this->crl->destroy(this->crl);
			this->crl = crl;
			DBG1("  this crl is newer - existing crl replaced");
		}
		else
		{
			crl->destroy(crl);
			DBG1("  this crl is not newer - existing crl retained");
		}
	}
	else
	{
		this->crl = crl;
		DBG2("  crl added");
	}

	pthread_mutex_unlock(&(this->mutex));
}

/**
 * Implements ca_info_t.list_crl
 */
static void list_crl(private_ca_info_t *this, FILE *out, bool utc)
{
	pthread_mutex_lock(&this->mutex);
	this->crl->list(this->crl, out, utc);
	pthread_mutex_unlock(&this->mutex);
}

/**
 * Implements ca_info_t.list_certinfos
 */
static void list_certinfos(private_ca_info_t *this, FILE *out, bool utc)
{
	iterator_t *iterator;
	certinfo_t *certinfo;
	chunk_t authkey;

	pthread_mutex_lock(&this->mutex);

	authkey = this->cacert->get_subjectKeyID(this->cacert);
	fprintf(out,"    authname:  '%D'\n", this->cacert->get_subject(this->cacert));
	fprintf(out,"    authkey:    %#B\n", &authkey);

	iterator = this->certinfos->create_iterator(this->certinfos, TRUE);
	while (iterator->iterate(iterator, (void**)&certinfo))
	{
		time_t nextUpdate, thisUpdate, now;
		chunk_t serial;
		
		now = time(NULL);
		nextUpdate = certinfo->get_nextUpdate(certinfo);
		thisUpdate = certinfo->get_thisUpdate(certinfo);
		serial = certinfo->get_serialNumber(certinfo);
		
		fprintf(out, "%#T, until %#T, ", &thisUpdate, utc, &nextUpdate, utc);
		if (now > nextUpdate)
		{
			fprintf(out, "expired (%V ago)\n", &now, &nextUpdate);
		}
		else
		{
			fprintf(out, "ok (expires in %V)\n", &now, &nextUpdate);
		}
		fprintf(out, "    serial:     %#B, %N\n", &serial,
				cert_status_names, certinfo->get_status(certinfo));
	}
	iterator->destroy(iterator);

	pthread_mutex_unlock(&this->mutex);
}

/**
 * Find an exact copy of an identification in a linked list
 */
static identification_t* find_identification(linked_list_t *list, identification_t *id)
{
	identification_t *found_id = NULL, *current_id;

	iterator_t *iterator = list->create_iterator(list, TRUE);

	while (iterator->iterate(iterator, (void**)&current_id))
	{
		if (id->equals(id, current_id))
		{
			found_id = current_id;
			break;
		}
	}
	iterator->destroy(iterator);

	return found_id;
}

/**
 * Add a unique identification to a linked list
 */
static identification_t *add_identification(linked_list_t *list, identification_t *id)
{
	identification_t *found_id = find_identification(list, id);

	if (found_id)
	{
		id->destroy(id);
		return found_id;
	}
	else
	{
		list->insert_last(list, (void*)id);
		return id;
	}
}

/**
 * Implements ca_info_t.add_crluri
 */
static void add_crluri(private_ca_info_t *this, chunk_t uri)
{
	if (uri.len < 6 ||
	   (strncasecmp(uri.ptr, "http", 4) != 0  &&
		strncasecmp(uri.ptr, "ldap", 4) != 0  &&
		strncasecmp(uri.ptr, "file", 4) != 0  &&
		strncasecmp(uri.ptr, "ftp",  3) != 0))
	{
		DBG1("  invalid crl uri '%#B'", uri);
		return;
	}
	else
	{
		identification_t *crluri = identification_create_from_encoding(ID_DER_ASN1_GN_URI, uri);

		pthread_mutex_lock(&(this->mutex));
		add_identification(this->crluris, crluri);
		pthread_mutex_unlock(&(this->mutex));
	}
}

/**
 * Implements ca_info_t.add_ocspuri
 */
static void add_ocspuri(private_ca_info_t *this, chunk_t uri)
{
	if (uri.len < 7 || strncasecmp(uri.ptr, "http", 4) != 0)
	{
		DBG1("  invalid ocsp uri '%.*s'", uri.len, uri.ptr);
		return;
	}
	else
	{
		identification_t *ocspuri = identification_create_from_encoding(ID_DER_ASN1_GN_URI, uri);

		pthread_mutex_lock(&(this->mutex));
		add_identification(this->ocspuris, ocspuri);
		pthread_mutex_unlock(&(this->mutex));
	}
}

/**
 * Implements ca_info_t.add_info.
 */
void add_info (private_ca_info_t *this, const private_ca_info_t *that)
{
	pthread_mutex_lock(&(this->mutex));

	if (this->name == NULL && that->name != NULL)
	{
		this->name = strdup(that->name);
	}

	pthread_mutex_unlock(&(this->mutex));

	{
		identification_t *uri;

		iterator_t *iterator = that->crluris->create_iterator(that->crluris, TRUE);

		while (iterator->iterate(iterator, (void**)&uri))
		{
			add_crluri(this, uri->get_encoding(uri));
		}
		iterator->destroy(iterator);
	}

	{
		identification_t *uri;

		iterator_t *iterator = that->ocspuris->create_iterator(that->ocspuris, TRUE);

		while (iterator->iterate(iterator, (void**)&uri))
		{
			add_ocspuri(this, uri->get_encoding(uri));
		}
		iterator->destroy(iterator);
	}
}

/**
 *  Implements ca_info_t.get_certificate.
 */
static x509_t* get_certificate(private_ca_info_t* this)
{
	return this->cacert;
}

/**
 * caches a crl by saving it to a given crl directory
 */
void cache_crl(private_ca_info_t* this, const char *crl_dir, crl_t *crl)
{
	char buffer[BUF_LEN];
	char *path;
	char *pos = buffer;
	int len = BUF_LEN;
	int n;

	chunk_t authKeyID = this->cacert->get_subjectKeyID(this->cacert);
	chunk_t uri;

	uri.ptr = buffer;
	uri.len = 7 + strlen(crl_dir) + 1 + 2*authKeyID.len + 4;

	if (uri.len >= BUF_LEN)	
	{
		DBG1("file uri exceeds buffer length of %d bytes - crl not saved", BUF_LEN);
		return;
	}

	/* print the file uri prefix */
	n = snprintf(pos, len, "file://");
	pos += n;  len -= n;

	/* remember the start of the path string */
	path = pos;

	/* print the default crl directory path */
	n = snprintf(pos, len, "%s/", crl_dir);
	pos += n;  len -= n;

	/* create and print a unique crl filename derived from the authKeyID */
	while (authKeyID.len-- > 0)
	{
		n = snprintf(pos, len, "%02x", *authKeyID.ptr++);
		pos += n; len -= n;
	}

	/* add the file suffix */
	n = snprintf(pos, len, ".crl");

	if (crl->write_to_file(crl, path, 0022, TRUE))
	{
		identification_t *crluri = identification_create_from_encoding(ID_DER_ASN1_GN_URI, uri);

		add_identification(this->crluris, crluri);
	}
}

/**
 *  Implements ca_info_t.verify_by_crl.
 */
static cert_status_t verify_by_crl(private_ca_info_t* this, certinfo_t *certinfo,
								   const char *crl_dir)
{
	rsa_public_key_t *issuer_public_key = this->cacert->get_public_key(this->cacert);
	bool stale;

	pthread_mutex_lock(&(this->mutex));
	if (this->crl == NULL)
	{
		stale = TRUE;
		DBG1("no crl is locally available");
	}
	else
	{
		stale = !this->crl->is_valid(this->crl);
		DBG1("crl is %s", stale? "stale":"valid");
	}

	if (stale && crl_check_interval > 0)
	{
		iterator_t *iterator = this->crluris->create_iterator(this->crluris, TRUE);
		identification_t *uri;
		
		while (iterator->iterate(iterator, (void**)&uri))
		{
			fetcher_t *fetcher;
			char uri_string[BUF_LEN];
			chunk_t uri_chunk = uri->get_encoding(uri);
			chunk_t response_chunk;

			snprintf(uri_string, BUF_LEN, "%.*s", uri_chunk.len, uri_chunk.ptr);
			fetcher = fetcher_create(uri_string);
			
			response_chunk = fetcher->get(fetcher);
			fetcher->destroy(fetcher);
			if (response_chunk.ptr != NULL)
			{
				crl_t *crl = crl_create_from_chunk(response_chunk);
		
				if (crl == NULL)
				{
					free(response_chunk.ptr);
					continue;
				}
				if (!is_crl_issuer(this, crl))
				{
					DBG1("  fetched crl has wrong issuer");
					crl->destroy(crl);
					continue;
				}
				if (!crl->verify(crl, issuer_public_key))
				{
					DBG1("fetched crl signature is invalid");
					crl->destroy(crl);
					continue;
				}
				DBG2("fetched crl signature is valid");

				if (this->crl == NULL)
				{
					this->crl = crl;
				}
				else if (crl->is_newer(crl, this->crl))
				{
					this->crl->destroy(this->crl);
					this->crl = crl;
					DBG1("this crl is newer - existing crl replaced");
				}
				else
				{
					crl->destroy(crl);
					DBG1("this crl is not newer - existing crl retained");
					continue;
				}
				if (crl->is_valid(crl))
				{
					if (cache_crls && strncasecmp(uri_string, "file", 4) != 0)
					{
						cache_crl(this, crl_dir, crl);
					}
					/* we found a valid crl and therefore exit the fetch loop */
					break;
				}
				else
				{
					DBG1("fetched crl is stale");
				}
			}
		}
		iterator->destroy(iterator);
	}

	if (this->crl)
	{
		if (!this->crl->verify(this->crl, issuer_public_key))
		{
			DBG1("crl signature is invalid");
			goto ret;
		}
		DBG2("crl signature is valid");

		this->crl->get_status(this->crl, certinfo);
	}

ret:
	pthread_mutex_unlock(&(this->mutex));
	return certinfo->get_status(certinfo);
}

/**
  * Implements ca_info_t.verify_by_ocsp.
  */
static cert_status_t verify_by_ocsp(private_ca_info_t* this,
									certinfo_t *certinfo,
									credential_store_t *credentials)
{
	bool stale;
	iterator_t *iterator;
	certinfo_t *cached_certinfo = NULL;
	int comparison = 1;

	pthread_mutex_lock(&(this->mutex));

	/* do we support OCSP at all? */
	if (this->ocspuris->get_count(this->ocspuris) == 0)
	{
		goto ret;
	}

	iterator = this->certinfos->create_iterator(this->certinfos, TRUE);

	/* find the list insertion point in alphabetical order */
	while(iterator->iterate(iterator, (void**)&cached_certinfo))
	{
		comparison = certinfo->compare_serialNumber(certinfo, cached_certinfo);

		if (comparison <= 0)
		{
			break;
		}
	}

	/* do we have a valid certinfo_t for this serial number in our cache? */
	if (comparison == 0)
	{	
		stale = cached_certinfo->get_nextUpdate(cached_certinfo) < time(NULL);
		DBG1("ocsp status in cache is %s", stale ? "stale":"fresh");
	}
	else
	{
		stale = TRUE;
		DBG1("ocsp status is not in cache");
	}

	if (stale)
	{
		ocsp_t *ocsp;

		ocsp = ocsp_create(this->cacert, this->ocspuris);
		ocsp->fetch(ocsp, certinfo, credentials);
		if (certinfo->get_status(certinfo) != CERT_UNDEFINED)
		{
			if (comparison != 0)
			{
				cached_certinfo = certinfo_create(certinfo->get_serialNumber(certinfo));

				if (comparison > 0)
				{
					iterator->insert_after(iterator, (void *)cached_certinfo);
				}
				else
				{
					iterator->insert_before(iterator, (void *)cached_certinfo);
				}
			}
			cached_certinfo->update(cached_certinfo, certinfo);
		}
		ocsp->destroy(ocsp);
	}
	else
	{
		certinfo->update(certinfo, cached_certinfo);
	}

	iterator->destroy(iterator);

ret:
	pthread_mutex_unlock(&(this->mutex));
	return certinfo->get_status(certinfo);
}

/**
 * Implements ca_info_t.purge_ocsp
 */
static void purge_ocsp(private_ca_info_t *this)
{
	pthread_mutex_lock(&(this->mutex));

	this->certinfos->destroy_offset(this->certinfos,
									offsetof(certinfo_t, destroy));
	this->certinfos = linked_list_create();

	pthread_mutex_unlock(&(this->mutex));
}

/**
 * Implements ca_info_t.destroy
 */
static void destroy(private_ca_info_t *this)
{
	this->attrcerts->destroy_offset(this->attrcerts,
								  offsetof(x509ac_t, destroy));
	this->crluris->destroy_offset(this->crluris,
								  offsetof(identification_t, destroy));
	this->ocspuris->destroy_offset(this->ocspuris,
								   offsetof(identification_t, destroy));
	this->certinfos->destroy_offset(this->certinfos,
								   offsetof(certinfo_t, destroy));
	DESTROY_IF(this->crl);
	free(this->name);
	free(this);
}

/**
 * list the info of this CA
 */
static void list(private_ca_info_t* this, FILE* out, bool utc)
{
	chunk_t chunk;
	identification_t *uri;
	iterator_t *iterator;
	bool first;
	
	pthread_mutex_lock(&(this->mutex));
	fprintf(out, "%#T", &this->installed, utc);

	if (this->name)
	{
		fprintf(out, ", \"%s\"\n", this->name);
	}
	else
	{
		fprintf(out, "\n");
	}

	fprintf(out, "    authname:  '%D'\n", this->cacert->get_subject(this->cacert));
	chunk = this->cacert->get_subjectKeyID(this->cacert);
	fprintf(out, "    authkey:    %#B\n", &chunk);
	chunk = this->cacert->get_keyid(this->cacert);
	fprintf(out, "    keyid:      %#B\n", &chunk);
	
	first = TRUE;
	iterator = this->crluris->create_iterator(this->crluris, TRUE);
	while (iterator->iterate(iterator, (void**)&uri))
	{
		fprintf(out, "    %s   '%D'\n",  first ? "crluris:":"        ", uri);
		first = FALSE;
	}
	iterator->destroy(iterator);
	
	first = TRUE;
	iterator = this->ocspuris->create_iterator(this->ocspuris, TRUE);
	while (iterator->iterate(iterator, (void**)&uri))
	{
		fprintf(out, "    %s  '%D'\n", first ? "ocspuris:":"         ", uri);
		first = FALSE;
	}
	iterator->destroy(iterator);
	pthread_mutex_unlock(&(this->mutex));
}

/*
 * Described in header.
 */
void ca_info_set_options(strict_t strict, bool cache, u_int interval)
{
	strict_crl_policy = strict;
	cache_crls = cache;
	crl_check_interval = interval;
}

/*
 * Described in header.
 */
ca_info_t *ca_info_create(const char *name, x509_t *cacert)
{
	private_ca_info_t *this = malloc_thing(private_ca_info_t);
	
	/* initialize */
	this->installed = time(NULL);
	this->name = (name == NULL)? NULL:strdup(name);
	this->cacert = cacert;
	this->attrcerts = linked_list_create();
	this->crluris = linked_list_create();
	this->ocspuris = linked_list_create();
	this->certinfos = linked_list_create();
	this->crl = NULL;
	
	/* initialize the mutex */
	pthread_mutex_init(&(this->mutex), NULL);

	/* public functions */
	this->public.equals = (bool (*) (const ca_info_t*,const ca_info_t*))equals;
	this->public.equals_name_release_info = (bool (*) (ca_info_t*,const char*))equals_name_release_info;
	this->public.is_cert_issuer = (bool (*) (ca_info_t*,const x509_t*))is_cert_issuer;
	this->public.is_crl_issuer = (bool (*) (ca_info_t*,const crl_t*))is_crl_issuer;
	this->public.is_ca = (bool (*) (ca_info_t*))is_ca;
	this->public.is_strict = (bool (*) (ca_info_t*))is_strict;
	this->public.add_info = (void (*) (ca_info_t*,const ca_info_t*))add_info;
	this->public.add_crl = (void (*) (ca_info_t*,crl_t*))add_crl;
	this->public.has_crl = (bool (*) (ca_info_t*))has_crl;
	this->public.has_certinfos = (bool (*) (ca_info_t*))has_certinfos;
	this->public.list = (void (*) (ca_info_t*,FILE*,bool))list;
	this->public.list_crl = (void (*) (ca_info_t*,FILE*,bool))list_crl;
	this->public.list_certinfos = (void (*) (ca_info_t*,FILE*,bool))list_certinfos;
	this->public.add_crluri = (void (*) (ca_info_t*,chunk_t))add_crluri;
	this->public.add_ocspuri = (void (*) (ca_info_t*,chunk_t))add_ocspuri;
	this->public.get_certificate = (x509_t* (*) (ca_info_t*))get_certificate;
	this->public.verify_by_crl = (cert_status_t (*) (ca_info_t*,certinfo_t*, const char*))verify_by_crl;
	this->public.verify_by_ocsp = (cert_status_t (*) (ca_info_t*,certinfo_t*,credential_store_t*))verify_by_ocsp;
	this->public.purge_ocsp = (void (*) (ca_info_t*))purge_ocsp;
	this->public.destroy = (void (*) (ca_info_t*))destroy;

	return &this->public;
}