From patchwork Thu Dec 3 09:55:58 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gert Doering X-Patchwork-Id: 5839 Return-Path: Delivered-To: patchwork@openvpn.net Received: by 2002:a05:6022:91c9:10b0:11b:d6c:f273 with SMTP id tl9-n1csp17536966lad; Thu, 3 Dec 2026 01:56:17 -0800 (PST) X-Forwarded-Encrypted: i=2; AL+hErHiCfuynnjW4GGdMo4cAKhOPH0lPMLdnTysfRIsNBqE1/39LGzr3txpwm7CgE9xTstab3TzB3LdkQQ=@openvpn.net X-Received: by 2002:a05:693c:41c5:20b0:387:44b0:947c with SMTP id 5a478bee46e88-38744b09b1bmr1138916eec.42.1796291776839; Thu, 03 Dec 2026 01:56:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1796291776; cv=none; d=google.com; s=arc-20260327; b=Vsx8dyPyXc+A8xRcfU2FZAt5OujW9VGcKKw0uKq3vWmChLttr6iN1BQd4E4mcYlTzq JT4HG8n13uFUBzcW5ePACvyZsTBe6U0Oya6a5abh8GMrLCRITIF9qq//ybmyWLuHZ5JV BpiS9SXTQ8vu1mxNhEWebt+J8AZ98OmMArakUgCGqpg8c8Q5gi5NjW9XBU6oZ/b31yTO ItqC67zA/wZG5KAZDtMwxWQmOhHrOtjZ46ys1Ss/tg8JQUX3k6YbkAhRAnuYth7Jpkuz PAVPwNzyIWJICuMeZ6xzlPRJb8Lif8pBMTxfHS+M7SQvVibQuunr8qy24vpImiyrBMvW F36g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20260327; h=errors-to:content-transfer-encoding:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence:subject :mime-version:references:in-reply-to:message-id:date:to:from :dkim-signature:dkim-signature:dkim-signature; bh=MOgSuI68zv2bXAtkD4QG/GEL8rKyuFwQKnud/bOAe2U=; fh=4NbAC/LsuMLI0S0hprUlLSLCiHwg6SCAifhH718Jh0Q=; b=p4FIz5kG3z4VYXLhYrl+BMzyMTLjLCxwT8XrhxzwdjlhBj0s6/xhOAxESCyTsfffdz yI0NBslzgtYU80xUCUqjfpsuMT5+aEIg9sM/8PuJHjeCzmV4SKTaseLjCarBcEJ8nxDV VkJ+5w6hmMHEW3n1tMTsQDStenzyYV8Yz7BAH32DosFA/JykFb/cXkZEGIgXoem4q+Tz QCGpjvfaSVqymQMigm088CJEkQ/JeqjIBdKcmbdi3E/EpFY/mRlEccsbg40+pXTWZCSD v0uo9143V0yh+RS+IFq4mBNLKeSZvYtZjA1nlzTTE+I6Nboy8ORLQmNkVmFMV2Q/mqzX 2Esg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lists.sourceforge.net header.s=beta header.b=l3tBiMxi; dkim=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b=GGvxdHau; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=JdlOmemU; spf=pass (google.com: domain of openvpn-devel-bounces@lists.sourceforge.net designates 216.105.38.7 as permitted sender) smtp.mailfrom=openvpn-devel-bounces@lists.sourceforge.net; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=muc.de Received: from lists.sourceforge.net (lists.sourceforge.net. [216.105.38.7]) by mx.google.com with ESMTPS id 5a478bee46e88-38567dabe79si99236981eec.50.2026.12.03.01.56.16 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 03 Dec 2026 01:56:16 -0800 (PST) Received-SPF: pass (google.com: domain of openvpn-devel-bounces@lists.sourceforge.net designates 216.105.38.7 as permitted sender) client-ip=216.105.38.7; Authentication-Results: mx.google.com; dkim=pass header.i=@lists.sourceforge.net header.s=beta header.b=l3tBiMxi; dkim=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b=GGvxdHau; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=JdlOmemU; spf=pass (google.com: domain of openvpn-devel-bounces@lists.sourceforge.net designates 216.105.38.7 as permitted sender) smtp.mailfrom=openvpn-devel-bounces@lists.sourceforge.net; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=muc.de DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.sourceforge.net; s=beta; h=Content-Transfer-Encoding:Content-Type: List-Subscribe:List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id: Subject:MIME-Version:References:In-Reply-To:Message-ID:Date:To:From:Sender: Reply-To:Cc:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Unsubscribe-Post: List-Owner; bh=MOgSuI68zv2bXAtkD4QG/GEL8rKyuFwQKnud/bOAe2U=; b=l3tBiMxiMksfyP U++F6HThoJxco4nIRdB5POjbNHVf5zdFitHzXxpmL2GXEeqb/NSgGZxJWJST7jon13tdGoxMywStw ocqbSvRw7ST4wroN1DEWtkanv4gNBm9xRI9KbAvfBpBye76WXSh7WOsVUBs76S08qeH5/Gyn8N1mB teM=; 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.100.1) (envelope-from ) id 1xZ3Xx-000000007hT-3KGh; Thu, 03 Dec 2026 09:56:13 +0000 Received: from [172.30.29.66] (helo=mx.sourceforge.net) by sfs-ml-2.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.100.1) (envelope-from ) id 1xZ3Xw-000000007hF-38Ny for openvpn-devel@lists.sourceforge.net; Thu, 03 Dec 2026 09:56:12 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=Content-Transfer-Encoding:MIME-Version:References: In-Reply-To:Message-ID:Date:Subject:To:From:Sender:Reply-To:Cc:Content-Type: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Unsubscribe-Post:List-Subscribe:List-Post:List-Owner:List-Archive; bh=Q6sjgJSizlh4JoXHOCv/ffSDh80GejqceQ8v0ydWPOc=; b=GGvxdHau8495IVOK9xKJUr4YWX toyfd5NEzxwYyP99fj+4TFvOkgcTujfDlxMieGunh5cSz4Y5G1yLzgUQz0+RSi2E8YLk3mIvdAc3o DPjFJ+VaMDi2w6J9LINLyPBiOLereZeNv4e5Vl9Q/QaB7TXKMQrAfEItmaO7OCYoBs98=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID: Date:Subject:To:From:Sender:Reply-To:Cc:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Unsubscribe-Post: List-Subscribe:List-Post:List-Owner:List-Archive; bh=Q6sjgJSizlh4JoXHOCv/ffSDh80GejqceQ8v0ydWPOc=; b=JdlOmemUSeMk6+rVVQHZtsTKwK 4eB4xYlmnn1vwT6b+/Ng9ctDzTWQ9QORsQqhg1E4HLkAEnAN5eBZPLq66NGHA4qSgERbKQcks+7si TArWI5yzOxEmOJGfXJ+pjKOMSASoMCXq0QR/Mk5HzfNAxXPaqq5u3rS5s7udgGTSi7io=; Received: from [193.149.48.129] (helo=blue.greenie.muc.de) by sfi-mx-1.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.100.1) id 1xZ3Xv-000000005to-1vTa for openvpn-devel@lists.sourceforge.net; Thu, 03 Dec 2026 09:56:12 +0000 Received: from blue.greenie.muc.de (localhost [127.0.0.1]) by blue.greenie.muc.de (8.18.1/8.18.1) with ESMTP id 6B39u4Qr006965 for ; Thu, 3 Dec 2026 10:56:04 +0100 Received: (from gert@localhost) by blue.greenie.muc.de (8.18.2/8.18.1/Submit) id 6B39u4TZ006964 for openvpn-devel@lists.sourceforge.net; Thu, 3 Dec 2026 10:56:04 +0100 From: Gert Doering To: openvpn-devel@lists.sourceforge.net Date: Thu, 3 Dec 2026 10:55:58 +0100 Message-ID: <20261203095603.6951-1-gert@greenie.muc.de> X-Mailer: git-send-email 2.55.0 In-Reply-To: References: MIME-Version: 1.0 X-Spam-Score: 1.3 (+) X-Spam-Report: Spam detection software, running on the system "sfi-spamd-2.hosts.colo.sdot.me", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: From: Selva Nair Initializing before open_management() is required for management interface directives such as pkcs11-id-count to not error out if used during the first management-hold, for example. Content analysis details: (1.3 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 1.3 RDNS_NONE Delivered to internal network by a host with no rDNS X-Headers-End: 1xZ3Xv-000000005to-1vTa Subject: [Openvpn-devel] [PATCH v2] pkcs11: Initialize pkcs11-helper early 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: , Errors-To: openvpn-devel-bounces@lists.sourceforge.net X-getmail-retrieved-from-mailbox: Inbox X-GMAIL-THRID: 1883548445989135017 X-GMAIL-MSGID: 1883548445989135017 From: Selva Nair Initializing before open_management() is required for management interface directives such as pkcs11-id-count to not error out if used during the first management-hold, for example. Github: fixes OpenVPN/openvpn#1166 Change-Id: Ibd33f20108d3ca8ddc17f145502d21d2f6e6d91a Signed-off-by: Selva Nair Acked-by: Razvan Cojocaru Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/2388 --- This change was reviewed on Gerrit and approved by at least one developer. I request to merge it to master. Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/2388 This mail reflects revision 2 of this Change. Acked-by according to Gerrit (reflected above): Razvan Cojocaru diff --git a/src/openvpn/init.c b/src/openvpn/init.c index 49fcaf6..d26d759 100644 --- a/src/openvpn/init.c +++ b/src/openvpn/init.c @@ -747,20 +747,6 @@ do_link_socket_addr_new(c); -#if defined(ENABLE_PKCS11) - if (c->first_time) - { - int i; - pkcs11_initialize(true, c->options.pkcs11_pin_cache_period); - for (i = 0; i < MAX_PARMS && c->options.pkcs11_providers[i] != NULL; i++) - { - pkcs11_addProvider( - c->options.pkcs11_providers[i], c->options.pkcs11_protected_authentication[i], - c->options.pkcs11_private_mode[i], c->options.pkcs11_cert_private[i]); - } - } -#endif - #if 0 /* test get_user_pass with GET_USER_PASS_NEED_OK flag */ { /* @@ -786,6 +772,26 @@ } void +init_pkcs11(const struct context *c) +{ +#if defined(ENABLE_PKCS11) + if (c->first_time) + { + if (!pkcs11_initialize(true, c->options.pkcs11_pin_cache_period)) + { + msg(M_FATAL, "ERROR: pkcs11-helper initialization failed."); + } + for (int i = 0; i < MAX_PARMS && c->options.pkcs11_providers[i] != NULL; i++) + { + pkcs11_addProvider( + c->options.pkcs11_providers[i], c->options.pkcs11_protected_authentication[i], + c->options.pkcs11_private_mode[i], c->options.pkcs11_cert_private[i]); + } + } +#endif +} + +void context_gc_free(struct context *c) { gc_free(&c->c2.gc); diff --git a/src/openvpn/init.h b/src/openvpn/init.h index d028280..b3ee75b 100644 --- a/src/openvpn/init.h +++ b/src/openvpn/init.h @@ -34,6 +34,7 @@ void context_clear_2(struct context *c); void context_init_1(struct context *c); +void init_pkcs11(const struct context *c); void context_clear_all_except_first_time(struct context *c); diff --git a/src/openvpn/openvpn.c b/src/openvpn/openvpn.c index d9a7c85..50be82c 100644 --- a/src/openvpn/openvpn.c +++ b/src/openvpn/openvpn.c @@ -280,6 +280,8 @@ write_pid_file(c.options.writepid, c.options.chroot_dir); } + init_pkcs11(&c); + #ifdef ENABLE_MANAGEMENT /* open management subsystem */ if (!open_management(&c))