From nobody Fri May 3 09:42:10 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1636663054; cv=none; d=zohomail.com; s=zohoarc; b=lz5q4rH8fUiubPAgFcMepmtY1bjY2hIEqqVh2wF2aiwh95yAqyfoHxqVcnWnhBRcGYQHMUcWT4sQWzjWvJqSaqoE1SBp2WZfbI7NpK6E6zZOXH3vsV4nrOy3I8CQofhRRWZrynDGnlQs+XSLFQKE3kbI6qcLZmZzKbKlT0asXAY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1636663054; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=URtQWOLhY4/xIk/FnpXtEC6QiaHtpB+Ib4btDRmjLqs=; b=GHt4UEerNN4fll5u7QG97DaARwoK3sf2/0MCtFvvzxkIzq1reaLBWpuq8VmiC373LXFIuL4OfLYzXN3siXzfDAS6oGEKupWEE0CzOSndLF853hTm6D5DfAQGIctYdeXJZGankYyjejPZI36jSOnYJfpPxbX/gYzY8QXaemMqJvQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1636663054002314.87452377041416; Thu, 11 Nov 2021 12:37:34 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-527-JsNtPYldMyu5DZfX-kqXiA-1; Thu, 11 Nov 2021 15:37:31 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 7C90D802C94; Thu, 11 Nov 2021 20:37:26 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 60F5F67848; Thu, 11 Nov 2021 20:37:26 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 36B061832DD2; Thu, 11 Nov 2021 20:37:26 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 1ABKbMEo007127 for ; Thu, 11 Nov 2021 15:37:22 -0500 Received: by smtp.corp.redhat.com (Postfix) id 08498404727C; Thu, 11 Nov 2021 20:37:22 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast01.extmail.prod.ext.rdu2.redhat.com [10.11.55.17]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 048FC4047279 for ; Thu, 11 Nov 2021 20:37:22 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id DF6E985A5A8 for ; Thu, 11 Nov 2021 20:37:21 +0000 (UTC) Received: from mail-ed1-f69.google.com (mail-ed1-f69.google.com [209.85.208.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-380-rVe-T67RN9SQmMCxxZ463A-1; Thu, 11 Nov 2021 15:37:01 -0500 Received: by mail-ed1-f69.google.com with SMTP id m8-20020a056402510800b003e29de5badbso6370088edd.18 for ; Thu, 11 Nov 2021 12:37:01 -0800 (PST) Received: from wheatley.localdomain (k8r.cz. [95.82.177.71]) by smtp.gmail.com with ESMTPSA id hd18sm1862520ejc.84.2021.11.11.12.36.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Nov 2021 12:36:58 -0800 (PST) Received: from wheatley.k8r.cz (wheatley.k8r.cz [127.0.0.1]) by wheatley.localdomain (Postfix) with ESMTP id 562E61BCD6D2; Thu, 11 Nov 2021 21:36:58 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1636663053; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=URtQWOLhY4/xIk/FnpXtEC6QiaHtpB+Ib4btDRmjLqs=; b=ZAhfPJ0TpYZWR9hE6f+WwV2JDjsIkSL1R52+G0e9GYHJBIZwHF56/syTN4ZISxWkmV6Z2y /3Hi3MtAbiUpQLzU4qp+KotfKnomPy6l+sh2R9jGmi9gTGH1LFOc5DfJ+IQKMJX00JzIKC 0de7a+DgkdstSqkEyQYeIr82uKjV23k= X-MC-Unique: JsNtPYldMyu5DZfX-kqXiA-1 X-MC-Unique: rVe-T67RN9SQmMCxxZ463A-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=URtQWOLhY4/xIk/FnpXtEC6QiaHtpB+Ib4btDRmjLqs=; b=gzShSSZCKyjvseBab0tJuI/97jvqekD/Ut1C9ClGSzYB3fuh+4pfzB+PwpWjkq2922 GoD1UbYDXTAhooLitnZ3bfUr97MsEmlluHWLulYjATR5IftZ4T+5JupDBNJtxmoqSFa9 0CV+lH5l0OOlLHT/i3urxqtaGNuDXrW3F8VNfxdEfbEfWq1wZpaXHnixDP1tR5DhoFzz +jz7a1ffg1grJv3sI7JfNCZOlEKsnse8mUUmpCIBpWDB8Ac1XOnoW7RBdUG/kioIOqfU Wo9ttKaCQrXYYWdq1IZ6OVCCyAar2UlAJf2x4rZJiK1+uDtQkdJUo9q6cCaeWm9DRuCC 3GfA== X-Gm-Message-State: AOAM530Ol8HVDF7CuPCfKsPj1Ku3mY9sGldVRnki3ZYAbUO9ZCeG6RTC UPeZRKWxT1BfWxxmqmWeYK0qgwhe1lmmzrgoJ+HK+SFzc3EKG6tTR46dYpD6RB/j4fs0xFEZGlp fLtxfwsr70vugNHb7boo= X-Received: by 2002:a17:907:9711:: with SMTP id jg17mr13421894ejc.242.1636663020195; Thu, 11 Nov 2021 12:37:00 -0800 (PST) X-Google-Smtp-Source: ABdhPJxsmSuyb9dv9Y2nGjxq6sgbfKCOZnyo1WS+xME7xr+sY837zunvzm+VcAfLX0P2NP+tsGqbpQ== X-Received: by 2002:a17:907:9711:: with SMTP id jg17mr13421875ejc.242.1636663020008; Thu, 11 Nov 2021 12:37:00 -0800 (PST) From: Martin Kletzander To: libvir-list@redhat.com Subject: [PATCH v2 1/3] tools: Add virt-pki-query-dn binary Date: Thu, 11 Nov 2021 21:36:55 +0100 Message-Id: <7112805793f67c1edfaf47a2df33ec16656ade1b.1636662545.git.mkletzan@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.11.54.2 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1636663055438100003 Content-Type: text/plain; charset="utf-8" With this program we do not have to depend on the output of `certtool -i`, = which changed the order of the fields at some point and the newest version is incompatible with what libvirt expects in tls_allowed_dn_list configuration option. Signed-off-by: Martin Kletzander Reviewed-by: Daniel P. Berrang=C3=A9 --- libvirt.spec.in | 1 + po/POTFILES.in | 1 + tools/meson.build | 27 ++++++++ tools/virt-pki-query-dn.c | 140 ++++++++++++++++++++++++++++++++++++++ 4 files changed, 169 insertions(+) create mode 100644 tools/virt-pki-query-dn.c diff --git a/libvirt.spec.in b/libvirt.spec.in index 4ecb28114ce8..5f1773ef93f2 100644 --- a/libvirt.spec.in +++ b/libvirt.spec.in @@ -1983,6 +1983,7 @@ exit 0 %{_mandir}/man1/virt-pki-validate.1* %{_bindir}/virsh %{_bindir}/virt-xml-validate +%{_bindir}/virt-pki-query-dn %{_bindir}/virt-pki-validate =20 %{_datadir}/bash-completion/completions/virsh diff --git a/po/POTFILES.in b/po/POTFILES.in index 8a726f624e38..bf0a3b352979 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -376,6 +376,7 @@ @SRCDIR@tools/virt-host-validate-qemu.c @SRCDIR@tools/virt-host-validate.c @SRCDIR@tools/virt-login-shell-helper.c +@SRCDIR@tools/virt-pki-query-dn.c @SRCDIR@tools/vsh-table.c @SRCDIR@tools/vsh.c @SRCDIR@tools/vsh.h diff --git a/tools/meson.build b/tools/meson.build index bf0eab8b6bf2..3fba313e5f49 100644 --- a/tools/meson.build +++ b/tools/meson.build @@ -257,6 +257,33 @@ configure_file( install_mode: 'rwxrwxr-x', ) =20 +executable( + 'virt-pki-query-dn', + [ + 'virt-pki-query-dn.c', + ], + dependencies: [ + glib_dep, + gnutls_dep, + ], + include_directories: [ + libvirt_inc, + src_inc_dir, + top_inc_dir, + util_inc_dir, + ], + link_args: ( + libvirt_relro + + libvirt_no_indirect + + libvirt_no_undefined + ), + link_with: [ + libvirt_lib + ], + install: true, + install_dir: bindir, +) + if conf.has('WITH_SANLOCK') configure_file( input: 'virt-sanlock-cleanup.in', diff --git a/tools/virt-pki-query-dn.c b/tools/virt-pki-query-dn.c new file mode 100644 index 000000000000..ee3783c1b279 --- /dev/null +++ b/tools/virt-pki-query-dn.c @@ -0,0 +1,140 @@ +/* + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#include +#include "internal.h" + +#include +#include +#include + +#include +#include + +#include "virgettext.h" + + +static void +glib_auto_cleanup_gnutls_x509_crt_t(gnutls_x509_crt_t *pointer) +{ + gnutls_x509_crt_deinit(*pointer); +} + + +static void +print_usage(const char *progname, + FILE *out) +{ + fprintf(out, + _("Usage:\n" + " %s FILE\n" + " %s { -v | -h }\n" + "\n" + "Extract Distinguished Name from a PEM certificate.\n" + "The output is meant to be used in the tls_allowed_dn_list\n" + "configuration option in the libvirtd.conf file.\n" + "\n" + " FILE certificate file to extract the DN from\n" + "\n" + "options:\n" + " -h | --help display this help and exit\n" + " -v | --version output version information and exit\n"), + progname, progname); +} + + +int +main(int argc, + char **argv) +{ + const char *progname =3D NULL; + const char *filename =3D NULL; + size_t dnamesize =3D 256; + size_t bufsize =3D 0; + g_autofree char *dname =3D g_new0(char, dnamesize); + g_autofree char *buf =3D NULL; + g_auto(gnutls_x509_crt_t) crt =3D {0}; + gnutls_datum_t crt_data =3D {0}; + g_autoptr(GError) error =3D NULL; + int arg =3D 0; + int rv =3D 0; + + struct option opt[] =3D { + {"help", no_argument, NULL, 'h'}, + {"version", optional_argument, NULL, 'v'}, + {NULL, 0, NULL, 0} + }; + + if (virGettextInitialize() < 0) + return EXIT_FAILURE; + + if (!(progname =3D strrchr(argv[0], '/'))) + progname =3D argv[0]; + else + progname++; + + while ((arg =3D getopt_long(argc, argv, "hv", opt, NULL)) !=3D -1) { + switch (arg) { + case 'v': + printf("%s\n", PACKAGE_VERSION); + return EXIT_SUCCESS; + case 'h': + print_usage(progname, stdout); + return EXIT_SUCCESS; + default: + print_usage(progname, stderr); + return EXIT_FAILURE; + } + } + + if (optind !=3D argc - 1) { + print_usage(progname, stderr); + return EXIT_FAILURE; + } + + filename =3D argv[optind]; + + g_file_get_contents(filename, &buf, &bufsize, &error); + if (error) { + g_printerr("%s: %s\n", progname, error->message); + return EXIT_FAILURE; + } + + if (bufsize > UINT_MAX) { + g_printerr(_("%s: File '%s' is too large\n"), progname, filename); + return EXIT_FAILURE; + } + + crt_data.data =3D (unsigned char *)buf; + crt_data.size =3D bufsize; + + rv =3D gnutls_x509_crt_init(&crt); + if (rv < 0) { + g_printerr(_("Unable to initialize certificate: %s\n"), + gnutls_strerror(rv)); + return EXIT_FAILURE; + } + + rv =3D gnutls_x509_crt_import(crt, &crt_data, GNUTLS_X509_FMT_PEM); + if (rv < 0) { + g_printerr(_("Unable to load certificate, make sure it is in PEM f= ormat: %s\n"), + gnutls_strerror(rv)); + return EXIT_FAILURE; + } + + rv =3D gnutls_x509_crt_get_dn(crt, dname, &dnamesize); + if (rv =3D=3D GNUTLS_E_SHORT_MEMORY_BUFFER) { + dname =3D g_realloc(dname, dnamesize); + rv =3D gnutls_x509_crt_get_dn(crt, dname, &dnamesize); + } + if (rv !=3D 0) { + g_printerr(_("Failed to get distinguished name: %s\n"), + gnutls_strerror(rv)); + return EXIT_FAILURE; + } + + printf("%s\n", dname); + + return EXIT_SUCCESS; +} --=20 2.33.1 From nobody Fri May 3 09:42:10 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1636663052; cv=none; d=zohomail.com; s=zohoarc; b=kVXaLR4lz7rjI2VIwaE3dgVtAKcdUMJ7dcn3WwJLe9iIh0ZH/MqMcg2U+MAgx5bs4wApdUyNwaybipRyYr6WEa35vUW+BlYYZX4S55EW01DCWpn7BXMXlOHbTjR3P83wmbiWUD5bE7016kxDA0CIB2mKLMHQZDhBpqjomwhOxgQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1636663052; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=HpFljb0P5iYY0zqGQmtGa3EdKKNcVfMWFbAVhFr2DRo=; b=OYtujUaoWgvNidoIRVQUhWq8bZAQBvtrLYemNS2XcTc38eV4jChv/1C46hceQ/Kfe8KZeYC81TxTPgPTUdXSgE7yMMPmPTZgxLFKpFT63xMKUzsoM/oDUheqvIe9Qnc69fy5npHhz+0etuTf5E+qeLWQ2VwsxVsooGQbXVjHSSU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 163666305260253.405965907888685; Thu, 11 Nov 2021 12:37:32 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-98-NnN1GeOWN2iMbXzvRoxH3g-1; Thu, 11 Nov 2021 15:37:27 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 46F641030C25; Thu, 11 Nov 2021 20:37:23 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 29A6667849; Thu, 11 Nov 2021 20:37:23 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 9772E4E58F; Thu, 11 Nov 2021 20:37:22 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 1ABKb8I9007086 for ; Thu, 11 Nov 2021 15:37:08 -0500 Received: by smtp.corp.redhat.com (Postfix) id 825D82026D6B; Thu, 11 Nov 2021 20:37:08 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast01.extmail.prod.ext.rdu2.redhat.com [10.11.55.17]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7BEE42026D48 for ; Thu, 11 Nov 2021 20:37:02 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-1.mimecast.com [205.139.110.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id C01A185A5B5 for ; Thu, 11 Nov 2021 20:37:02 +0000 (UTC) Received: from mail-ed1-f72.google.com (mail-ed1-f72.google.com [209.85.208.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-560-cUanGiRNPCOrPt8MvzAdzQ-1; Thu, 11 Nov 2021 15:37:01 -0500 Received: by mail-ed1-f72.google.com with SMTP id w13-20020a05640234cd00b003e2fde5ff8aso6354442edc.14 for ; Thu, 11 Nov 2021 12:37:01 -0800 (PST) Received: from wheatley.localdomain (k8r.cz. [95.82.177.71]) by smtp.gmail.com with ESMTPSA id e13sm1830474eje.95.2021.11.11.12.36.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Nov 2021 12:36:58 -0800 (PST) Received: from wheatley.k8r.cz (wheatley.k8r.cz [127.0.0.1]) by wheatley.localdomain (Postfix) with ESMTP id 576731BCD6D3; Thu, 11 Nov 2021 21:36:58 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1636663051; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=HpFljb0P5iYY0zqGQmtGa3EdKKNcVfMWFbAVhFr2DRo=; b=ViZBZQz99p8ilweClJTsdKkASjQbOi81ovuRHjxacu5I/vTCWI9zYJk9m+Ykx8xq2GGK+m QqlkLLiFbe9zbV1C2FqBvUhuhaimoLxpGn8QKvIf1IkRoSThikC7K6FMbk7jKkV3MuBRTg W2iu2T98Cn2pwkIoJqFOM7iXknHZ64U= X-MC-Unique: NnN1GeOWN2iMbXzvRoxH3g-1 X-MC-Unique: cUanGiRNPCOrPt8MvzAdzQ-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=HpFljb0P5iYY0zqGQmtGa3EdKKNcVfMWFbAVhFr2DRo=; b=hY6cRVzyLVF80eRZ2U9Rka8zu5LtM/X5A8AX6G/C2586Xzli2MFVjCQEJ/jYPnnW5k PfiR6ZNzeZRA3/O1FCMrrgbviywv5biarYTFQUovAsIVespkrLEw6EAOk8+Nw/xi1foB U1BAgMHj/WZBD+QbcpwoL870+6um4YV7+JhYOMmkPywGIlborV5T9Yj2IaZGXpUAUK3n Gw1QT78MkkO1jVXfznOii4TZMpnx765BoQmLZWGRFtU+W6o3cZGFjxGlyskDPkyTDusV S5eoONeFurQUq0qS2KZJDM1Btpbu1pFeW+CS4KfBw+DTQtXwIt09/+dW6fHjqKFTUG+p kIng== X-Gm-Message-State: AOAM532vMNGonKVqDp3/FnKf7C9bjcXh4VhwFx7u0ucmXL9I5W9Rmd8O IzaN/odnI0fPOrXSFZf/bXwvjxBklOsjgXNm++KdEcmUFyBEKkagCw4KIqUKz3Hk7bNz0j0QIO8 wvAO58w1XKtbluixHPiI= X-Received: by 2002:a05:6402:147:: with SMTP id s7mr2287813edu.8.1636663020446; Thu, 11 Nov 2021 12:37:00 -0800 (PST) X-Google-Smtp-Source: ABdhPJx9aNVfO4T5aUWZrlzfgqSzg9TfukeiawK5pvLP8i/U4JjbA4q54ASKPaboEiypjXZEaqKPXw== X-Received: by 2002:a05:6402:147:: with SMTP id s7mr2287781edu.8.1636663020268; Thu, 11 Nov 2021 12:37:00 -0800 (PST) From: Martin Kletzander To: libvir-list@redhat.com Subject: [PATCH v2 2/3] Add suggestions for virt-pki-query-dn usage Date: Thu, 11 Nov 2021 21:36:56 +0100 Message-Id: <6da09569caf0e0a22a5ef8e81e75e0a10e612c33.1636662545.git.mkletzan@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1636663053460100001 To make it easier for users to figure out how the DN should be formatted. Signed-off-by: Martin Kletzander Reviewed-by: Daniel P. Berrang=C3=A9 --- docs/remote.html.in | 4 ++++ src/remote/libvirtd.conf.in | 5 +++++ src/rpc/virnettlscontext.c | 2 +- tests/virconfdata/libvirtd.conf | 4 ++++ tests/virconfdata/libvirtd.out | 4 ++++ 5 files changed, 18 insertions(+), 1 deletion(-) diff --git a/docs/remote.html.in b/docs/remote.html.in index 66f56a3a64fc..efdb2b32535d 100644 --- a/docs/remote.html.in +++ b/docs/remote.html.in @@ -259,6 +259,10 @@ Blank lines and comments beginning with #= are ignored. Note also that GnuTLS returns DNs without spaces after commas between the fields (and this is what we check against), but the openssl x509 tool shows spaces. +

+ To make it easy to see the order of the fields in the DN a helper execut= able + virt-pki-query-dn is provided for this particular use case. +

diff --git a/src/remote/libvirtd.conf.in b/src/remote/libvirtd.conf.in index b18c5885a1a7..2cd20aaa7f52 100644 --- a/src/remote/libvirtd.conf.in +++ b/src/remote/libvirtd.conf.in @@ -292,6 +292,11 @@ # # Any * matches any number of consecutive spaces, like a simplified glob(7= ). # +# The format of the DN for a particular certificate can be queried +# using: +# +# virt-pki-query-dn clientcert.pem +# # NB If this is an empty list, no client can connect, so comment out # entirely rather than using empty list to disable these checks # diff --git a/src/rpc/virnettlscontext.c b/src/rpc/virnettlscontext.c index 3babf3ee4dc3..1a3dd92676f7 100644 --- a/src/rpc/virnettlscontext.c +++ b/src/rpc/virnettlscontext.c @@ -371,7 +371,7 @@ virNetTLSContextCheckCertDNACL(const char *dname, virReportError(VIR_ERR_SYSTEM_ERROR, "%s", _("Client's Distinguished Name is not on the list " "of allowed clients (tls_allowed_dn_list). Use " - "'certtool -i --infile clientcert.pem' to view the " + "'virt-pki-query-dn clientcert.pem' to view the " "Distinguished Name field in the client certificate, " "or run this daemon with --verbose option.")); return 0; diff --git a/tests/virconfdata/libvirtd.conf b/tests/virconfdata/libvirtd.c= onf index f4c35e9e430f..c5a225e42f6f 100644 --- a/tests/virconfdata/libvirtd.conf +++ b/tests/virconfdata/libvirtd.conf @@ -185,6 +185,10 @@ tls_no_verify_certificate =3D 1 # # Any * matches any number of consecutive spaces, like a simplified glob(7= ). # +# The format of the DN for a particular certificate can be queried +# using: +# +# virt-pki-query-dn clientcert.pem # # NB If this is an empty list, no client can connect, so comment out # entirely rather than using empty list to disable these checks diff --git a/tests/virconfdata/libvirtd.out b/tests/virconfdata/libvirtd.out index a407c5f189e9..754bf56ee4dd 100644 --- a/tests/virconfdata/libvirtd.out +++ b/tests/virconfdata/libvirtd.out @@ -149,6 +149,10 @@ tls_no_verify_certificate =3D 1 # # Any * matches any number of consecutive spaces, like a simplified glob(7= ). # +# The format of the DN for a particular certificate can be queried +# using: +# +# virt-pki-query-dn clientcert.pem # # NB If this is an empty list, no client can connect, so comment out # entirely rather than using empty list to disable these checks --=20 2.33.1 From nobody Fri May 3 09:42:10 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1636663039; cv=none; d=zohomail.com; s=zohoarc; b=PSimOSMG05mLMrltapthSbKbQL1Mj9FG+auItlQ+W6n841i074vnfIsBMMM+kS4tdol0oGWNiJ8fE/h45W7aADhk8fZrb1ElyfitE9OBQkjpaYRN+wASNdTqgSsDjbG65BrA8y9jkeiJHwcUsl3ve9hSoEhmNfX5M0acsC3AKNo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1636663039; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=iLYFOPKZhY/hfZC6bjudPZ/bnmjNDEhzj7AOJqjVnb8=; b=C19UZPhjH1Hg/hxoOpPzmp8c8LBemTHUQQUub0LHtMxWtSjD8uGk4nniJUBLLe4+cKX9WqNjW3+t5/gxV6ehtYRCFgKE/fF1bch6CpYq6q2eVBDNJeXlv76rWDBurph3ox/YpHJ9mvFJAxQWgrx4xlUKLNC3C5GpDKNzAx0JIxQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1636663039357755.9944198874095; Thu, 11 Nov 2021 12:37:19 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-519-HOe1zEbhP-KI8IOxToka9Q-1; Thu, 11 Nov 2021 15:37:16 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 752ED100C662; Thu, 11 Nov 2021 20:37:11 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 09BCE5D6B1; Thu, 11 Nov 2021 20:37:10 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id A25124A703; Thu, 11 Nov 2021 20:37:05 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 1ABKb3vH007052 for ; Thu, 11 Nov 2021 15:37:03 -0500 Received: by smtp.corp.redhat.com (Postfix) id 4421940CFD0F; Thu, 11 Nov 2021 20:37:03 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast04.extmail.prod.ext.rdu2.redhat.com [10.11.55.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3F74A40CFD04 for ; Thu, 11 Nov 2021 20:37:03 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-2.mimecast.com [205.139.110.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 286E61066681 for ; Thu, 11 Nov 2021 20:37:03 +0000 (UTC) Received: from mail-ed1-f72.google.com (mail-ed1-f72.google.com [209.85.208.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-562-z3EYoEMWNMa63RDjF0uZFQ-1; Thu, 11 Nov 2021 15:37:01 -0500 Received: by mail-ed1-f72.google.com with SMTP id h15-20020a056402094f00b003e51ef806a9so2201859edz.6 for ; Thu, 11 Nov 2021 12:37:01 -0800 (PST) Received: from wheatley.localdomain (k8r.cz. [95.82.177.71]) by smtp.gmail.com with ESMTPSA id q7sm109769edr.9.2021.11.11.12.36.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Nov 2021 12:36:58 -0800 (PST) Received: from wheatley.k8r.cz (wheatley.k8r.cz [127.0.0.1]) by wheatley.localdomain (Postfix) with ESMTP id 62D731BCD6D4; Thu, 11 Nov 2021 21:36:58 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1636663038; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=iLYFOPKZhY/hfZC6bjudPZ/bnmjNDEhzj7AOJqjVnb8=; b=gDNufIaTWp4AaZ51g16mZ9HbvfFwN3DkXGRYWLNwgdpJfZTwryjF+/6nAj+4jlqcfXRTm4 em2QM3q71Xx40wOlX0thYMRD56MAwoMfxHsNwFsqEERLDniCUP2D9PxIjmx2DPNEGufeC1 Y5MVHaAwR0pDVxSf/LMdrpwmsY5DPHk= X-MC-Unique: HOe1zEbhP-KI8IOxToka9Q-1 X-MC-Unique: z3EYoEMWNMa63RDjF0uZFQ-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=iLYFOPKZhY/hfZC6bjudPZ/bnmjNDEhzj7AOJqjVnb8=; b=AjJeb4KzluhI6pABYzPBh7aoZCj5+M3nhHfvFNYlGa40v1SG0SrgiJD2w2ZpwhzRIE BL9SvCj8NuB1IiN5PFvEmG8sQdi8NhEukaCnHm1al3+IuzGn49IyfEy2YpeAvVX3pEv9 sJ0J4l3hbHq+guPDO/M2niRoK30/Oocrk5J+2yQ4Kke/V7swdqOhIJvg6IGK5En3sD0o C3UzfZcm5acHD7Bq0JElsgVoJnjLCWMcC3YTq2jo7LAYMkK9lJ0nGBt06+vLUDAh+vbZ MSuHcG87HKBzSCzlKSWEsDUOtlAjl2aaWxIA/3sXcNnbKGdD6yZvDSFKi+kgvzENryep UXkg== X-Gm-Message-State: AOAM5314QdXRz/q1bq8YN0a3dxpxBLj6TjrzAP8FuPpz53fMgQ5kVBEP Et5xHMYxl3FlEGeD5wUurabAnbqoxDfqw+6/mb8GpeesVgJK7KIKHMtjBzjBfkoOMHVFG67F7cy 4jedp1Q6UgzKKJ01chMI= X-Received: by 2002:aa7:cb41:: with SMTP id w1mr13827151edt.327.1636663020720; Thu, 11 Nov 2021 12:37:00 -0800 (PST) X-Google-Smtp-Source: ABdhPJzEAFtqpqT4wZAXsfhJ0DeMwwBmglqSXj3WXjn42lmHO1urILmsqK1MreQR4xr53wwvAVtlNg== X-Received: by 2002:aa7:cb41:: with SMTP id w1mr13827126edt.327.1636663020558; Thu, 11 Nov 2021 12:37:00 -0800 (PST) From: Martin Kletzander To: libvir-list@redhat.com Subject: [PATCH v2 3/3] news: Mention the addition of virt-pki-query-dn binary Date: Thu, 11 Nov 2021 21:36:57 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.11.54.1 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1636663040019100001 Signed-off-by: Martin Kletzander Reviewed-by: Daniel P. Berrang=C3=A9 --- NEWS.rst | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/NEWS.rst b/NEWS.rst index 983153a63123..a71b84c36390 100644 --- a/NEWS.rst +++ b/NEWS.rst @@ -17,6 +17,12 @@ v7.10.0 (unreleased) =20 * **New features** =20 + * Added virt-pki-query-dn binary + + This binary helps users figure out the format of Distinguished Name + from a certificate file the way that libvirt expects it in + tls_allowed_dn_list option of libvirtd.conf configuration file + * **Improvements** =20 * qemu: Report guest interface information in ``virDomainGetGuestInfo`` --=20 2.33.1