From: "Daniel P. Berrange" <berrange@redhat.com>
To: Eric Blake <eblake@redhat.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>,
qemu-devel@nongnu.org, Gerd Hoffmann <kraxel@redhat.com>
Subject: Re: [Qemu-devel] [PATCH v5 6/9] crypto: add sanity checking of TLS x509 credentials
Date: Thu, 27 Aug 2015 09:48:02 +0100 [thread overview]
Message-ID: <20150827084802.GB24486@redhat.com> (raw)
In-Reply-To: <55DE354C.3000401@redhat.com>
On Wed, Aug 26, 2015 at 03:53:16PM -0600, Eric Blake wrote:
> On 08/26/2015 09:05 AM, Daniel P. Berrange wrote:
> > If the administrator incorrectly sets up their x509 certificates,
> > the errors seen at runtime during connection attempts are very
> > obscure and difficult to diagnose. This has been a particular
> > problem for people using openssl to generate their certificates
> > instead of the gnutls certtool, because the openssl tools don't
> > turn on the various x509 extensions that gnutls expects to be
> > present by default.
> >
> > This change thus adds support in the TLS credentials object to
> > sanity check the certificates when QEMU first loads them. This
> > gives the administrator immediate feedback for the majority of
> > common configuration mistakes, reducing the pain involved in
> > setting up TLS. The code is derived from equivalent code that
> > has been part of libvirt's TLS support and has been seen to be
> > valuable in assisting admins.
> >
> > It is possible to disable the sanity checking, however, via
> > the new 'sanity-check' property on the tls-creds object type,
> > with a value of 'no'.
> >
> > Unit tests are included in this change to verify the correctness
> > of the sanity checking code in all the key scenarios it is
> > intended to cope with. As part of the test suite, the pkix_asn1_tab.c
> > from gnutls is imported. This file is intentionally copied from the
> > (long since obsolete) gnutls 1.6.3 source tree, since that version
> > was still under GPLv2+, rather than the GPLv3+ of gnutls >= 2.0.
> >
> > Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
> > ---
>
> > +++ b/crypto/tlscredsx509.c
> > @@ -38,6 +38,514 @@
>
>
> > +static int
> > +qcrypto_tls_creds_check_cert_pair(gnutls_x509_crt_t cert,
> > + const char *certFile,
> > + gnutls_x509_crt_t *cacerts,
> > + size_t ncacerts,
> > + const char *cacertFile,
> > + bool isServer,
> > + Error **errp)
> > +{
>
> > + if (status != 0) {
> > + const char *reason = "Invalid certificate";
> > +
> > + if (status & GNUTLS_CERT_INVALID) {
> > + reason = "The certificate is not trusted.";
> > + }
> > +
> > + if (status & GNUTLS_CERT_SIGNER_NOT_FOUND) {
> > + reason = "The certificate hasn't got a known issuer.";
> > + }
> > +
> > + if (status & GNUTLS_CERT_REVOKED) {
> > + reason = "The certificate has been revoked.";
>
> The trailing dots seem unusual here, since most of your code doesn't
> have them.
>
>
> > +++ b/tests/crypto-tls-x509-helpers.c
>
>
> > +void
> > +test_tls_generate_cert(QCryptoTLSTestCertReq *req,
> > + gnutls_x509_crt_t ca)
> > +{
> > + gnutls_x509_crt_t crt;
> > + int err;
> > + static char buffer[1024*1024];
>
> Space around operator '*'
>
> > + size_t size = sizeof(buffer);
> > + char serial[5] = { 1, 2, 3, 4, 0 };
> > + gnutls_datum_t der;
> > + time_t start = time(NULL) + (60*60*req->start_offset);
> > + time_t expire = time(NULL) + (60*60*(req->expire_offset
>
> and again
>
> > +++ b/tests/pkix_asn1_tab.c
> > @@ -0,0 +1,1103 @@
> > +/*
> > + * This file is taken from gnutls 1.6.3 under the GPLv2+
> > + */
>
> Is this missing a copyright statement? Even if gnutls 1.6.3 didn't
> mention copyright per-file, it might be nice to mention the copyright
> owner of the overall release of that old tarball.
The original gnutls file didn't have any header at all, so I added
the mention that it was GPLv2+ per the global gnutls license file.
I didn't put any Copyright as it was not clear who exactly it add.
I guess the answer might lie in gnutls git history somewhere if
you think that's important.
Regards,
Daniel
--
|: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org -o- http://virt-manager.org :|
|: http://autobuild.org -o- http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|
next prev parent reply other threads:[~2015-08-27 8:48 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-08-26 15:05 [Qemu-devel] [PATCH v5 0/9] Extract TLS handling code from VNC server Daniel P. Berrange
2015-08-26 15:05 ` [Qemu-devel] [PATCH v5 1/9] qapi: allow override of default enum prefix naming Daniel P. Berrange
2015-08-26 15:22 ` Eric Blake
2015-08-27 11:04 ` Daniel P. Berrange
2015-08-26 15:05 ` [Qemu-devel] [PATCH v5 2/9] make: ensure all members of libqemuutil.a are linked Daniel P. Berrange
2015-08-26 15:25 ` Eric Blake
2015-08-26 15:42 ` Daniel P. Berrange
2015-08-26 15:05 ` [Qemu-devel] [PATCH v5 3/9] crypto: introduce new base module for TLS credentials Daniel P. Berrange
2015-08-26 16:56 ` Eric Blake
2015-08-26 15:05 ` [Qemu-devel] [PATCH v5 4/9] crypto: introduce new module for TLS anonymous credentials Daniel P. Berrange
2015-08-26 21:22 ` Eric Blake
2015-08-26 15:05 ` [Qemu-devel] [PATCH v5 5/9] crypto: introduce new module for TLS x509 credentials Daniel P. Berrange
2015-08-26 21:32 ` Eric Blake
2015-08-26 15:05 ` [Qemu-devel] [PATCH v5 6/9] crypto: add sanity checking of " Daniel P. Berrange
2015-08-26 21:53 ` Eric Blake
2015-08-27 8:48 ` Daniel P. Berrange [this message]
2015-08-26 15:05 ` [Qemu-devel] [PATCH v5 7/9] crypto: introduce new module for handling TLS sessions Daniel P. Berrange
2015-08-27 14:33 ` Eric Blake
2015-08-28 13:14 ` Daniel P. Berrange
2015-08-26 15:05 ` [Qemu-devel] [PATCH v5 8/9] ui: fix return type for VNC I/O functions to be ssize_t Daniel P. Berrange
2015-08-28 21:08 ` Eric Blake
2015-08-26 15:05 ` [Qemu-devel] [PATCH v5 9/9] ui: convert VNC server to use QCryptoTLSSession Daniel P. Berrange
2015-09-01 15:08 ` Eric Blake
2015-09-02 11:06 ` Daniel P. Berrange
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20150827084802.GB24486@redhat.com \
--to=berrange@redhat.com \
--cc=eblake@redhat.com \
--cc=kraxel@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.