aboutsummaryrefslogtreecommitdiffstats
path: root/src/libstrongswan/credentials/certificates/certificate_printer.h
blob: 7953eb060b25c17365f8cf5fc00c8442cddf6e3d (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
/*
 * Copyright (C) 2015 Andreas Steffen
 * HSR 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.
 */

/**
 * @defgroup certificate_printer certificate_printer
 * @{ @ingroup certificates
 */

#ifndef CERTIFICATE_PRINTER_H_
#define CERTIFICATE_PRINTER_H_

typedef struct certificate_printer_t certificate_printer_t;

#include "credentials/certificates/certificate.h"
#include "credentials/certificates/x509.h"

#include <stdio.h>

/**
 * An object for printing certificate information.
 */
struct certificate_printer_t {

	/**
	 * Print a certificate.
	 *
	 * @param cert			certificate to be printed
	 * @param has_privkey	indicates that certificate has a matching private key
	 */
	void (*print)(certificate_printer_t *this, certificate_t *cert,
				  bool has_privkey);

	/**
	 * Print a caption if the certificate type changed.
	 *
	 * @param type		certificate type
	 * @param flag		X.509 certificate flag
	 */
	void (*print_caption)(certificate_printer_t *this, certificate_type_t type,
						  x509_flag_t flag);

	/**
	 * Destroy the certificate_printer object.
	 */
	void (*destroy)(certificate_printer_t *this);
};

/**
 * Create a certificate_printer object
 *
 * @param f				file where print output is directed to (usually stdout)
 * @param detailed		print more detailed certificate information
 * @param utc			print time inforamtion in UTC
 */
certificate_printer_t* certificate_printer_create(FILE *f, bool detailed,
												  bool utc);

#endif /** CERTIFICATE_PRINTER_H_ @}*/