1 | /* |
2 | * tls.c |
3 | * |
4 | * Copyright (C) 2016 Aerospike, Inc. |
5 | * |
6 | * Portions may be licensed to Aerospike, Inc. under one or more contributor |
7 | * license agreements. |
8 | * |
9 | * This program is free software: you can redistribute it and/or modify it under |
10 | * the terms of the GNU Affero General Public License as published by the Free |
11 | * Software Foundation, either version 3 of the License, or (at your option) any |
12 | * later version. |
13 | * |
14 | * This program is distributed in the hope that it will be useful, but WITHOUT |
15 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
16 | * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more |
17 | * details. |
18 | * |
19 | * You should have received a copy of the GNU Affero General Public License |
20 | * along with this program. If not, see http://www.gnu.org/licenses/ |
21 | */ |
22 | #include <openssl/ssl.h> |
23 | |
24 | #include "fault.h" |
25 | #include "socket.h" |
26 | #include "tls.h" |
27 | |
28 | void |
29 | tls_check_init() |
30 | { |
31 | } |
32 | |
33 | void |
34 | tls_cleanup() |
35 | { |
36 | } |
37 | |
38 | void |
39 | tls_thread_cleanup() |
40 | { |
41 | } |
42 | |
43 | void |
44 | tls_socket_init(cf_socket *sock) |
45 | { |
46 | sock->ssl = NULL; |
47 | } |
48 | |
49 | void |
50 | tls_socket_term(cf_socket *sock) |
51 | { |
52 | if (sock->ssl) { |
53 | cf_crash(CF_TLS, "unexpected TLS state" ); |
54 | } |
55 | } |
56 | |
57 | int |
58 | tls_socket_shutdown(cf_socket *sock) |
59 | { |
60 | if (sock->ssl) { |
61 | cf_crash(CF_TLS, "unexpected TLS state" ); |
62 | } |
63 | return -1; |
64 | } |
65 | |
66 | void |
67 | tls_socket_close(cf_socket *sock) |
68 | { |
69 | if (sock->ssl) { |
70 | cf_crash(CF_TLS, "unexpected TLS state" ); |
71 | } |
72 | } |
73 | |
74 | char *tls_read_password(const char *path) |
75 | { |
76 | cf_crash(CF_TLS, "unexpected TLS state" ); |
77 | return NULL; |
78 | } |
79 | |
80 | cf_tls_info * |
81 | tls_config_server_context(cf_tls_spec *tspec, bool auth_client, uint32_t n_peer_names, char **peer_names) |
82 | { |
83 | cf_crash(CF_TLS, "unexpected TLS state" ); |
84 | return NULL; |
85 | } |
86 | |
87 | cf_tls_info * |
88 | tls_config_intra_context(cf_tls_spec *tspec, const char *which) |
89 | { |
90 | cf_crash(CF_TLS, "unexpected TLS state" ); |
91 | return NULL; |
92 | } |
93 | |
94 | void |
95 | tls_socket_prepare_server(cf_tls_info *info, cf_socket *sock) |
96 | { |
97 | cf_crash(CF_TLS, "unexpected TLS state" ); |
98 | } |
99 | |
100 | void |
101 | tls_socket_prepare_client(cf_tls_info *info, cf_socket *sock) |
102 | { |
103 | cf_crash(CF_TLS, "unexpected TLS state" ); |
104 | } |
105 | |
106 | void |
107 | tls_socket_must_not_have_data(cf_socket *sock, const char *caller) |
108 | { |
109 | if (sock->state == CF_SOCKET_STATE_NON_TLS) { |
110 | return; |
111 | } |
112 | |
113 | cf_crash(CF_TLS, "unexpected TLS state" ); |
114 | } |
115 | |
116 | int |
117 | tls_socket_accept(cf_socket *sock) |
118 | { |
119 | cf_crash(CF_TLS, "unexpected TLS state" ); |
120 | return 1; |
121 | } |
122 | |
123 | int |
124 | tls_socket_connect(cf_socket *sock) |
125 | { |
126 | cf_crash(CF_TLS, "unexpected TLS state" ); |
127 | return 1; |
128 | } |
129 | |
130 | int |
131 | tls_socket_accept_block(cf_socket *sock) |
132 | { |
133 | cf_crash(CF_TLS, "unexpected TLS state" ); |
134 | return 1; |
135 | } |
136 | |
137 | int |
138 | tls_socket_connect_block(cf_socket *sock) |
139 | { |
140 | cf_crash(CF_TLS, "unexpected TLS state" ); |
141 | return 1; |
142 | } |
143 | |
144 | int |
145 | tls_socket_recv(cf_socket *sock, void *buf, size_t sz, int32_t flags, |
146 | uint64_t deadline_msec) |
147 | { |
148 | cf_crash(CF_TLS, "unexpected TLS state" ); |
149 | return 1; |
150 | } |
151 | |
152 | int |
153 | tls_socket_send(cf_socket *sock, void const *buf, size_t sz, int32_t flags, |
154 | uint64_t deadline_msec) |
155 | { |
156 | cf_crash(CF_TLS, "unexpected TLS state" ); |
157 | return 1; |
158 | } |
159 | |
160 | int |
161 | tls_socket_pending(cf_socket *sock) |
162 | { |
163 | return 0; |
164 | } |
165 | |
166 | |