From patchwork Fri Jan 18 23:34:00 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steffan Karger X-Patchwork-Id: 665 Return-Path: Delivered-To: patchwork@openvpn.net Delivered-To: patchwork@openvpn.net Received: from director8.mail.ord1d.rsapps.net ([172.31.255.6]) by backend30.mail.ord1d.rsapps.net with LMTP id iCCOI079QlxzWQAAIUCqbw for ; Sat, 19 Jan 2019 05:34:54 -0500 Received: from proxy11.mail.iad3b.rsapps.net ([172.31.255.6]) by director8.mail.ord1d.rsapps.net with LMTP id iDDHIE79QlxTKQAAfY0hYg ; Sat, 19 Jan 2019 05:34:54 -0500 Received: from smtp15.gate.iad3b ([172.31.255.6]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by proxy11.mail.iad3b.rsapps.net with LMTP id GAHvGk79QlzNLAAARNREpw ; Sat, 19 Jan 2019 05:34:54 -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: smtp15.gate.iad3b.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-Suspicious-Flag: YES X-Classification-ID: db40155c-1bd5-11e9-b270-5254003d6d3a-1-1 Received: from [216.105.38.7] ([216.105.38.7:43447] helo=lists.sourceforge.net) by smtp15.gate.iad3b.rsapps.net (envelope-from ) (ecelerity 4.2.38.62370 r(:)) with ESMTPS (cipher=DHE-RSA-AES256-GCM-SHA384) id 02/CD-26175-D4DF24C5; Sat, 19 Jan 2019 05:34:54 -0500 Received: from [127.0.0.1] (helo=sfs-ml-2.v29.lw.sourceforge.com) by sfs-ml-2.v29.lw.sourceforge.com with esmtp (Exim 4.90_1) (envelope-from ) id 1gknxA-0002Wm-Po; Sat, 19 Jan 2019 10:34:16 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-2.v29.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.90_1) (envelope-from ) id 1gknx6-0002WT-DD for openvpn-devel@lists.sourceforge.net; Sat, 19 Jan 2019 10:34:12 +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=zl4kdB9nuZfbxSgw2W5h1x2tTy1CfcbydexR529MFTA=; b=NexG8sniJhh8URRWF3/HT5e1cO TBB6khYzouJpXC3d3LbqJAPFMEBoL68qTRK/S/zXIrmlHSLwLTrIcWaMF3WornkGY9SQdh5Nd8X+s EKlZkvPHWDWiuprN+UVjX0v9jzmfCQ2yGFh9T7g6nJXPj9enCyxWmKQcIF1Lu3vhEWXI=; 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=zl4kdB9nuZfbxSgw2W5h1x2tTy1CfcbydexR529MFTA=; b=PntgJbA/kEvo9voEqWLqHwg4S3 DBQUID45qWCAz3/G3Ruz+yGthTN60obSnxFbk5d6woWuMA40LMvT0iF/QZywyTCYKZXIxaWK8TlvR nYoE55mnL3eUcPAobHFwZKhsVy9ZTnQjXhFgt5Ak1KNwpCIgVFxK7Y5kzsG0k9qVIV+s=; Received: from mail-ed1-f68.google.com ([209.85.208.68]) by sfi-mx-1.v28.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.90_1) id 1gknx4-0001kI-QT for openvpn-devel@lists.sourceforge.net; Sat, 19 Jan 2019 10:34:12 +0000 Received: by mail-ed1-f68.google.com with SMTP id y20so13063862edw.9 for ; Sat, 19 Jan 2019 02:34:10 -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=zl4kdB9nuZfbxSgw2W5h1x2tTy1CfcbydexR529MFTA=; b=k2/uXChaBKH8RY0m0SxCc/196DWhbxwVMFEAfyrPXR0NFhaR9/sShHRIAEp9WHF9cu MzGPsi4iPF7nj4oVyoYjJX/YIhbVhc9GwCgmc40tnZol5kWaNNoeVPDwlJ8KLPLW34ZX Pi+JvOhvp36f4FEoSbHlbPDI165NylTS8W0BXhwHTjwi6L8SJPlshNmd0pkOGsP/09Xq t3+URC0ClyLKVjrZqeZIVKadVuydwkw7T0jZIrb/5a5UgQnNNS4Ptw3kL5P7itess98s KM7JZJZSjTCaap6YrCOd/ehFbg5FZ3i5Kjt7Wf97IXNLOrY+6TEpf8ak/zCm36lriJGZ p8XQ== 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=zl4kdB9nuZfbxSgw2W5h1x2tTy1CfcbydexR529MFTA=; b=JNu25821PY7/xHwMchLDBRhgUgxaslQIdUFZVFM7RZE+LbpO37zHWHKpn1x4UTXlbH 16eheQCf6FNFMKoUctBoM1L1fEFvq4OEIoF4bKJFdaDpdhQbHtAVwGx6X7Sl80hfGS3X Tzrd9UBahkvVO4NRBBwW/jzBZA2aVmNz22hkukA0zRZetoMLCVqNyWsxcrc1NBjw1IET bsff6J3ZMPEZoGzqoF0NQ2frk6DoVg0aJSp/JNYMtE5LT6MTamRfQnO2nSQ1LFvlUVzn fm1UaHNWiq6Ff50w4fKNlqZl0KS0zHzMwYyl5xPvAmsmkHTBpnn9+0MfcW7o7aeVMS2r DzMA== X-Gm-Message-State: AJcUukcAW0ihLMI7MF+ZTSDrlqPeE79apgYVOXkA5L5a2V/Kn+DpLLoY Aw1zRYkd9fyNcT2NSGTfBOJ2xJyc8i0= X-Google-Smtp-Source: ALg8bN5cPZ2u2Zz/salVK+hMlQbWYfpZ4jC+a7nclFsJNtAS/8aFJZAVuS2tqDMxcGTX0cUAj00kdA== X-Received: by 2002:a17:906:b893:: with SMTP id hb19-v6mr17083194ejb.76.1547894043910; Sat, 19 Jan 2019 02:34:03 -0800 (PST) Received: from syzzer-tweakbak.fritz.box ([2001:985:e54:1:881e:647d:3c8e:6ee4]) by smtp.gmail.com with ESMTPSA id f20sm8216382edf.19.2019.01.19.02.34.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 19 Jan 2019 02:34:03 -0800 (PST) From: Steffan Karger To: openvpn-devel@lists.sourceforge.net Date: Sat, 19 Jan 2019 11:34:00 +0100 Message-Id: <20190119103400.12887-1-steffan@karger.me> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190119103028.12497-1-steffan@karger.me> References: <20190119103028.12497-1-steffan@karger.me> X-Spam-Report: Spam Filtering performed by mx.sourceforge.net. See http://spamassassin.org/tag/ for more details. -0.0 RCVD_IN_MSPIKE_H2 RBL: Average reputation (+2) [209.85.208.68 listed in wl.mailspike.net] -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [209.85.208.68 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.0 DKIMWL_WL_MED DKIMwl.org - Whitelisted Medium sender X-Headers-End: 1gknx4-0001kI-QT Subject: [Openvpn-devel] [PATCH v2] Fix tls-auth/crypt in connection blocks with --persist-key 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-getmail-retrieved-from-mailbox: Inbox If --persist-key was used, we would always try to pre-load the 'global' tls-auth/crypt file. That would result in using the wrong key (leading to a failed connection) or en error is there was to 'global' key: Sat Jan 19 11:09:01 2019 Cannot pre-load tls-auth keyfile ((null)) Sat Jan 19 11:09:01 2019 Exiting due to fatal error Fix that by loading loading the key from the current connection entry. Signed-off-by: Steffan Karger Acked-By: Arne Schabe --- v2: Also fix tls-crypt, not just tls-auth. src/openvpn/options.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/openvpn/options.c b/src/openvpn/options.c index 0cf8db767..bebd30059 100644 --- a/src/openvpn/options.c +++ b/src/openvpn/options.c @@ -2863,11 +2863,11 @@ options_postprocess_mutate_ce(struct options *o, struct connection_entry *ce) { if (ce->tls_auth_file && !ce->tls_auth_file_inline) { - struct buffer in = buffer_read_from_file(o->tls_auth_file, &o->gc); + struct buffer in = buffer_read_from_file(ce->tls_auth_file, &o->gc); if (!buf_valid(&in)) { msg(M_FATAL, "Cannot pre-load tls-auth keyfile (%s)", - o->tls_auth_file); + ce->tls_auth_file); } ce->tls_auth_file = INLINE_FILE_TAG; @@ -2876,11 +2876,11 @@ options_postprocess_mutate_ce(struct options *o, struct connection_entry *ce) if (ce->tls_crypt_file && !ce->tls_crypt_inline) { - struct buffer in = buffer_read_from_file(o->tls_crypt_file, &o->gc); + struct buffer in = buffer_read_from_file(ce->tls_crypt_file, &o->gc); if (!buf_valid(&in)) { msg(M_FATAL, "Cannot pre-load tls-crypt keyfile (%s)", - o->tls_auth_file); + ce->tls_crypt_file); } ce->tls_crypt_file = INLINE_FILE_TAG;