From patchwork Mon May 22 10:11:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arne Schwabe X-Patchwork-Id: 3235 Return-Path: Delivered-To: patchwork@openvpn.net Received: by 2002:a05:7300:7b9a:b0:c3:1364:a2a2 with SMTP id j26csp1476688dyk; Mon, 22 May 2023 03:12:04 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ45UL1vetKY5XGMdA8LoW4gaAoHHFRRzHsEg2z4jeu1tGxT5fKkP/C+81p/1fh26Ge18Ioa X-Received: by 2002:a6b:5c10:0:b0:769:a626:6e13 with SMTP id z16-20020a6b5c10000000b00769a6266e13mr5934816ioh.19.1684750323956; Mon, 22 May 2023 03:12:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684750323; cv=none; d=google.com; s=arc-20160816; b=vthAe8Rqku5IqzZ5xRy9RQ5l10UI9XXtWVoN3RqXDlvWCPlOTU7nyC2Ob0Djz5Ecut tHyDXMYIMH688ejJ2nw28NcRZDcSK9KjIsB2rIGcJRt/tdxzgCYPkRavnMhfqgdIEITy vvQhDnfIYwXs3J7VaAU9sBWDdfH5w33xQtfvNqHBIq63TR4D0CFshsaqns281hRtOLpk Kroff1SWRSgmidIc/l1yjmeqmVTDZa0NvHWylVODyOacsbrsYfx4GDoHD+qUSIq/QSEv lI61zMqNXmW5d7ijNoMBYfA7AOnmh50oGJ2h2PsDw/sKjuUqO3oIGYkKzzpQFDWuJGal NpVQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; 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; bh=BN/uKZO8heOybx1BVKpsYXEhV4/Tcg8vL1MbfDFhdKQ=; b=oQcmvuvbPGfRN185lqV6vRkCYmWpEG/HFLaFriRDKOcQGcYGu8NV46sZktNwcJxqbc y3e+tqYYErYSldP8bHW6uaIGGY4W8aT3mX869OV0Hp2RoRmj119LCHTpXLis/uo4VGab 24TYo9nQw5o2wmXmrQH01t5h0rwdlwwJQJCz8XVyox3WryalYdJrJ/JfY/nhwTmeYubk TiqeNyi/7dtyS+hE9gITAJExIfrTI32ZaG8pTwxl1X+AdLQL3mkjuE35nAwIoUQwBZ9W 7Wh4DJ/PA1SuPnvlGY5ncuysgsNY0Znx/Tdkj7amnkss1IiL2Xva1xLCcEwO5qiN8a+v NdFQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b=R1jHPS7a; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=eSXGJGSQ; 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 Received: from lists.sourceforge.net (lists.sourceforge.net. [216.105.38.7]) by mx.google.com with ESMTPS id z18-20020a056602005200b007637e2cbae4si3043548ioz.125.2023.05.22.03.12.03 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 22 May 2023 03:12:03 -0700 (PDT) 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=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b=R1jHPS7a; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=eSXGJGSQ; 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 Received: from [127.0.0.1] (helo=sfs-ml-1.v29.lw.sourceforge.com) by sfs-ml-1.v29.lw.sourceforge.com with esmtp (Exim 4.95) (envelope-from ) id 1q12W1-0002w2-K7; Mon, 22 May 2023 10:11:46 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-1.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1q12W0-0002vS-IW for openvpn-devel@lists.sourceforge.net; Mon, 22 May 2023 10:11:45 +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-Subscribe:List-Post:List-Owner:List-Archive; bh=CoyQm650HLw8uC7/JprV6DSA6HEKAwJWmLhNp15gWQ8=; b=R1jHPS7atphcFL+2cvnWyt/xcw tMeT4FWsIP7c5tMX5G82E19JU/foCC8XK5vMaqSozAEyS1m4USDMzingDuVHExOyBq475OJhq+EI4 ep9BlAEuHYZkiHYAngr99rIVBe6V/02KSsbxboqD7gsGNIHvqlKaiGpOvwbq9k7MVApU=; 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-Subscribe: List-Post:List-Owner:List-Archive; bh=CoyQm650HLw8uC7/JprV6DSA6HEKAwJWmLhNp15gWQ8=; b=eSXGJGSQZHo/np8XskzWyxMOQ2 r2Y63qJabfvJ0hYJT3ABk81uY4TiuQzu0+/zniQ4tIu0X7lJ5lh/SszVimai4z5Pu2Rm61pdrAPK8 dBFOHC75jH6mRg5sYECCgDQeKOj/92fbOETRcQuQKR0R46ydX8mdYErTStClc8tQbJTc=; Received: from mail.blinkt.de ([192.26.174.232]) by sfi-mx-1.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.95) id 1q12W0-00FdhK-Je for openvpn-devel@lists.sourceforge.net; Mon, 22 May 2023 10:11:45 +0000 Received: from kamera.blinkt.de ([2001:638:502:390:20c:29ff:fec8:535c]) by mail.blinkt.de with smtp (Exim 4.95 (FreeBSD)) (envelope-from ) id 1q12Vu-000MwG-5V for openvpn-devel@lists.sourceforge.net; Mon, 22 May 2023 12:11:38 +0200 Received: (nullmailer pid 2842424 invoked by uid 10006); Mon, 22 May 2023 10:11:38 -0000 From: Arne Schwabe To: openvpn-devel@lists.sourceforge.net Date: Mon, 22 May 2023 12:11:37 +0200 Message-Id: <20230522101138.2842378-1-arne@rfc2549.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230517110230.2234266-1-arne@rfc2549.org> References: <20230517110230.2234266-1-arne@rfc2549.org> MIME-Version: 1.0 X-Spam-Score: 0.2 (/) X-Spam-Report: Spam detection software, running on the system "util-spamd-2.v13.lw.sourceforge.com", 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: This function allows us to map from a management key id to a key structure and also allows this function to be reused. Patch v2: add message when key is not found. Signed-off-by: Arne Schwabe --- src/openvpn/ssl_common.h | 20 ++++++++++++++++++++ src/openvpn/ssl_verify.c | 23 +++++++++++++ 2 files changed, 33 insertions(+), 10 deleti [...] Content analysis details: (0.2 points, 6.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 SPF_NONE SPF: sender does not publish an SPF Record 0.2 HEADER_FROM_DIFFERENT_DOMAINS From and EnvelopeFrom 2nd level mail domains are different 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 T_SCC_BODY_TEXT_LINE No description available. X-Headers-End: 1q12W0-00FdhK-Je Subject: [Openvpn-devel] [PATCH v2 1/2] Introduce get_key_by_management_key_id helper function 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: =?utf-8?q?1766138989755727710?= X-GMAIL-MSGID: =?utf-8?q?1766588755536019746?= This function allows us to map from a management key id to a key structure and also allows this function to be reused. Patch v2: add message when key is not found. Signed-off-by: Arne Schwabe --- src/openvpn/ssl_common.h | 20 ++++++++++++++++++++ src/openvpn/ssl_verify.c | 23 +++++++++++++---------- 2 files changed, 33 insertions(+), 10 deletions(-) diff --git a/src/openvpn/ssl_common.h b/src/openvpn/ssl_common.h index 27b029479..ebfd25432 100644 --- a/src/openvpn/ssl_common.h +++ b/src/openvpn/ssl_common.h @@ -722,4 +722,24 @@ get_primary_key(const struct tls_multi *multi) return &multi->session[TM_ACTIVE].key[KS_PRIMARY]; } +#ifdef ENABLE_MANAGEMENT +/** + * Gets the \c key_state object that belong to the management key id or + * return NULL if not found. + */ +static inline struct key_state * +get_key_by_management_key_id(struct tls_multi *multi, unsigned int mda_key_id) +{ + for (int i = 0; i < KEY_SCAN_SIZE; ++i) + { + struct key_state *ks = get_key_scan(multi, i); + if (ks->mda_key_id == mda_key_id) + { + return ks; + } + } + return NULL; +} +#endif + #endif /* SSL_COMMON_H_ */ diff --git a/src/openvpn/ssl_verify.c b/src/openvpn/ssl_verify.c index 1b589f1a6..d4d291098 100644 --- a/src/openvpn/ssl_verify.c +++ b/src/openvpn/ssl_verify.c @@ -1268,22 +1268,25 @@ tls_authentication_status(struct tls_multi *multi) bool tls_authenticate_key(struct tls_multi *multi, const unsigned int mda_key_id, const bool auth, const char *client_reason) { - bool ret = false; + struct key_state *ks = NULL; if (multi) { - int i; + auth_set_client_reason(multi, client_reason); - for (i = 0; i < KEY_SCAN_SIZE; ++i) + ks = get_key_by_management_key_id(multi, mda_key_id); + + if (ks) { - struct key_state *ks = get_key_scan(multi, i); - if (ks->mda_key_id == mda_key_id) - { - ks->mda_status = auth ? ACF_SUCCEEDED : ACF_FAILED; - ret = true; - } + ks->mda_status = auth ? ACF_SUCCEEDED : ACF_FAILED; } + else + { + msg(D_TLS_DEBUG_LOW, "%s: no key state found for management key id " + "%d", __func__, mda_key_id); + } + } - return ret; + return (bool) ks; } #endif /* ifdef ENABLE_MANAGEMENT */ From patchwork Mon May 22 10:11:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arne Schwabe X-Patchwork-Id: 3236 Return-Path: Delivered-To: patchwork@openvpn.net Received: by 2002:a05:7300:7b9a:b0:c3:1364:a2a2 with SMTP id j26csp1476719dyk; Mon, 22 May 2023 03:12:08 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ518El2NE9HpT1C1R9mY7Qp4Om1R83XRfvZ5rD/BCrZ65NnsxPAvZB++v9uMHBGnOFjwgd1 X-Received: by 2002:a92:bf06:0:b0:33a:2863:2c57 with SMTP id z6-20020a92bf06000000b0033a28632c57mr707650ilh.9.1684750328144; Mon, 22 May 2023 03:12:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684750328; cv=none; d=google.com; s=arc-20160816; b=RxuD4EKRm61WFZX2ztKcVVDvKumdbCZfIUgQT16xih13e9LgCHM8JzZudIj8m0+0dd L66xzqDm8tba+L0ePGbf51f4ozSjvEyootqMJsFCqTJTUJ5p4s67V9UNdElbjOqoBClz Z10oIlOzJ0GTXVQVup1axd6jXBAEBWo7lgJo758jRldUQ7C2HRPMp48nw9xxKxJGniqX Fu3/NnftKPjmUFOy1GoaWHJfOKoqu2uNQBJDTcld/vAxVaIdChBa5/rC4JXHMiaHZUK0 VV84/Y7ou6I7NOoJ86qISuTQ2ov9O5c5h0qAoCBCwzrIoRMpT3KuQBCJM8lQv7+gaRmZ 2auA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; 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; bh=klG6Om0s0/qXiD9Y+qgHWgPLaI3y/Z6Qwvx17kM5Nr8=; b=XWVyUBvkNymar24qNBFk3Phk3DQNYxdQulldNSQOpp7Hnyd2Eb9taZWYMaVgbQOzqd 4DYoIvmP5cgYS1f9nuWluJlf8q77nRTk0jg38Eld0wTTFa2NHoAMGCqMP6EOyVrR5SZo sf26n09gV+kBxXTzli5NP4sENCUcqGlXx7oczvCKOKyJ3GesJKNQTAmZR/IWLDSziKXi Eq8tjabSPEkiPLAsHPtZzbTm3Qzb9iks2/txMdmK3o7EBGSUCucFuxuUQ88YV8o/VitD 87r/fk82EV6UrMJzpISn2iQmvKgnNue6GQgh6sb/XjoeVjRALtKg/C9VQ/I4jyGkkGvL K6Yg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b="jq/TTIE4"; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=WX1vR82T; 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 Received: from lists.sourceforge.net (lists.sourceforge.net. [216.105.38.7]) by mx.google.com with ESMTPS id c17-20020a92cf51000000b00338589975e4si3072937ilr.74.2023.05.22.03.12.07 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 22 May 2023 03:12:08 -0700 (PDT) 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=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b="jq/TTIE4"; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=WX1vR82T; 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 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.95) (envelope-from ) id 1q12W7-0005VY-IE; Mon, 22 May 2023 10:11:51 +0000 Received: from [172.30.20.202] (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.95) (envelope-from ) id 1q12W6-0005VR-JD for openvpn-devel@lists.sourceforge.net; Mon, 22 May 2023 10:11:50 +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-Subscribe:List-Post:List-Owner:List-Archive; bh=EeaUIXZf7kPl873DRfzi/v4g0MT+VU+dRpAjCXCbT4A=; b=jq/TTIE4j6JMMe3f7cbErw27Dj BAjuNjCb0SgyUpud1gm6UIOSPqCQa1BdSoowcpjRI9nKB07flBYB8t+pzwQgsuxxJ4yGJ7QxEcOF+ 7v/1xNJhsrvq5MVRQkuRfTuCHfSLFfQUMBmwY6zcx75pD7U8zQwebm1Mme6oVpNVTnRI=; 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-Subscribe: List-Post:List-Owner:List-Archive; bh=EeaUIXZf7kPl873DRfzi/v4g0MT+VU+dRpAjCXCbT4A=; b=WX1vR82TJk7z4VQhEo2IHgKOYv Um+MmdHwT2KIpts6lRdya3N+R74Uh2jUKUzYxleFeyXIAgIoGHRCYSJifbRuDU28yu1k/79fhYlEX nW6aApRhz+4tFCS8Rgq7nT5WjHVlzfNVsjx3wVPA4Hvbhi/RolFfKGLpdlX4QjT5jGNM=; Received: from mail.blinkt.de ([192.26.174.232]) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.95) id 1q12W5-0004Xy-TU for openvpn-devel@lists.sourceforge.net; Mon, 22 May 2023 10:11:50 +0000 Received: from kamera.blinkt.de ([2001:638:502:390:20c:29ff:fec8:535c]) by mail.blinkt.de with smtp (Exim 4.95 (FreeBSD)) (envelope-from ) id 1q12Vu-000MwI-6F for openvpn-devel@lists.sourceforge.net; Mon, 22 May 2023 12:11:38 +0200 Received: (nullmailer pid 2842427 invoked by uid 10006); Mon, 22 May 2023 10:11:38 -0000 From: Arne Schwabe To: openvpn-devel@lists.sourceforge.net Date: Mon, 22 May 2023 12:11:38 +0200 Message-Id: <20230522101138.2842378-2-arne@rfc2549.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230522101138.2842378-1-arne@rfc2549.org> References: <20230517110230.2234266-1-arne@rfc2549.org> <20230522101138.2842378-1-arne@rfc2549.org> MIME-Version: 1.0 X-Spam-Score: 0.3 (/) X-Spam-Report: Spam detection software, running on the system "util-spamd-1.v13.lw.sourceforge.com", 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: the management interface expects the management key id instead of the openvpn key id. In the past they often were the same for low ids which hid the bug quite well. Also do not pick uninitialised keystates (management key_id is not valid in these). Content analysis details: (0.3 points, 6.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 SPF_NONE SPF: sender does not publish an SPF Record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.2 HEADER_FROM_DIFFERENT_DOMAINS From and EnvelopeFrom 2nd level mail domains are different X-Headers-End: 1q12W5-0004Xy-TU Subject: [Openvpn-devel] [PATCH v2 2/2] Fix CR_RESPONSE mangaement message using wrong key_id 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: =?utf-8?q?1766138990735137506?= X-GMAIL-MSGID: =?utf-8?q?1766588759981837197?= the management interface expects the management key id instead of the openvpn key id. In the past they often were the same for low ids which hid the bug quite well. Also do not pick uninitialised keystates (management key_id is not valid in these). Patch v2: do not add logging Change-Id: If9fa1165a0e886b570b3738546ed810a32367cbe Signed-off-by: Arne Schwabe --- src/openvpn/push.c | 4 ++-- src/openvpn/ssl_common.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/openvpn/push.c b/src/openvpn/push.c index 8e9627199..8f0a534ac 100644 --- a/src/openvpn/push.c +++ b/src/openvpn/push.c @@ -267,9 +267,9 @@ receive_cr_response(struct context *c, const struct buffer *buffer) struct tls_session *session = &c->c2.tls_multi->session[TM_ACTIVE]; struct man_def_auth_context *mda = session->opt->mda_context; struct env_set *es = session->opt->es; - int key_id = get_primary_key(c->c2.tls_multi)->key_id; + unsigned int mda_key_id = get_primary_key(c->c2.tls_multi)->mda_key_id; - management_notify_client_cr_response(key_id, mda, es, m); + management_notify_client_cr_response(mda_key_id, mda, es, m); #endif #if ENABLE_PLUGIN verify_crresponse_plugin(c->c2.tls_multi, m); diff --git a/src/openvpn/ssl_common.h b/src/openvpn/ssl_common.h index ebfd25432..be0f18746 100644 --- a/src/openvpn/ssl_common.h +++ b/src/openvpn/ssl_common.h @@ -733,7 +733,7 @@ get_key_by_management_key_id(struct tls_multi *multi, unsigned int mda_key_id) for (int i = 0; i < KEY_SCAN_SIZE; ++i) { struct key_state *ks = get_key_scan(multi, i); - if (ks->mda_key_id == mda_key_id) + if (ks->mda_key_id == mda_key_id && ks->state > S_UNDEF) { return ks; }