Re: [libvirt] [libvirt PATCH] qemu: Add support for specifying SPICE TLS ciphers

2018-04-04 Thread Christophe Fergeau
On Wed, Apr 04, 2018 at 09:11:25AM +0100, Daniel P. Berrangé wrote:
> On Tue, Apr 03, 2018 at 08:11:05PM +0200, Jiri Denemark wrote:
> > On Tue, Apr 03, 2018 at 17:23:50 +0200, Ján Tomko wrote:
> > > From: Christophe Fergeau 
> > > 
> > > This commit adds a 'spice_tls_ciphers' parameter in
> > > qemu.conf which allows to configure which TLS ciphers
> > > SPICE will be using for its TLS connections.
> > > 
> > > https://bugzilla.redhat.com/show_bug.cgi?id=1562032
> > > 
> > > Signed-off-by: Christophe Fergeau 
> > > Signed-off-by: Ján Tomko 
> > > ---
> > > This is mostly useful as a workaround for missing crypto policies,
> > > so I'm not sure if it's upstream material.
> > 
> > Are OpenSSL crypto policies supported upstream? If so, I think we should
> > just rely on them and leave this workaround for downstreams if they want
> > it.

--system-ciphers-file support seems to be a fedora patch
(openssl-1.1.0-system-cipherlist.patch), I could not find it in the
upstream git.
Something I realized recently is that OpenSSL crypto policies as they
are now in Fedora only allow to configure TLS ciphers, you cannot
enable/disable TLS protocol versions. This is possible with the gnutls
crypto policies.


> >Also, what would we do if spice changed its TLS code to use another
> > library, wouldn't it force us to translate the parameters from OpenSSL
> > to the other library if this happens and this code is merged upstream?
> 
> The latter is actually my biggest concern with this. I would really like
> to get SPICE to use the QEMU TLS creds framework, so we can do the normal
> -object tls-creds-x509 ... setup as we do for other parts ofo QEMU. This
> would mean SPICE using GNUTLS format for specifying ciphers. In fact the
> GNUTLS format specifies ciphers and TLS protocol versions - both of which
> the quoted bug is asking for - whereas this patch only specifies ciphers

Yes, I also want to explore making use of -object tls-creds-x509 for
SPICE. However, if doing that, it seems better to go the whole way, and
let QEMU do the socket handling including TLS, which is probably some
longer term work

I also have a set of patches to address the TLS version issue, which
adds a -spice tls-min-version command line option, and another libvirt
qemu.conf option.

I can definitely spend more time on -object tls-creds-x509 support
before we decide whether to move forward one way or the other.


Another stop gap solution I was thinking of, but which I'm not sure it
would work would be to extend  so that we can use it
to append options to existing commandline parameters, rather than always
adding a new parameter with the option. If there had been a way to
generate
-spice $libvirt_generated_args,tls-ciphers= rather than
-spice $libvirt_generated_args -spice tls-ciphers= , I don't think
https://bugzilla.redhat.com/show_bug.cgi?id=1562032 would have been
opened.

Christophe


signature.asc
Description: PGP signature
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Re: [libvirt] [libvirt PATCH] qemu: Add support for specifying SPICE TLS ciphers

2018-04-04 Thread Daniel P . Berrangé
On Tue, Apr 03, 2018 at 08:11:05PM +0200, Jiri Denemark wrote:
> On Tue, Apr 03, 2018 at 17:23:50 +0200, Ján Tomko wrote:
> > From: Christophe Fergeau 
> > 
> > This commit adds a 'spice_tls_ciphers' parameter in
> > qemu.conf which allows to configure which TLS ciphers
> > SPICE will be using for its TLS connections.
> > 
> > https://bugzilla.redhat.com/show_bug.cgi?id=1562032
> > 
> > Signed-off-by: Christophe Fergeau 
> > Signed-off-by: Ján Tomko 
> > ---
> > This is mostly useful as a workaround for missing crypto policies,
> > so I'm not sure if it's upstream material.
> 
> Are OpenSSL crypto policies supported upstream? If so, I think we should
> just rely on them and leave this workaround for downstreams if they want
> it. Also, what would we do if spice changed its TLS code to use another
> library, wouldn't it force us to translate the parameters from OpenSSL
> to the other library if this happens and this code is merged upstream?

The latter is actually my biggest concern with this. I would really like
to get SPICE to use the QEMU TLS creds framework, so we can do the normal
-object tls-creds-x509 ... setup as we do for other parts ofo QEMU. This
would mean SPICE using GNUTLS format for specifying ciphers. In fact the
GNUTLS format specifies ciphers and TLS protocol versions - both of which
the quoted bug is asking for - whereas this patch only specifies ciphers


Regards,
Daniel
-- 
|: https://berrange.com  -o-https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org -o-https://fstop138.berrange.com :|
|: https://entangle-photo.org-o-https://www.instagram.com/dberrange :|

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Re: [libvirt] [libvirt PATCH] qemu: Add support for specifying SPICE TLS ciphers

2018-04-03 Thread Jiri Denemark
On Tue, Apr 03, 2018 at 17:23:50 +0200, Ján Tomko wrote:
> From: Christophe Fergeau 
> 
> This commit adds a 'spice_tls_ciphers' parameter in
> qemu.conf which allows to configure which TLS ciphers
> SPICE will be using for its TLS connections.
> 
> https://bugzilla.redhat.com/show_bug.cgi?id=1562032
> 
> Signed-off-by: Christophe Fergeau 
> Signed-off-by: Ján Tomko 
> ---
> This is mostly useful as a workaround for missing crypto policies,
> so I'm not sure if it's upstream material.

Are OpenSSL crypto policies supported upstream? If so, I think we should
just rely on them and leave this workaround for downstreams if they want
it. Also, what would we do if spice changed its TLS code to use another
library, wouldn't it force us to translate the parameters from OpenSSL
to the other library if this happens and this code is merged upstream?

Jirka

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [libvirt PATCH] qemu: Add support for specifying SPICE TLS ciphers

2018-04-03 Thread Ján Tomko
From: Christophe Fergeau 

This commit adds a 'spice_tls_ciphers' parameter in
qemu.conf which allows to configure which TLS ciphers
SPICE will be using for its TLS connections.

https://bugzilla.redhat.com/show_bug.cgi?id=1562032

Signed-off-by: Christophe Fergeau 
Signed-off-by: Ján Tomko 
---
This is mostly useful as a workaround for missing crypto policies,
so I'm not sure if it's upstream material.

Changes from the patch attached to the BZ:
ciphers(2) -> ciphers(1)
Added augeas changes and tests
escape the string before passing it to QEMU

 src/qemu/libvirtd_qemu.aug |  1 +
 src/qemu/qemu.conf |  5 
 src/qemu/qemu_command.c|  8 +-
 src/qemu/qemu_conf.c   |  3 +++
 src/qemu/qemu_conf.h   |  1 +
 src/qemu/test_libvirtd_qemu.aug.in |  1 +
 .../graphics-spice-sasl-ciphers.args   | 29 ++
 .../graphics-spice-sasl-ciphers.xml|  1 +
 tests/qemuxml2argvtest.c   |  5 
 9 files changed, 53 insertions(+), 1 deletion(-)
 create mode 100644 tests/qemuxml2argvdata/graphics-spice-sasl-ciphers.args
 create mode 12 tests/qemuxml2argvdata/graphics-spice-sasl-ciphers.xml

diff --git a/src/qemu/libvirtd_qemu.aug b/src/qemu/libvirtd_qemu.aug
index c19bf3a43..15222d7e3 100644
--- a/src/qemu/libvirtd_qemu.aug
+++ b/src/qemu/libvirtd_qemu.aug
@@ -44,6 +44,7 @@ module Libvirtd_qemu =
let spice_entry = str_entry "spice_listen"
  | bool_entry "spice_tls"
  | str_entry  "spice_tls_x509_cert_dir"
+ | str_entry "spice_tls_ciphers"
  | bool_entry "spice_auto_unix_socket"
  | str_entry "spice_password"
  | bool_entry "spice_sasl"
diff --git a/src/qemu/qemu.conf b/src/qemu/qemu.conf
index 07eab7eff..1d7b6c555 100644
--- a/src/qemu/qemu.conf
+++ b/src/qemu/qemu.conf
@@ -181,6 +181,11 @@
 #spice_tls_x509_cert_dir = "/etc/pki/libvirt-spice"
 
 
+# The ciphers used by spice can be overridden here. This is an OpenSSL cipher
+# list as documented in ciphers(1)
+#spice_tls_ciphers = "DEFAULT"
+
+
 # Enable this option to have SPICE served over an automatically created
 # unix socket. This prevents unprivileged access from users on the
 # host machine.
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 682d71441..adf0b2cb9 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -8028,8 +8028,14 @@ qemuBuildGraphicsSPICECommandLine(virQEMUDriverConfigPtr 
cfg,
 !cfg->spicePassword)
 virBufferAddLit(, "disable-ticketing,");
 
-if (hasSecure)
+if (hasSecure) {
 virBufferAsprintf(, "x509-dir=%s,", cfg->spiceTLSx509certdir);
+if (cfg->spiceTLSCiphers) {
+virBufferAddLit(, "tls-ciphers=");
+virQEMUBuildBufferEscapeComma(, cfg->spiceTLSCiphers);
+virBufferAddLit(, ",");
+}
+}
 
 switch (graphics->data.spice.defaultMode) {
 case VIR_DOMAIN_GRAPHICS_SPICE_CHANNEL_MODE_SECURE:
diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
index 36cf3a281..92afd252d 100644
--- a/src/qemu/qemu_conf.c
+++ b/src/qemu/qemu_conf.c
@@ -374,6 +374,7 @@ static void virQEMUDriverConfigDispose(void *obj)
 VIR_FREE(cfg->vncSASLdir);
 
 VIR_FREE(cfg->spiceTLSx509certdir);
+VIR_FREE(cfg->spiceTLSCiphers);
 VIR_FREE(cfg->spiceListen);
 VIR_FREE(cfg->spicePassword);
 VIR_FREE(cfg->spiceSASLdir);
@@ -550,6 +551,8 @@ int virQEMUDriverConfigLoadFile(virQEMUDriverConfigPtr cfg,
 goto cleanup;
 if (virConfGetValueString(conf, "spice_tls_x509_cert_dir", 
>spiceTLSx509certdir) < 0)
 goto cleanup;
+if (virConfGetValueString(conf, "spice_tls_ciphers", 
>spiceTLSCiphers) < 0)
+goto cleanup;
 if (virConfGetValueBool(conf, "spice_sasl", >spiceSASL) < 0)
 goto cleanup;
 if (virConfGetValueString(conf, "spice_sasl_dir", >spiceSASLdir) < 0)
diff --git a/src/qemu/qemu_conf.h b/src/qemu/qemu_conf.h
index e1ad5463f..9ab9f4e37 100644
--- a/src/qemu/qemu_conf.h
+++ b/src/qemu/qemu_conf.h
@@ -128,6 +128,7 @@ struct _virQEMUDriverConfig {
 
 bool spiceTLS;
 char *spiceTLSx509certdir;
+char *spiceTLSCiphers;
 bool spiceSASL;
 char *spiceSASLdir;
 char *spiceListen;
diff --git a/src/qemu/test_libvirtd_qemu.aug.in 
b/src/qemu/test_libvirtd_qemu.aug.in
index 688e5b9fd..2f62b383e 100644
--- a/src/qemu/test_libvirtd_qemu.aug.in
+++ b/src/qemu/test_libvirtd_qemu.aug.in
@@ -17,6 +17,7 @@ module Test_libvirtd_qemu =
 { "spice_listen" = "0.0.0.0" }
 { "spice_tls" = "1" }
 { "spice_tls_x509_cert_dir" = "/etc/pki/libvirt-spice" }
+{ "spice_tls_ciphers" = "DEFAULT" }
 { "spice_auto_unix_socket" = "1" }
 { "spice_password" = "XYZ12345" }
 { "spice_sasl" = "1" }
diff --git