From patchwork Thu Mar 8 09:08:48 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steffan Karger X-Patchwork-Id: 267 Return-Path: Delivered-To: patchwork@openvpn.net Delivered-To: patchwork@openvpn.net Received: from director7.mail.ord1d.rsapps.net ([172.30.191.6]) by backend30.mail.ord1d.rsapps.net (Dovecot) with LMTP id zaMiBLOYoVofMgAAIUCqbw for ; Thu, 08 Mar 2018 15:10:27 -0500 Received: from proxy13.mail.ord1d.rsapps.net ([172.30.191.6]) by director7.mail.ord1d.rsapps.net (Dovecot) with LMTP id 7cveDbOYoVo3EgAAovjBpQ ; Thu, 08 Mar 2018 15:10:27 -0500 Received: from smtp36.gate.ord1d ([172.30.191.6]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by proxy13.mail.ord1d.rsapps.net with LMTP id gGAvE7OYoVpiPAAAgjf6aA ; Thu, 08 Mar 2018 15:10:27 -0500 X-Spam-Threshold: 95 X-Spam-Score: 0 X-Spam-Flag: NO X-Virus-Scanned: OK X-Orig-To: openvpnslackdevel@openvpn.net X-Originating-Ip: [216.105.38.7] Authentication-Results: smtp36.gate.ord1d.rsapps.net; iprev=pass policy.iprev="216.105.38.7"; spf=pass smtp.mailfrom="openvpn-devel-bounces@lists.sourceforge.net" smtp.helo="lists.sourceforge.net"; dkim=fail (signature verification failed) header.d=sourceforge.net; dkim=fail (signature verification failed) header.d=sf.net; dkim=fail (signature verification failed) header.d=karger-me.20150623.gappssmtp.com; dmarc=none (p=nil; dis=none) header.from=karger.me X-Classification-ID: bd219bb2-230c-11e8-ad78-525400c11307-1-1 Received: from [216.105.38.7] ([216.105.38.7:15061] helo=lists.sourceforge.net) by smtp36.gate.ord1d.rsapps.net (envelope-from ) (ecelerity 4.2.1.56364 r(Core:4.2.1.14)) with ESMTPS (cipher=DHE-RSA-AES256-GCM-SHA384) id 98/89-29044-2B891AA5; Thu, 08 Mar 2018 15:10:26 -0500 Received: from [127.0.0.1] (helo=sfs-ml-4.v29.lw.sourceforge.com) by sfs-ml-4.v29.lw.sourceforge.com with esmtp (Exim 4.90_1) (envelope-from ) id 1eu1qa-0004Pk-NR; Thu, 08 Mar 2018 20:09:04 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-4.v29.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.90_1) (envelope-from ) id 1eu1qZ-0004PP-6L for openvpn-devel@lists.sourceforge.net; Thu, 08 Mar 2018 20:09:03 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=References:In-Reply-To:Message-Id:Date:Subject:Cc: To:From:Sender:Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=UPsUpM/d4xmPzoR6/7iTP5NPtPbNKxKHOlrHel17W7k=; b=SRNDusA3cB4g480hQM1GrMzYf7 fViRzdHrKEbzi+3zL2Cwh1cGM9Opb9gOcB6IsfDe3ke7HkKXv62jZPwTySNShUT9Ocs3hTpTd9Pfd 9V4JsBHjFVohd7JZpzzUNe5pEcqtszw3V5Itn/UribIhxyWOTJ+WjpKD8CwDfLsx0ZGY=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To :MIME-Version:Content-Type:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=UPsUpM/d4xmPzoR6/7iTP5NPtPbNKxKHOlrHel17W7k=; b=P81MUaPJEwoep0OH492ejbCk3+ 8jv781sUuU/idpzKBvvSYEDYAa1dQE5EvlC4PtaPu/cU/X5r9E9ie6vxTd2FrXqXmcEbGq+PldV0q zeIeCMOS/DfBJ1MIXOhSOY/kZmrpRhTKaZTIOdvG5mABhvpFbOFXF9ptRWvN0uH3S8S4=; Received: from sfi-lb-mx.v20.lw.sourceforge.com ([172.30.20.201] helo=mail-wm0-f46.google.com) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.90_1) id 1eu1qW-005ioA-8A for openvpn-devel@lists.sourceforge.net; Thu, 08 Mar 2018 20:09:03 +0000 Received: by mail-wm0-f46.google.com with SMTP id t6so41502wmt.5 for ; Thu, 08 Mar 2018 12:09:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=karger-me.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=UPsUpM/d4xmPzoR6/7iTP5NPtPbNKxKHOlrHel17W7k=; b=BQghUE5LrZi+d6yX6DwepT3G4kJ1QjsdV8zwu9hNqKWUTIQxce3hiO1ApHIre0mTlx oIGWTynQdMu3VetXV9iIcJTm0+jgw3Fu2A19W9B9g07ASwtOiS/gFyBG/jlGbpzfOwla 5Ze5rj2ScQdGZJiRB+X7/cE+4UFusR8phqWeBJH6mpg7esluax79GMeN1mxDgQvlrKfx sTEwlmh3+h3GlAFrhFKHd91rVllrzbYrzMpbDxfYkiUPuFqSeyOUBpvdZhylhYQzsKPV ea9kjw0dFUts4WvgtRdXbK2nxO2J9NyvZIOV067GL/Zd/kRlaoUmfpTwOPTnes4iHssi CNsA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=UPsUpM/d4xmPzoR6/7iTP5NPtPbNKxKHOlrHel17W7k=; b=Cd2h5YR50Mo2zi+kfITIfLKNAEDmzxH9D2UIowruG6IvR+RMcdH+ttKyU1jFLUrVnz 6jsC3S4/Gf0YtlbXcypAMna7HxzV8GBUSrHQOvF0TGUZCZGIOera4zY5EhiuiPCW1K2D YtxKeCsn0spp6ZpX0WNDdcGuOP2EAGW1cysN+hO4Ek8RyrIJuViZAf4+2suMGXcW6b2n KooxToJOTGNsuu1hLbEwD6/EkLjDEhJfbZbKOlH4bkTp7KkpxL36gICLIUx1eHzvSj2j q3ie+VvlPDBO1+LlIPbj6MoGRRYmuAuplFihFNgSzo/F1MAOScGsQkFJBHmg3COjw5q3 g68w== X-Gm-Message-State: APf1xPBEycvtHFS4zi9UtVJYWtUj6tbjpJBOt/wxmMPEoMPQxIbW1efn s9/Ttd1Pc4n9QFGA4Lqtlu2+AQdNPRk= X-Google-Smtp-Source: AG47ELtXmvPumqmqEmOezU2qUfIWlPXJLN1541IABLJ9qqvcbx2ZOzKta4woqbSEeOUaETnOcgsKsQ== X-Received: by 10.80.164.3 with SMTP id u3mr34439324edb.282.1520539733683; Thu, 08 Mar 2018 12:08:53 -0800 (PST) Received: from vesta.fritz.box ([2001:985:e54:1:99cf:be5f:7efd:47d1]) by smtp.gmail.com with ESMTPSA id h21sm1741941edb.47.2018.03.08.12.08.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 08 Mar 2018 12:08:53 -0800 (PST) From: Steffan Karger To: openvpn-devel@lists.sourceforge.net Date: Thu, 8 Mar 2018 21:08:48 +0100 Message-Id: <20180308200848.5908-1-steffan@karger.me> X-Mailer: git-send-email 2.14.1 In-Reply-To: References: X-Spam-Report: Spam Filtering performed by mx.sourceforge.net. See http://spamassassin.org/tag/ for more details. 1.0 SPF_SOFTFAIL SPF: sender does not match SPF record (softfail) 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.2 AWL AWL: Adjusted score from AWL reputation of From: address X-Headers-End: 1eu1qW-005ioA-8A Subject: [Openvpn-devel] [PATCH] Improve management-external-key/cert error handling X-BeenThere: openvpn-devel@lists.sourceforge.net X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: openvpn-devel-bounces@lists.sourceforge.net X-Suspicious-Flag: YES X-getmail-retrieved-from-mailbox: Inbox Check the return values of management_query_cert() and tls_ctx_use_external_private_key(), and error out with a more descriptive error message. To do so, we make the openssl-backed implementation of tls_ctx_use_external_private_key() not throw fatal error anymore. (And fix line wrapping while touching this code.) Signed-off-by: Steffan Karger --- v2: error out with M_FATAL as suggested by Selva. src/openvpn/ssl.c | 28 ++++++++++++++++++++-------- src/openvpn/ssl_openssl.c | 2 +- 2 files changed, 21 insertions(+), 9 deletions(-) diff --git a/src/openvpn/ssl.c b/src/openvpn/ssl.c index 1756f8a2..1882db52 100644 --- a/src/openvpn/ssl.c +++ b/src/openvpn/ssl.c @@ -660,18 +660,30 @@ init_ssl(const struct options *options, struct tls_root_ctx *new_ctx) else if ((options->management_flags & MF_EXTERNAL_KEY) && (options->cert_file || options->management_flags & MF_EXTERNAL_CERT)) { - if (options->cert_file) + if (options->cert_file + && 0 != tls_ctx_use_external_private_key(new_ctx, + options->cert_file, + options->cert_file_inline)) { - tls_ctx_use_external_private_key(new_ctx, options->cert_file, - options->cert_file_inline); + msg(M_FATAL, "Failed to initialize management-external-key"); } else { - char *external_certificate = management_query_cert(management, - options->management_certificate); - tls_ctx_use_external_private_key(new_ctx, external_certificate, - true); - free(external_certificate); + char *external_cert = management_query_cert( + management, options->management_certificate); + + if (!external_cert) + { + msg(M_FATAL, "Failed to initialize management-external-cert"); + } + + if (0 != tls_ctx_use_external_private_key(new_ctx, external_cert, + true)) + { + msg(M_FATAL, "Failed to initialize management-external-key"); + } + + free(external_cert); } } #endif diff --git a/src/openvpn/ssl_openssl.c b/src/openvpn/ssl_openssl.c index 66d98c54..87f67680 100644 --- a/src/openvpn/ssl_openssl.c +++ b/src/openvpn/ssl_openssl.c @@ -1327,7 +1327,7 @@ tls_ctx_use_external_private_key(struct tls_root_ctx *ctx, return 0; err: - crypto_msg(M_FATAL, "Cannot enable SSL external private key capability"); + crypto_msg(M_WARN, "Cannot enable SSL external private key capability"); return 1; }