From patchwork Tue Apr 5 19:33:48 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Bligh X-Patchwork-Id: 8754741 Return-Path: X-Original-To: patchwork-qemu-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id A2D85C0553 for ; Tue, 5 Apr 2016 19:34:04 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 0192420154 for ; Tue, 5 Apr 2016 19:34:04 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id DCC6420383 for ; Tue, 5 Apr 2016 19:34:02 +0000 (UTC) Received: from localhost ([::1]:38932 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1anWji-0008TE-3E for patchwork-qemu-devel@patchwork.kernel.org; Tue, 05 Apr 2016 15:34:02 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58090) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1anWja-0008QU-Cq for qemu-devel@nongnu.org; Tue, 05 Apr 2016 15:33:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1anWjV-0002ko-D3 for qemu-devel@nongnu.org; Tue, 05 Apr 2016 15:33:54 -0400 Received: from mail.avalus.com ([89.16.176.221]:38552) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1anWjV-0002kc-6P for qemu-devel@nongnu.org; Tue, 05 Apr 2016 15:33:49 -0400 Received: by mail.avalus.com (Postfix) with ESMTPSA id 958D332A6005; Tue, 5 Apr 2016 20:33:45 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=alex.org.uk; s=mail; t=1459884825; bh=WDbTw/JD9OJ0IeiYX7MV9CqheKkKd6c9zSJaQbyKF18=; h=From:To:Cc:Subject:Date; b=CXYHpmHlxUsTpR7Z7Pm0QtC2jusFcb1TnX9QqH4wq2NCQvn8v5GSlIdhfSlLD4tu0 IQ426Q4NtuaagBNP+GM24adpgcj2bjQfBe3luWs23VIPXZ7e79hYsTaL2Lgp0YYnNC rMTVvjKQjRzQG54bax11UqZYT6xh1hh5nxgpTP+0= From: Alex Bligh To: "Daniel P. Berrange" , Paolo Bonzini , Kevin Wolf , Eric Blake , "qemu-devel@nongnu.org" Date: Tue, 5 Apr 2016 20:33:48 +0100 Message-Id: <1459884828-25902-1-git-send-email-alex@alex.org.uk> X-Mailer: git-send-email 1.9.1 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 89.16.176.221 Cc: Wouter Verhelst , Alex Bligh Subject: [Qemu-devel] [PATCH] TLS: provide slightly more information when TLS certificate loading fails X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Give slightly more information when certification loading fails. Rather than have no information, you now get gnutls's only slightly less unhelpful error messages. Signed-off-by: Alex Bligh --- crypto/tlscredsx509.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/crypto/tlscredsx509.c b/crypto/tlscredsx509.c index 6a0179c..520d34d 100644 --- a/crypto/tlscredsx509.c +++ b/crypto/tlscredsx509.c @@ -392,11 +392,14 @@ qcrypto_tls_creds_load_cert(QCryptoTLSCredsX509 *creds, gsize buflen; GError *gerr; int ret = -1; + int err; trace_qcrypto_tls_creds_x509_load_cert(creds, isServer, certFile); - if (gnutls_x509_crt_init(&cert) < 0) { - error_setg(errp, "Unable to initialize certificate"); + err = gnutls_x509_crt_init(&cert); + if (err < 0) { + error_setg(errp, "Unable to initialize certificate: %s", + gnutls_strerror(err)); goto cleanup; } @@ -410,11 +413,13 @@ qcrypto_tls_creds_load_cert(QCryptoTLSCredsX509 *creds, data.data = (unsigned char *)buf; data.size = strlen(buf); - if (gnutls_x509_crt_import(cert, &data, GNUTLS_X509_FMT_PEM) < 0) { + err = gnutls_x509_crt_import(cert, &data, GNUTLS_X509_FMT_PEM); + if (err < 0) { error_setg(errp, isServer ? - "Unable to import server certificate %s" : - "Unable to import client certificate %s", - certFile); + "Unable to import server certificate %s: %s" : + "Unable to import client certificate %s: %s", + certFile, + gnutls_strerror(err)); goto cleanup; }