root/src/eventer/eventer_SSL_fd_opset.h

Revision 853067a71a061cf7ab27ee767ecdea65d9ddc9cf, 3.8 kB (checked in by Theo Schlossnagle <jesus@omniti.com>, 9 years ago)

quick fix for #212

  • Property mode set to 100644
Line 
1 /*
2  * Copyright (c) 2007, OmniTI Computer Consulting, Inc.
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are
7  * met:
8  *
9  *     * Redistributions of source code must retain the above copyright
10  *       notice, this list of conditions and the following disclaimer.
11  *     * Redistributions in binary form must reproduce the above
12  *       copyright notice, this list of conditions and the following
13  *       disclaimer in the documentation and/or other materials provided
14  *       with the distribution.
15  *     * Neither the name OmniTI Computer Consulting, Inc. nor the names
16  *       of its contributors may be used to endorse or promote products
17  *       derived from this software without specific prior written
18  *       permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  */
32
33 #ifndef _EVENTER_EVENTER_SSL_FD_OPSET_H
34 #define _EVENTER_EVENTER_SSL_FD_OPSET_H
35
36 #include "noit_defines.h"
37 #include "eventer/eventer.h"
38
39 #include <openssl/ssl.h>
40
41 enum {
42   SSL_OP_READ,
43   SSL_OP_WRITE,
44   SSL_OP_CONNECT,
45   SSL_OP_ACCEPT
46 };
47
48 typedef enum {
49   SSL_SERVER,
50   SSL_CLIENT
51 } eventer_ssl_orientation_t;
52
53 extern eventer_fd_opset_t eventer_SSL_fd_opset;
54
55 struct eventer_ssl_ctx_t;
56 typedef struct eventer_ssl_ctx_t eventer_ssl_ctx_t;
57 typedef int (*eventer_ssl_verify_func_t)(eventer_ssl_ctx_t *,
58                                          int, X509_STORE_CTX *, void *);
59
60 /* Only the scheduler calls this */
61 void eventer_ssl_init();
62
63 /* Helper functions */
64 API_EXPORT(eventer_ssl_ctx_t *)
65   eventer_ssl_ctx_new(eventer_ssl_orientation_t type,
66                       const char *certificate, const char *key,
67                       const char *ca, const char *ciphers);
68 API_EXPORT(void)
69   eventer_ssl_ctx_free(eventer_ssl_ctx_t *ctx);
70
71 API_EXPORT(eventer_ssl_ctx_t *)
72   eventer_get_eventer_ssl_ctx(const eventer_t e);
73
74 API_EXPORT(void)
75   eventer_set_eventer_ssl_ctx(eventer_t e, eventer_ssl_ctx_t *ctx);
76
77 /* This makes it more obvious how to turn SSL on */
78 #define EVENTER_ATTACH_SSL(e,ctx) eventer_set_eventer_ssl_ctx(e,ctx)
79
80 API_EXPORT(void)
81   eventer_ssl_ctx_set_verify(eventer_ssl_ctx_t *ctx,
82                              eventer_ssl_verify_func_t f, void *c);
83
84 /* These happen _after_ a socket accept and thus require their
85  * strings being pulled from the outside.
86  */
87 API_EXPORT(int) eventer_SSL_renegotiate(eventer_t e);
88 API_EXPORT(int) eventer_SSL_accept(eventer_t e, int *mask);
89 API_EXPORT(int) eventer_SSL_connect(eventer_t e, int *mask);
90
91 API_EXPORT(int)
92   eventer_ssl_verify_cert(eventer_ssl_ctx_t *ctx, int ok,
93                           X509_STORE_CTX *x509ctx, void *closure);
94
95 /* These are all helper functions to expose information
96  * gleaned in the cert verfication process.
97  */
98 #define GET_SET_X509_NAME_PROTO(type) \
99 API_EXPORT(const char *) \
100   eventer_ssl_get_peer_##type(eventer_ssl_ctx_t *ctx)
101 GET_SET_X509_NAME_PROTO(issuer);
102 GET_SET_X509_NAME_PROTO(subject);
103 GET_SET_X509_NAME_PROTO(error);
104 API_EXPORT(time_t)
105   eventer_ssl_get_peer_start_time(eventer_ssl_ctx_t *ctx);
106 API_EXPORT(time_t)
107   eventer_ssl_get_peer_end_time(eventer_ssl_ctx_t *ctx);
108
109 #endif
110
Note: See TracBrowser for help on using the browser.