Skip to content

Commit e18a1d0

Browse files
erahnblp
authored andcommitted
Add support for specifying SSL connection parameters to ovsdb
Signed-off-by: Ethan Rahn <erahn@arista.com> Signed-off-by: Ben Pfaff <blp@ovn.org>
1 parent 60230e0 commit e18a1d0

26 files changed

Lines changed: 243 additions & 20 deletions

AUTHORS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ Eohyung Lee liquidnuker@gmail.com
8585
Eric Garver e@erig.me
8686
Eric Sesterhenn eric.sesterhenn@lsexperts.de
8787
Ethan J. Jackson ejj@eecs.berkeley.edu
88+
Ethan Rahn erahn@arista.com
8889
Eziz Durdyyev ezizdurdy@gmail.com
8990
Flavio Fernandes flavio@flaviof.com
9091
Flavio Leitner fbl@redhat.com

NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
Post-v2.6.0
22
---------------------
3+
- Utilities and daemons that support SSL now allow protocols and
4+
ciphers to be configured with --ssl-protocols and --ssl-ciphers.
35
- OVN:
46
* QoS is now implemented via egress shaping rather than ingress policing.
57
* DSCP marking is now supported, via the new northbound QoS table.

lib/automake.mk

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -461,6 +461,8 @@ MAN_FRAGMENTS += \
461461
lib/ssl-peer-ca-cert-syn.man \
462462
lib/ssl.man \
463463
lib/ssl-syn.man \
464+
lib/ssl-connect.man \
465+
lib/ssl-connect-syn.man \
464466
lib/table.man \
465467
lib/unixctl.man \
466468
lib/unixctl-syn.man \

lib/ssl-connect-syn.man

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
.IP "SSL connection options:"
2+
[\fB\-\-ssl\-protocols=\fIprotocols\fR]
3+
.br
4+
[\fB\-\-ssl\-ciphers=\fIciphers\fR]
5+
.br

lib/ssl-connect.man

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
.IP "\fB\-\-ssl\-protocols=\fIprotocols\fR"
2+
Specifies, in a comma- or space-delimited list, the SSL protocols
3+
\fB\*(PN\fR will enable for SSL connections. Supported
4+
\fIprotocols\fR include \fBTLSv1\fR, \fBTLSv1.1\fR, and \fBTLSv1.2\fR.
5+
Regardless of order, the highest protocol supported by both sides will
6+
be chosen when making the connection. The default when this option is
7+
omitted is \fBTLSv1,TLSv1.1,TLSv1.2\fR.
8+
.
9+
.IP "\fB\-\-ssl\-ciphers=\fIciphers\fR"
10+
Specifies, in OpenSSL cipher string format, the ciphers \fB\*(PN\fR will
11+
support for SSL connections. The default when this option is omitted is
12+
\fBHIGH:!aNULL:!MD5\fR.

lib/stream-nossl.c

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2011 Nicira, Inc.
2+
* Copyright (c) 2011, 2016 Nicira, Inc.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -74,3 +74,17 @@ stream_ssl_set_key_and_cert(const char *private_key_file,
7474
stream_ssl_set_private_key_file(private_key_file);
7575
stream_ssl_set_certificate_file(certificate_file);
7676
}
77+
78+
void
79+
stream_ssl_set_protocols(const char *arg OVS_UNUSED)
80+
{
81+
/* Ignore this option since it seems harmless to set SSL protocols if SSL
82+
* won't be used. */
83+
}
84+
85+
void
86+
stream_ssl_set_ciphers(const char *arg OVS_UNUSED)
87+
{
88+
/* Ignore this option since it seems harmless to set SSL ciphers if SSL
89+
* won't be used. */
90+
}

lib/stream-ssl.c

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,8 @@ struct ssl_config_file {
162162
static struct ssl_config_file private_key;
163163
static struct ssl_config_file certificate;
164164
static struct ssl_config_file ca_cert;
165+
static char *ssl_protocols = "TLSv1,TLSv1.1,TLSv1.2";
166+
static char *ssl_ciphers = "HIGH:!aNULL:!MD5";
165167

166168
/* Ordinarily, the SSL client and server verify each other's certificates using
167169
* a CA certificate. Setting this to false disables this behavior. (This is a
@@ -966,6 +968,7 @@ do_ssl_init(void)
966968
SSL_CTX_set_verify(ctx, SSL_VERIFY_PEER | SSL_VERIFY_FAIL_IF_NO_PEER_CERT,
967969
NULL);
968970
SSL_CTX_set_session_cache_mode(ctx, SSL_SESS_CACHE_OFF);
971+
SSL_CTX_set_cipher_list(ctx, "HIGH:!aNULL:!MD5");
969972

970973
return 0;
971974
}
@@ -1114,6 +1117,68 @@ stream_ssl_set_key_and_cert(const char *private_key_file,
11141117
}
11151118
}
11161119

1120+
/* Sets SSL ciphers based on string input. Aborts with an error message
1121+
* if 'arg' is invalid. */
1122+
void
1123+
stream_ssl_set_ciphers(const char *arg)
1124+
{
1125+
if (ssl_init() || !arg || !strcmp(ssl_ciphers, arg)) {
1126+
return;
1127+
}
1128+
if (SSL_CTX_set_cipher_list(ctx,arg) == 0) {
1129+
VLOG_ERR("SSL_CTX_set_cipher_list: %s",
1130+
ERR_error_string(ERR_get_error(), NULL));
1131+
}
1132+
ssl_ciphers = xstrdup(arg);
1133+
}
1134+
1135+
/* Set SSL protocols based on the string input. Aborts with an error message
1136+
* if 'arg' is invalid. */
1137+
void
1138+
stream_ssl_set_protocols(const char *arg)
1139+
{
1140+
if (ssl_init() || !arg || !strcmp(arg, ssl_protocols)){
1141+
return;
1142+
}
1143+
1144+
/* Start with all the flags off and turn them on as requested. */
1145+
long protocol_flags = SSL_OP_NO_SSLv2 | SSL_OP_NO_SSLv3 | SSL_OP_NO_TLSv1;
1146+
protocol_flags |= SSL_OP_NO_TLSv1_1 | SSL_OP_NO_TLSv1_2;
1147+
1148+
char *s = xstrdup(arg);
1149+
char *save_ptr = NULL;
1150+
char *word = strtok_r(s, " ,\t", &save_ptr);
1151+
if (word == NULL) {
1152+
VLOG_ERR("SSL protocol settings invalid");
1153+
goto exit;
1154+
}
1155+
while (word != NULL) {
1156+
long on_flag;
1157+
if (!strcasecmp(word, "TLSv1.2")){
1158+
on_flag = SSL_OP_NO_TLSv1_2;
1159+
} else if (!strcasecmp(word, "TLSv1.1")){
1160+
on_flag = SSL_OP_NO_TLSv1_1;
1161+
} else if (!strcasecmp(word, "TLSv1")){
1162+
on_flag = SSL_OP_NO_TLSv1;
1163+
} else {
1164+
VLOG_ERR("%s: SSL protocol not recognized", word);
1165+
goto exit;
1166+
}
1167+
/* Reverse the no flag and mask it out in the flags
1168+
* to turn on that protocol. */
1169+
protocol_flags &= ~on_flag;
1170+
word = strtok_r(NULL, " ,\t", &save_ptr);
1171+
};
1172+
1173+
/* Set the actual options. */
1174+
SSL_CTX_set_options(ctx, protocol_flags);
1175+
1176+
ssl_protocols = xstrdup(arg);
1177+
1178+
exit:
1179+
free(s);
1180+
}
1181+
11171182
/* Reads the X509 certificate or certificates in file 'file_name'. On success,
11181183
* stores the address of the first element in an array of pointers to
11191184
* certificates in '*certs' and the number of certificates in the array in

lib/stream-ssl.h

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,19 @@ void stream_ssl_set_ca_cert_file(const char *file_name, bool bootstrap);
2525
void stream_ssl_set_peer_ca_cert_file(const char *file_name);
2626
void stream_ssl_set_key_and_cert(const char *private_key_file,
2727
const char *certificate_file);
28+
void stream_ssl_set_protocols(const char *arg);
29+
void stream_ssl_set_ciphers(const char *arg);
30+
31+
#define SSL_OPTION_ENUMS \
32+
OPT_SSL_PROTOCOLS, \
33+
OPT_SSL_CIPHERS
2834

2935
#define STREAM_SSL_LONG_OPTIONS \
3036
{"private-key", required_argument, NULL, 'p'}, \
3137
{"certificate", required_argument, NULL, 'c'}, \
32-
{"ca-cert", required_argument, NULL, 'C'}
38+
{"ca-cert", required_argument, NULL, 'C'}, \
39+
{"ssl-protocols", required_argument, NULL, OPT_SSL_PROTOCOLS}, \
40+
{"ssl-ciphers", required_argument, NULL, OPT_SSL_CIPHERS}
3341

3442
#define STREAM_SSL_OPTION_HANDLERS \
3543
case 'p': \
@@ -42,6 +50,14 @@ void stream_ssl_set_key_and_cert(const char *private_key_file,
4250
\
4351
case 'C': \
4452
stream_ssl_set_ca_cert_file(optarg, false); \
45-
break;
53+
break; \
54+
\
55+
case OPT_SSL_PROTOCOLS: \
56+
stream_ssl_set_protocols(optarg); \
57+
break; \
58+
\
59+
case OPT_SSL_CIPHERS: \
60+
stream_ssl_set_ciphers(optarg); \
61+
break;
4662

4763
#endif /* stream-ssl.h */

manpages.mk

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ ovsdb/ovsdb-client.1: \
2020
lib/daemon.man \
2121
lib/ssl-bootstrap-syn.man \
2222
lib/ssl-bootstrap.man \
23+
lib/ssl-connect-syn.man \
24+
lib/ssl-connect.man \
2325
lib/ssl-syn.man \
2426
lib/ssl.man \
2527
lib/table.man \
@@ -34,6 +36,8 @@ lib/daemon-syn.man:
3436
lib/daemon.man:
3537
lib/ssl-bootstrap-syn.man:
3638
lib/ssl-bootstrap.man:
39+
lib/ssl-connect-syn.man:
40+
lib/ssl-connect.man:
3741
lib/ssl-syn.man:
3842
lib/ssl.man:
3943
lib/table.man:
@@ -54,6 +58,8 @@ ovsdb/ovsdb-server.1: \
5458
lib/service.man \
5559
lib/ssl-bootstrap-syn.man \
5660
lib/ssl-bootstrap.man \
61+
lib/ssl-connect-syn.man \
62+
lib/ssl-connect.man \
5763
lib/ssl-peer-ca-cert-syn.man \
5864
lib/ssl-peer-ca-cert.man \
5965
lib/ssl-syn.man \
@@ -78,6 +84,8 @@ lib/service-syn.man:
7884
lib/service.man:
7985
lib/ssl-bootstrap-syn.man:
8086
lib/ssl-bootstrap.man:
87+
lib/ssl-connect-syn.man:
88+
lib/ssl-connect.man:
8189
lib/ssl-peer-ca-cert-syn.man:
8290
lib/ssl-peer-ca-cert.man:
8391
lib/ssl-syn.man:

ovn/controller-vtep/ovn-controller-vtep.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,8 @@ parse_options(int argc, char *argv[])
166166
OPT_PEER_CA_CERT = UCHAR_MAX + 1,
167167
OPT_BOOTSTRAP_CA_CERT,
168168
VLOG_OPTION_ENUMS,
169-
DAEMON_OPTION_ENUMS
169+
DAEMON_OPTION_ENUMS,
170+
SSL_OPTION_ENUMS,
170171
};
171172

172173
static struct option long_options[] = {

0 commit comments

Comments
 (0)