]> xenbits.xensource.com Git - libvirt.git/commitdiff
Sanity check explicit TLS file paths
authorDaniel P. Berrange <berrange@redhat.com>
Wed, 15 Mar 2017 18:02:40 +0000 (18:02 +0000)
committerDaniel P. Berrange <berrange@redhat.com>
Thu, 16 Mar 2017 10:49:58 +0000 (10:49 +0000)
When providing explicit x509 cert/key paths in libvirtd.conf,
the user must provide all three. If one or more is missed,
this leads to obscure errors at runtime when negotiating
the TLS session

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
daemon/libvirtd.c

index 9b98f337353e30cd0b8fba5d5aef13ccfbffc236..891238bcbe0d46ea6c14802c8ecbde3f80790212 100644 (file)
@@ -544,6 +544,23 @@ daemonSetupNetworking(virNetServerPtr srv,
             if (config->ca_file ||
                 config->cert_file ||
                 config->key_file) {
+                if (!config->ca_file) {
+                    virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+                                   _("No CA certificate path set to match server key/cert"));
+                    goto cleanup;
+                }
+                if (!config->cert_file) {
+                    virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+                                   _("No server certificate path set to match server key"));
+                    goto cleanup;
+                }
+                if (!config->key_file) {
+                    virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+                                   _("No server key path set to match server cert"));
+                    goto cleanup;
+                }
+                VIR_DEBUG("Using CA='%s' cert='%s' key='%s'",
+                          config->ca_file, config->cert_file, config->key_file);
                 if (!(ctxt = virNetTLSContextNewServer(config->ca_file,
                                                        config->crl_file,
                                                        config->cert_file,