|
| 1 | +diff --git a/Documentation/intro/install/general.rst b/Documentation/intro/install/general.rst |
| 2 | +index a297aadac..745ca4aea 100644 |
| 3 | +--- a/Documentation/intro/install/general.rst |
| 4 | ++++ b/Documentation/intro/install/general.rst |
| 5 | +@@ -85,6 +85,10 @@ need the following software: |
| 6 | + an OpenFlow controller. If libssl is installed, then Open vSwitch will |
| 7 | + automatically build with support for it. |
| 8 | + |
| 9 | ++- libwolfssl, from wolfSSL, is optional and can be used instead of openssl to |
| 10 | ++ provide commercial open source library for TLS and Crypto. Enabled using |
| 11 | ++ --with-wolfssl. See details in ./Documentation/intro/install/wolfssl.rst. |
| 12 | ++ |
| 13 | + - libcap-ng, written by Steve Grubb, is optional but recommended. It is |
| 14 | + required to run OVS daemons as a non-root user with dropped root privileges. |
| 15 | + If libcap-ng is installed, then Open vSwitch will automatically build with |
| 16 | +diff --git a/configure.ac b/configure.ac |
| 17 | +index f14ba7db4..b3afbb7b4 100644 |
| 18 | +--- a/configure.ac |
| 19 | ++++ b/configure.ac |
| 20 | +@@ -90,6 +90,7 @@ OVS_CHECK_COVERAGE |
| 21 | + OVS_CHECK_NDEBUG |
| 22 | + OVS_CHECK_USDT |
| 23 | + OVS_CHECK_NETLINK |
| 24 | ++OVS_CHECK_WOLFSSL |
| 25 | + OVS_CHECK_OPENSSL |
| 26 | + OVS_CHECK_LIBCAPNG |
| 27 | + OVS_CHECK_LOGDIR |
| 28 | +diff --git a/lib/dhparams.h b/lib/dhparams.h |
| 29 | +index 0eca99a6f..96b839f12 100644 |
| 30 | +--- a/lib/dhparams.h |
| 31 | ++++ b/lib/dhparams.h |
| 32 | +@@ -18,6 +18,9 @@ |
| 33 | + #define DHPARAMS_H 1 |
| 34 | + |
| 35 | + #include <inttypes.h> |
| 36 | ++#ifdef HAVE_WOLFSSL |
| 37 | ++#include <wolfssl/options.h> |
| 38 | ++#endif |
| 39 | + #include <openssl/dh.h> |
| 40 | + |
| 41 | + DH *get_dh2048(void); |
| 42 | +diff --git a/lib/stream-ssl.c b/lib/stream-ssl.c |
| 43 | +index f4fe3432e..60159b3fa 100644 |
| 44 | +--- a/lib/stream-ssl.c |
| 45 | ++++ b/lib/stream-ssl.c |
| 46 | +@@ -24,6 +24,10 @@ |
| 47 | + #include <sys/types.h> |
| 48 | + #include <sys/socket.h> |
| 49 | + #include <netinet/tcp.h> |
| 50 | ++#ifdef HAVE_WOLFSSL |
| 51 | ++#include <wolfssl/options.h> |
| 52 | ++#include <openssl/pem.h> |
| 53 | ++#endif |
| 54 | + #include <openssl/err.h> |
| 55 | + #include <openssl/rand.h> |
| 56 | + #include <openssl/ssl.h> |
| 57 | +@@ -185,6 +189,10 @@ static unsigned int next_session_nr; |
| 58 | + * quite a bit. */ |
| 59 | + static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(10, 25); |
| 60 | + |
| 61 | ++#ifdef HAVE_WOLFSSL |
| 62 | ++static const char *peer_ca_cert_file = NULL; |
| 63 | ++#endif |
| 64 | ++ |
| 65 | + static int ssl_init(void); |
| 66 | + static int do_ssl_init(void); |
| 67 | + static bool ssl_wants_io(int ssl_error); |
| 68 | +@@ -197,6 +205,7 @@ static DH *tmp_dh_callback(SSL *ssl, int is_export OVS_UNUSED, int keylength); |
| 69 | + static void log_ca_cert(const char *file_name, X509 *cert); |
| 70 | + static void stream_ssl_set_ca_cert_file__(const char *file_name, |
| 71 | + bool bootstrap, bool force); |
| 72 | ++static void stream_ssl_set_peer_ca_cert_file__(const char *file_name); |
| 73 | + static void ssl_protocol_cb(int write_p, int version, int content_type, |
| 74 | + const void *, size_t, SSL *, void *sslv_); |
| 75 | + static bool update_ssl_config(struct ssl_config_file *, const char *file_name); |
| 76 | +@@ -1004,6 +1013,15 @@ ssl_init(void) |
| 77 | + return init_status; |
| 78 | + } |
| 79 | + |
| 80 | ++#if defined(HAVE_WOLFSSL) && defined(DEBUG_WOLFSSL) |
| 81 | ++static void wolfssl_debug_cb(const int log_level, const char *const log_message) |
| 82 | ++{ |
| 83 | ++ (void)log_level; |
| 84 | ++ |
| 85 | ++ VLOG_DBG("wolfSSL debug: %s", log_message); |
| 86 | ++} |
| 87 | ++#endif |
| 88 | ++ |
| 89 | + static int |
| 90 | + do_ssl_init(void) |
| 91 | + { |
| 92 | +@@ -1017,6 +1035,10 @@ do_ssl_init(void) |
| 93 | + SSL_library_init(); |
| 94 | + SSL_load_error_strings(); |
| 95 | + #endif |
| 96 | ++#if defined(HAVE_WOLFSSL) && defined(DEBUG_WOLFSSL) |
| 97 | ++ wolfSSL_Debugging_ON(); |
| 98 | ++ wolfSSL_SetLoggingCb(wolfssl_debug_cb); |
| 99 | ++#endif |
| 100 | + |
| 101 | + if (!RAND_status()) { |
| 102 | + /* We occasionally see OpenSSL fail to seed its random number generator |
| 103 | +@@ -1354,13 +1376,8 @@ read_cert_file(const char *file_name, X509 ***certs, size_t *n_certs) |
| 104 | + return 0; |
| 105 | + } |
| 106 | + |
| 107 | +- |
| 108 | +-/* Sets 'file_name' as the name of a file containing one or more X509 |
| 109 | +- * certificates to send to the peer. Typical use in OpenFlow is to send the CA |
| 110 | +- * certificate to the peer, which enables a switch to pick up the controller's |
| 111 | +- * CA certificate on its first connection. */ |
| 112 | + void |
| 113 | +-stream_ssl_set_peer_ca_cert_file(const char *file_name) |
| 114 | ++stream_ssl_set_peer_ca_cert_file__(const char *file_name) |
| 115 | + { |
| 116 | + X509 **certs; |
| 117 | + size_t n_certs; |
| 118 | +@@ -1381,6 +1398,20 @@ stream_ssl_set_peer_ca_cert_file(const char *file_name) |
| 119 | + } |
| 120 | + } |
| 121 | + |
| 122 | ++/* Sets 'file_name' as the name of a file containing one or more X509 |
| 123 | ++ * certificates to send to the peer. Typical use in OpenFlow is to send the CA |
| 124 | ++ * certificate to the peer, which enables a switch to pick up the controller's |
| 125 | ++ * CA certificate on its first connection. */ |
| 126 | ++void |
| 127 | ++stream_ssl_set_peer_ca_cert_file(const char *file_name) |
| 128 | ++{ |
| 129 | ++#ifdef HAVE_WOLFSSL |
| 130 | ++ peer_ca_cert_file = file_name; |
| 131 | ++#else |
| 132 | ++ stream_ssl_set_peer_ca_cert_file__(file_name); |
| 133 | ++#endif /* HAVE_WOLFSSL */ |
| 134 | ++} |
| 135 | ++ |
| 136 | + /* Logs fingerprint of CA certificate 'cert' obtained from 'file_name'. */ |
| 137 | + static void |
| 138 | + log_ca_cert(const char *file_name, X509 *cert) |
| 139 | +@@ -1447,6 +1478,19 @@ stream_ssl_set_ca_cert_file__(const char *file_name, |
| 140 | + } |
| 141 | + } |
| 142 | + ca_cert.read = true; |
| 143 | ++ |
| 144 | ++ /* |
| 145 | ++ * With wolfSSL, we can't just call stream_ssl_set_peer_ca_cert_file |
| 146 | ++ * before setting the leaf cert with stream_ssl_set_ca_cert_file because |
| 147 | ++ * stream_ssl_set_ca_cert_file will wipe out the peer CA cert. So, we set |
| 148 | ++ * the peer CA cert *after* the leaf cert here instead. This allows the |
| 149 | ++ * cert bootstrapping strategy to work with wolfSSL. |
| 150 | ++ */ |
| 151 | ++#ifdef HAVE_WOLFSSL |
| 152 | ++ if (peer_ca_cert_file != NULL) { |
| 153 | ++ stream_ssl_set_peer_ca_cert_file__(peer_ca_cert_file); |
| 154 | ++ } |
| 155 | ++#endif |
| 156 | + } |
| 157 | + |
| 158 | + /* Sets 'file_name' as the name of the file from which to read the CA |
| 159 | +diff --git a/m4/openvswitch.m4 b/m4/openvswitch.m4 |
| 160 | +index 4c3bace6e..595b7b343 100644 |
| 161 | +--- a/m4/openvswitch.m4 |
| 162 | ++++ b/m4/openvswitch.m4 |
| 163 | +@@ -259,6 +259,56 @@ AC_DEFUN([OVS_CHECK_LIBCAPNG], |
| 164 | + AC_SUBST([CAPNG_LDADD]) |
| 165 | + fi]) |
| 166 | + |
| 167 | ++ |
| 168 | ++dnl Checks for wolfSSL |
| 169 | ++AC_DEFUN([OVS_CHECK_WOLFSSL], [ |
| 170 | ++ WOLFSSL_URL="http://www.wolfssl.com/download.html" |
| 171 | ++ HAVE_WOLFSSL=no |
| 172 | ++ AC_ARG_WITH(wolfssl, |
| 173 | ++ [AC_HELP_STRING([--with-wolfssl=PATH], [PATH to wolfssl install])], |
| 174 | ++ [ |
| 175 | ++ AC_MSG_CHECKING([whether compiling and linking against wolfSSL works]) |
| 176 | ++ if test "x$withval" != "xno" ; then |
| 177 | ++ if test -d "$withval/lib"; then |
| 178 | ++ LDFLAGS="$LDFLAGS -L${withval}/lib" |
| 179 | ++ fi |
| 180 | ++ if test -d "$withval/include"; then |
| 181 | ++ CPPFLAGS="-I${withval}/include -I${withval}/include/wolfssl $CPPFLAGS" |
| 182 | ++ fi |
| 183 | ++ fi |
| 184 | ++ if test "x$withval" = "xyes" ; then |
| 185 | ++ LDFLAGS="$LDFLAGS -L/usr/local/lib" |
| 186 | ++ CPPFLAGS="-I/usr/local/include -I/usr/local/include/wolfssl $CPPFLAGS" |
| 187 | ++ fi |
| 188 | ++ LIBS="$LIBS -lwolfssl" |
| 189 | ++ CPPFLAGS="$CPPFLAGS -DHAVE_WOLFSSL" |
| 190 | ++ |
| 191 | ++ AC_LINK_IFELSE( |
| 192 | ++ [AC_LANG_PROGRAM([#include <wolfssl/ssl.h>], |
| 193 | ++ [wolfSSL_Init();])], |
| 194 | ++ [wolfssl_linked=yes], |
| 195 | ++ [wolfssl_linked=no] |
| 196 | ++ ) |
| 197 | ++ |
| 198 | ++ if test "x$wolfssl_linked" = "xno" ; then |
| 199 | ++ AC_MSG_ERROR([WolfSSL isn't found. You can get it from $WOLFSSL_URL |
| 200 | ++ If it's already installed, specify its path using --with-wolfssl=/dir/]) |
| 201 | ++ fi |
| 202 | ++ |
| 203 | ++ AC_MSG_RESULT([yes]) |
| 204 | ++ HAVE_WOLFSSL=yes |
| 205 | ++ HAVE_OPENSSL=yes |
| 206 | ++ ssl=true |
| 207 | ++ ], [ |
| 208 | ++ AC_MSG_RESULT([no]) |
| 209 | ++ ssl=no |
| 210 | ++ ]) |
| 211 | ++ |
| 212 | ++ AC_SUBST([HAVE_WOLFSSL]) |
| 213 | ++ AM_CONDITIONAL([HAVE_WOLFSSL], [test "$HAVE_WOLFSSL" = yes]) |
| 214 | ++]) |
| 215 | ++ |
| 216 | ++ |
| 217 | + dnl Checks for OpenSSL. |
| 218 | + AC_DEFUN([OVS_CHECK_OPENSSL], |
| 219 | + [AC_ARG_ENABLE( |
| 220 | +@@ -271,7 +321,7 @@ AC_DEFUN([OVS_CHECK_OPENSSL], |
| 221 | + esac], |
| 222 | + [ssl=check]) |
| 223 | + |
| 224 | +- if test "$ssl" != false; then |
| 225 | ++ if test "$ssl" != false && test "$HAVE_WOLFSSL" = "no"; then |
| 226 | + AX_CHECK_OPENSSL( |
| 227 | + [HAVE_OPENSSL=yes], |
| 228 | + [HAVE_OPENSSL=no |
| 229 | +@@ -286,7 +336,9 @@ OpenFlow connections over SSL will not be supported. |
| 230 | + AC_MSG_ERROR([Cannot find openssl (use --disable-ssl to configure without SSL support)]) |
| 231 | + fi]) |
| 232 | + else |
| 233 | +- HAVE_OPENSSL=no |
| 234 | ++ if test "x$HAVE_WOLFSSL" = "xno"; then |
| 235 | ++ HAVE_OPENSSL=no |
| 236 | ++ fi |
| 237 | + fi |
| 238 | + AC_SUBST([HAVE_OPENSSL]) |
| 239 | + AM_CONDITIONAL([HAVE_OPENSSL], [test "$HAVE_OPENSSL" = yes]) |
| 240 | +diff --git a/tests/ovsdb-server.at b/tests/ovsdb-server.at |
| 241 | +index 876cb836c..8eafa4135 100644 |
| 242 | +--- a/tests/ovsdb-server.at |
| 243 | ++++ b/tests/ovsdb-server.at |
| 244 | +@@ -657,7 +657,7 @@ AT_CHECK_UNQUOTED( |
| 245 | + # The error message for being unable to negotiate a shared ciphersuite |
| 246 | + # is 'sslv3 alert handshake failure'. This is not the clearest message. |
| 247 | + AT_CHECK_UNQUOTED( |
| 248 | +- [grep "sslv3 alert handshake failure" output], [0], |
| 249 | ++ [grep "bad SSL error code -313" output], [0], |
| 250 | + [stdout], |
| 251 | + [ignore]) |
| 252 | + OVSDB_SERVER_SHUTDOWN |
0 commit comments