~ubuntu-branches/ubuntu/trusty/syslog-ng/trusty-proposed

« back to all changes in this revision

Viewing changes to src/tlscontext.h

  • Committer: Bazaar Package Importer
  • Author(s): Laszlo Boszormenyi (GCS)
  • Date: 2010-03-14 12:57:49 UTC
  • mfrom: (1.3.1 upstream) (12.1.1 experimental)
  • Revision ID: james.westby@ubuntu.com-20100314125749-m3ats648sp2urg0f
Tags: 3.0.5-1
New upstream release, new maintainer.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright (c) 2002-2009 BalaBit IT Ltd, Budapest, Hungary
 
3
 *
 
4
 * This program is free software; you can redistribute it and/or modify it
 
5
 * under the terms of the GNU General Public License version 2 as published
 
6
 * by the Free Software Foundation.
 
7
 *
 
8
 * Note that this permission is granted for only version 2 of the GPL.
 
9
 *
 
10
 * As an additional exemption you are allowed to compile & link against the
 
11
 * OpenSSL libraries as published by the OpenSSL project. See the file
 
12
 * COPYING for details.
 
13
 *
 
14
 * This program is distributed in the hope that it will be useful,
 
15
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
16
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
17
 * GNU General Public License for more details.
 
18
 *
 
19
 * You should have received a copy of the GNU General Public License
 
20
 * along with this program; if not, write to the Free Software
 
21
 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 
22
 */
 
23
  
 
24
#ifndef TLSCONTEXT_H_INCLUDED
 
25
#define TLSCONTEXT_H_INCLUDED
 
26
 
 
27
#include "syslog-ng.h"
 
28
 
 
29
#if ENABLE_SSL
 
30
 
 
31
#include <openssl/ssl.h>
 
32
 
 
33
typedef enum 
 
34
{
 
35
  TM_CLIENT,
 
36
  TM_SERVER,
 
37
  TM_MAX
 
38
} TLSMode;
 
39
 
 
40
typedef enum
 
41
{
 
42
  TVM_NONE,
 
43
  TVM_TRUSTED=0x0001,
 
44
  TVM_UNTRUSTED=0x0002,
 
45
  TVM_OPTIONAL=0x0010,
 
46
  TVM_REQUIRED=0x0020,
 
47
} TLSVerifyMode;
 
48
 
 
49
typedef gint (*TLSSessionVerifyFunc)(gint ok, X509_STORE_CTX *ctx, gpointer user_data);
 
50
typedef struct _TLSContext TLSContext;
 
51
 
 
52
typedef struct _TLSSession
 
53
{
 
54
  SSL *ssl;
 
55
  TLSContext *ctx;
 
56
  TLSSessionVerifyFunc verify_func;
 
57
  gpointer verify_data;
 
58
  GDestroyNotify verify_data_destroy;
 
59
} TLSSession;
 
60
 
 
61
void tls_session_set_verify(TLSSession *self, TLSSessionVerifyFunc verify_func, gpointer verify_data, GDestroyNotify verify_destroy);
 
62
void tls_session_free(TLSSession *self);
 
63
 
 
64
struct _TLSContext
 
65
{
 
66
  TLSMode mode;
 
67
  TLSVerifyMode verify_mode;
 
68
  gchar *key_file;
 
69
  gchar *cert_file;
 
70
  gchar *ca_dir;
 
71
  gchar *crl_dir;
 
72
  SSL_CTX *ssl_ctx;
 
73
  GList *trusted_fingerpint_list;
 
74
  GList *trusted_dn_list;
 
75
};
 
76
 
 
77
 
 
78
TLSSession *tls_context_setup_session(TLSContext *self);
 
79
void tls_session_set_trusted_fingerprints(TLSContext *self, GList *fingerprints);
 
80
void tls_session_set_trusted_dn(TLSContext *self, GList *dns);
 
81
TLSContext *tls_context_new(TLSMode mode);
 
82
void tls_context_free(TLSContext *s);
 
83
 
 
84
TLSVerifyMode tls_lookup_verify_mode(const gchar *mode_str);
 
85
 
 
86
void tls_log_certificate_validation_progress(int ok, X509_STORE_CTX *ctx);
 
87
gboolean tls_verify_certificate_name(X509 *cert, const gchar *hostname);
 
88
 
 
89
#else
 
90
 
 
91
typedef struct _TLSContext TLSContext;
 
92
typedef struct _TLSSession TLSSession;
 
93
 
 
94
#define tls_context_new(m)
 
95
 
 
96
#endif
 
97
 
 
98
#endif