]> git.proxmox.com Git - mirror_ovs.git/blob - lib/stream-ssl.h
6bea577d32eb69126dc3aa21f21ab8bf9c511c55
[mirror_ovs.git] / lib / stream-ssl.h
1 /*
2 * Copyright (c) 2008, 2009, 2010 Nicira Networks.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at:
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16 #ifndef STREAM_SSL_H
17 #define STREAM_SSL_H 1
18
19 #include <stdbool.h>
20
21 #ifdef HAVE_OPENSSL
22 bool stream_ssl_is_configured(void);
23
24 void stream_ssl_set_private_key_file(const char *file_name);
25 void stream_ssl_set_certificate_file(const char *file_name);
26 void stream_ssl_set_ca_cert_file(const char *file_name, bool bootstrap);
27
28 void stream_ssl_set_key_and_cert(const char *private_key_file,
29 const char *certificate_file);
30
31
32 void stream_ssl_set_peer_ca_cert_file(const char *file_name);
33
34 /* Define the long options for SSL support.
35 *
36 * Note that the definition includes a final comma, and therefore a comma
37 * must not be supplied when using the definition. This is done so that
38 * compilation succeeds whether or not HAVE_OPENSSL is defined. */
39 #define STREAM_SSL_LONG_OPTIONS \
40 {"private-key", required_argument, 0, 'p'}, \
41 {"certificate", required_argument, 0, 'c'}, \
42 {"ca-cert", required_argument, 0, 'C'},
43
44 #define STREAM_SSL_OPTION_HANDLERS \
45 case 'p': \
46 stream_ssl_set_private_key_file(optarg); \
47 break; \
48 \
49 case 'c': \
50 stream_ssl_set_certificate_file(optarg); \
51 break; \
52 \
53 case 'C': \
54 stream_ssl_set_ca_cert_file(optarg, false); \
55 break;
56 #else /* !HAVE_OPENSSL */
57 static inline bool stream_ssl_is_configured(void)
58 {
59 return false;
60 }
61 #define STREAM_SSL_LONG_OPTIONS
62 #define STREAM_SSL_OPTION_HANDLERS
63 #endif /* !HAVE_OPENSSL */
64
65 #endif /* stream-ssl.h */