[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

[Nbd] [PATCHv3 0/6] Introduce TLS support on nbdserver & nbdclient



This is an RFC patch to introduce TLS support on nbdserver & nbdclient.

This is *NOT* production ready by any means, and is submitted for comment.

I have added crypto-gnutls.[ch] from:
github.com/abligh/tlsproxy
which is my attempt at an MIT licenced GnuTLS proxy. The proxy element
is standalone, and is incorporated here. Whilst it's not GPL licensed,
MIT is compatible. Also it uses GNU format indentation (sorry about that).
However, it (together with buffer.[ch]) is almost entirely self-contained.

The same approach is taken for nbdclient. As the proxy runs as an independent
process, nbdclient can launch it, then call the DOIT ioctl() on one end of
the created socketpair(). The proxy process then drops into the background
and closes after either the kernel closes the socket or the other end closes
the socket.

I have tested this to a minimal extent against qemu-img (i.e. qemu
acting as a client). The problem (see nbdgeneral ad nauseam) we have
with NBD_CMD_DISC means that we see false reports of 'magic number mismatch'.
This appears to be because read() returns 0 in negotiate(), and nbdserver
does not check for this. It then reverses (again) the *previous* magic
number, using ntohll(), and this causes the 'magic number mismatch' issue.
This isn't really a problem but causes confusing errors.

I have also tested nbd-client against nbd-server with TLS, and
the test suite tests nbd-tester-client against nbd-server with TLS.

The first two patches are preparatory work, and the third patch actually
adds NBD_OPT_STARTTLS. The comment in that patch shows what is left to
figure out.

Changes from v2:

* Add support for nbd-client

* Wouter's changes to Makefile.am and conditional compilation.

Changes from v1:

* Added support for TLS to nbd-tester-client. Weirdly it passed first
 time.

* In doing so, folded into this series the two patches to
 ndb-tester-client.c into this series. Note the FIXED_NEWSTYLE patch
 earlier missed host/network ordering.

* Per Wouter, use AM_CONDITIONAL rather than #ifdef'ing out files

* Per Wouter, do the test for GnuTLS later.

Alex Bligh (6):
  Add GnuTLS infrastructure
  Add options for TLS support for server
  Add TLS support to server
  Add TLS testing to nbd-tester-client.c
  Add options to nbd-client for TLS support
  Add TLS support to NBD client

 Makefile.am                     |   5 +
 buffer.c                        | 225 +++++++++++++++
 buffer.h                        |  45 +++
 cliserv.h                       |   1 +
 configure.ac                    |  15 +
 crypto-gnutls.c                 | 610 ++++++++++++++++++++++++++++++++++++++++
 crypto-gnutls.h                 |  43 +++
 man/nbd-server.5.in.sgml        |  65 +++++
 nbd-client.c                    | 193 ++++++++++++-
 nbd-server.c                    | 204 ++++++++++++--
 nbd.h                           |   2 +
 nbdsrv.h                        |   1 +
 tests/run/Makefile.am           |  14 +-
 tests/run/certs/ca-cert.pem     |  20 ++
 tests/run/certs/ca-key.pem      |  32 +++
 tests/run/certs/ca.info         |   3 +
 tests/run/certs/client-cert.pem |  23 ++
 tests/run/certs/client-key.pem  |  32 +++
 tests/run/certs/client.info     |   8 +
 tests/run/certs/server-cert.pem |  22 ++
 tests/run/certs/server-key.pem  |  32 +++
 tests/run/certs/server.info     |   5 +
 tests/run/nbd-tester-client.c   | 169 ++++++++++-
 tests/run/simple_test           |  45 +++
 24 files changed, 1778 insertions(+), 36 deletions(-)
 create mode 100644 buffer.c
 create mode 100644 buffer.h
 create mode 100644 crypto-gnutls.c
 create mode 100644 crypto-gnutls.h
 create mode 100644 tests/run/certs/ca-cert.pem
 create mode 100644 tests/run/certs/ca-key.pem
 create mode 100644 tests/run/certs/ca.info
 create mode 100644 tests/run/certs/client-cert.pem
 create mode 100644 tests/run/certs/client-key.pem
 create mode 100644 tests/run/certs/client.info
 create mode 100644 tests/run/certs/server-cert.pem
 create mode 100644 tests/run/certs/server-key.pem
 create mode 100644 tests/run/certs/server.info

-- 
1.9.1




Reply to: