893f07a2c651df85740dfae42fc0187a03bb9593
[claws.git] / src / common / ssl_certificate.h
1 /*
2  * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
3  * Copyright (C) 1999-2006 Hiroyuki Yamamoto
4  * This file Copyright (C) 2002-2005 Colin Leroy <colin@colino.net>
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19  */
20
21 #ifndef __SSL_CERTIFICATE_H__
22 #define __SSL_CERTIFICATE_H__
23
24 #ifdef HAVE_CONFIG_H
25 #  include "config.h"
26 #endif
27
28 #if USE_OPENSSL
29
30 #include <openssl/ssl.h>
31 #include <openssl/objects.h>
32 #include <glib.h>
33
34 #define SSLCERT_ASK_HOOKLIST "sslcert_ask"
35
36 typedef struct _SSLCertificate SSLCertificate;
37
38 struct _SSLCertificate
39 {
40         X509 *x509_cert;
41         gchar *host;
42         gushort port;
43 };
44
45 typedef struct _SSLCertHookData SSLCertHookData;
46
47 struct _SSLCertHookData
48 {
49         SSLCertificate *cert;
50         SSLCertificate *old_cert;
51         gboolean expired;
52         gboolean accept;
53 };
54
55 SSLCertificate *ssl_certificate_find (gchar *host, gushort port);
56 SSLCertificate *ssl_certificate_find_lookup (gchar *host, gushort port, gboolean lookup);
57 gboolean ssl_certificate_check (X509 *x509_cert, gchar *host, gushort port);
58 char* ssl_certificate_to_string(SSLCertificate *cert);
59 void ssl_certificate_destroy(SSLCertificate *cert);
60 void ssl_certificate_delete_from_disk(SSLCertificate *cert);
61 char * readable_fingerprint(unsigned char *src, int len);
62 char *ssl_certificate_check_signer (X509 *cert);
63 time_t asn1toTime(ASN1_TIME *asn1Time);
64
65 #endif /* USE_OPENSSL */
66 #endif /* SSL_CERTIFICATE_H */