Received: from lists.sourceforge.net (lists.sourceforge.net [216.105.38.7]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 26A26606A336 for ; Wed, 2 Dec 2026 08:39:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=lists.sourceforge.net header.i=@lists.sourceforge.net header.a=rsa-sha256 header.s=beta header.b=jDHB0OVN; dkim=fail reason="signature verification failed" (1024-bit key) header.d=sourceforge.net header.i=@sourceforge.net header.a=rsa-sha256 header.s=x header.b=Az9nWX6w; dkim=fail reason="signature verification failed" (1024-bit key) header.d=sf.net header.i=@sf.net header.a=rsa-sha256 header.s=x header.b=R3WGR2fg; dkim=neutral header.d=openvpn.net header.i=@openvpn.net header.a=rsa-sha256 header.s=google header.b=QwbR5Wj2 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.sourceforge.net; s=beta; h=Content-Type:Cc:Reply-To:From: List-Subscribe:List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id: Subject:MIME-Version:Message-ID:References:In-Reply-To:To:Date:Sender: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Unsubscribe-Post:List-Owner; bh=8/1cfyODmtK3M1T/niCwN4VsW8zPeKV+n1EwX/cn1Ac=; b=jDHB0OVN8Uq6cLI6qTZCwUboAy xTLpFmzJrnRWwLvOUbcIX7OPn4dLg/HBihImtc+yy68RNACFPK+Hy9LkdDGWW3eZR68ti7JwFp0av pNaaeRGEtEvY6RSevx94JvmNsQq6rQGERQBLdx8ll1llJJY/B5Y+/UEAJHAapifchNEo=; Received: from [127.0.0.1] (helo=sfs-ml-3.v29.lw.sourceforge.com) by sfs-ml-3.v29.lw.sourceforge.com with esmtp (Exim 4.100.1) (envelope-from ) id 1xYfsc-000000001E8-3PwF; Wed, 02 Dec 2026 08:39:58 +0000 Received: from [172.30.29.66] (helo=mx.sourceforge.net) by sfs-ml-3.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.100.1) (envelope-from ) id 1xYfsa-000000001E0-3aNK for openvpn-devel@lists.sourceforge.net; Wed, 02 Dec 2026 08:39:56 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=Content-Type:Content-Transfer-Encoding:MIME-Version :Message-ID:Reply-To:Subject:References:In-Reply-To:List-Unsubscribe:List-Id: Cc:To:Date:From:Sender:Content-ID:Content-Description:Resent-Date:Resent-From :Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Help: List-Unsubscribe-Post:List-Subscribe:List-Post:List-Owner:List-Archive; bh=OxaZkuhh0H4S+2UhwXrUdmLee08PEd2whvNI1iPnKF0=; b=Az9nWX6wCOkN70xwHTa67qNhjT yYFuFaKgX7/lkQvuKJaZWvazI2GGaKN2wRFR4h4JF6OepAWnEFGJw5udFJ2I2IB1r2aacmj+1JZ0p 8dZ73Lv+c4pbNmjreuLqzfae6wGvgkyES0dBbPCp0DdYZimZEMlpVIbewIE4tcm5gmgY=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Type:Content-Transfer-Encoding:MIME-Version:Message-ID:Reply-To: Subject:References:In-Reply-To:List-Unsubscribe:List-Id:Cc:To:Date:From: Sender:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Help:List-Unsubscribe-Post: List-Subscribe:List-Post:List-Owner:List-Archive; bh=OxaZkuhh0H4S+2UhwXrUdmLee08PEd2whvNI1iPnKF0=; b=R3WGR2fgfM6qeQfn9AW1a1MmzS 36ZpkpxIkf/PpaylDsPY7yuyniAxRbMwLal1WQrrEboIUH+3aU2N4IUnwz2iTs2PUgFm41hArsB2v GTaHtvNG29iUNLGeCjZChGoEfeEb4cauAQ460CsZhwuPtSyySK6kYS1tqYOQCNkl7M4E=; Received: from mail-wr1-f48.google.com ([209.85.221.48]) by sfi-mx-1.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.100.1) id 1xYfsY-000000000Qw-2syF for openvpn-devel@lists.sourceforge.net; Wed, 02 Dec 2026 08:39:56 +0000 Received: by mail-wr1-f48.google.com with SMTP id ffacd0b85a97d-4ac109a8a12so7553093f8f.3 for ; Wed, 02 Dec 2026 00:39:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=openvpn.net; s=google; t=1796200788; x=1796805588; darn=lists.sourceforge.net; h=content-type:user-agent:content-disposition :content-transfer-encoding:mime-version:message-id:reply-to:subject :thread-index:references:in-reply-to:list-unsubscribe:list-id :auto-submitted:cc:to:date:from:from:to:cc:subject:date:message-id :reply-to:content-type; bh=OxaZkuhh0H4S+2UhwXrUdmLee08PEd2whvNI1iPnKF0=; b=QwbR5Wj2c6r0IRMyBL0+aueYVd6QsSRcD4TOv9yBRzjP+syze1eEtFTdgp0m2HrYX6 vSpwgayUZYIMxhAKRFh0Bfa0NoErzhL8WeRLR70nALPXylST8DZynMl/umqsE08udBEJ 8NiElX3GpiazXeOxeorOhmhOt6XpqbR+09J/K4TXqYJAMMGrhs908u3kxZ7RSRXW3fGp 8JvfTF359QE6QlsFSPFYL3JbaBDNTA+ZSD7RefWUESLtiKZhDYFYO5RUQcmwL7Cn5C4c WxzJscz8DMerZrEIKDC0nh7D0n9qQwG6NNxBEQFmHQBTD1QusCJbB03hSAXbJi4sMfnW m3FA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796200788; x=1796805588; h=content-type:user-agent:content-disposition :content-transfer-encoding:mime-version:message-id:reply-to:subject :thread-index:references:in-reply-to:list-unsubscribe:list-id :auto-submitted:cc:to:date:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to:content-type; bh=OxaZkuhh0H4S+2UhwXrUdmLee08PEd2whvNI1iPnKF0=; b=pI9V1wvU1Rh/eKTkg3rMdJJcgnqQB+ZbcJqFdUAotNhDiZEp3JUs7RtHNRnrWPpQ24 JlDwxrxQS3b7jKsBxPZE2GOndFObnhwYppSAV+I6kZ2IQjPG45kh5GHJZtxzkKw9sgiR bFVZYEiI8fovtvTJvdXUNMCCWSpNaUS/7Q1kx5gKylyIS1Svw9tmiidUr8/rroQ7LbeN uEQinhdgHmYlncRWxnXhvYcozjbpDaIedHPSHlr74OcVlqCnetrVmLkaKfLAmcMc/aX9 a8mtqk8Zs9BshhpxA5BgngDMZoI5AdrykDaPGcnlvupyg3IxpJi1CUz1lsL5FyJrPstN ckRw== X-Gm-Message-State: APuU4Z93rxmvsK1F+bHV5UgG42xZ/NtFH4A59sjrBGtxX1W+EFQ+CBto ZyO+E2/NzFm1a9E/cdLl4WliCTI8VmuPV9zUJRgVp84S86cZBnMzVbHIB2iQTnNgSQEAN+k3j5z KDOAd6Sa4JVki3I86b66W8NB/3h/LaJTqg06nDfKsi3EAXZzkME9p6Jiq0uX+44IvHc/G X-Gm-Gg: AZFdTZeWwxgU+0Xc9jiomw5jx/BktmebnQMBuwccDto6HlEvJjhuui0A+GeQ8jVgbpa SDeR9WSEJIHulqzAwbQlll3JxRM9ehxsCBHclFx+N0mT2RbKZj6TOl11VhZiwmMcIrywSI79uKC jF4Ak03+3DyLub9Do0p/OeyfOxqT3SUadB8rRCyw+p6Ux1/3HchNmVig3dyHdOc228VmfsH1h8+ HCKBwK7r5kKFcLfvo+76cYrPE1ETdVxWeTA6FYDAcH6td4bNkHmIw7oWr48BjkDrtM85JultFp/ gG3tCZ4P9hRqN2unOk39yCVrnttkWqM1CIJ4zq+gaz0eqw3TFuFelUYhLvR93uJXTLLZSJSadUv SOj96NRKwVaTHnG50bnzdA1cuu5VQuGB1t802WmhhhFzEV5RJiAXAKgiSPgPfqfj4MpyMsGW0Wz tz4VaHo8MhqCpef8AveQ9Jp/M8zIBgWaXR0ws4vpX7VXhYMfF5IMr7aRdl4XAVyJdnmjofJva4b 5NV/enOW1v8m+TPWij6pnrM0A4kmUWZpTi1YKT8lWQF0tjssiu1x4sdw2yj+kgPUb0kQGf338fZ j/4gkVUb6/BYNY1I13BcAQFmIQ1wIMIQw9iMBaY3w9UdqHfnY8ff+i9FpV9M71u7lJE/gx5HgcM 3Uh1gdhPckGo6i/qBKrp5FzWEEwcE4RQZ6nFKEakqqyZB4m4189DCF/AaNpL7z50/1cYdPsc2EX IV7iwyFuNHms7tJA== X-Received: by 2002:a05:6000:26ca:b0:4a7:1fca:e52b with SMTP id ffacd0b85a97d-4abb0e469damr80399482f8f.19.1796200787867; Wed, 02 Dec 2026 00:39:47 -0800 (PST) Received: from ip-10-18-1-162.eu-central-1.compute.internal (ec2-18-159-0-78.eu-central-1.compute.amazonaws.com. [18.159.0.78]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4bef07f9e0dsm26244823f8f.53.2026.12.02.00.39.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Dec 2026 00:39:47 -0800 (PST) X-Google-Original-From: "Gert Doering (Code Review)" Date: Wed, 2 Dec 2026 08:39:46 +0000 To: Marvin Wunderlich , Selva Nair , Arne Schwabe , Frank Lichtenheld Auto-Submitted: auto-generated X-Gerrit-MessageType: newpatchset X-Gerrit-PatchSet: 10 X-Gerrit-Change-Id: I09e55085cde6dbc0040e111a42128527d59832b8 X-Gerrit-Change-Number: 2148 X-Gerrit-Project: openvpn X-Gerrit-ChangeURL: X-Gerrit-Commit: 56e0abbfab0ca9bad8105db16f77efcca8b89833 In-Reply-To: References: Thread-Index: PGdlcnJpdC4xNzk0MDU5NDM3MDAwLkkwOWU1NTA4NWNkZTZkYmMwMDQwZTExMWE0MjEyODUyN2Q1OTgzMmI4QGdlcnJpdC5vcGVudnBuLm5ldD4= Message-ID: <0396e86b1974b4136b99ef99d513c0d63ee7ed4c-EmailReplacePatchSet-HTML@gerrit.openvpn.net> X-Archived-By: MIME-Version: 1.0 User-Agent: Gerrit/3.14.5 X-Spam-Score: -0.2 (/) X-Headers-End: 1xYfsY-000000000Qw-2syF Subject: [Openvpn-devel] [M] Change in openvpn[master]: Implement multiline responses for pkcs11-id commands X-BeenThere: openvpn-devel@lists.sourceforge.net X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Archive: List-Post: List-Help: List-Subscribe: , From: "Gert Doering \(Code Review\) via Openvpn-devel" Reply-To: gert@greenie.muc.de, arne-openvpn@rfc2549.org, selva.nair@gmail.com, opidopiopi@gmail.com, openvpn-devel@lists.sourceforge.net, frank@lichtenheld.com Cc: "Gert Doering \(Code Review\)" , openvpn-devel Content-Type: multipart/mixed; boundary="===============1329455213902043592==" X-Spam-Status: No, score=-12.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,HTML_MESSAGE, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,MIME_HTML_MOSTLY, PDS_BAD_THREAD_QP_64,SPF_HELO_PASS,SPF_PASS,T_KAM_HTML_FONT_INVALID, WEIRD_PORT autolearn=ham autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 --===============1329455213902043592== Content-Transfer-Encoding: 8bit Content-Disposition: inline Content-Type: multipart/alternative; boundary="XRV+1K1LaUQ="; charset=UTF-8 --XRV+1K1LaUQ= Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Gert Doering has uploaded a new patch set (#10) to the change originally cr= eated by Marvin Wunderlich=2E ( https://gerrit=2Eopenvpn=2Enet/c/openvpn/+/= 2148?usp=3Demail ) The following approvals got outdated and were removed: = Build-Request+1 by Gert Doering Change subject: Implement multiline respo= nses for pkcs11-id commands =2E=2E=2E=2E=2E=2E=2E=2E=2E=2E=2E=2E=2E=2E=2E= =2E=2E=2E=2E=2E=2E=2E=2E=2E=2E=2E=2E=2E=2E=2E=2E=2E=2E=2E=2E=2E=2E=2E=2E=2E= =2E=2E=2E=2E=2E=2E=2E=2E=2E=2E=2E=2E=2E=2E=2E=2E=2E=2E=2E=2E=2E=2E=2E=2E=2E= =2E=2E=2E=2E=2E Implement multiline responses for pkcs11-id commands Resp= onses to the management interface commands pkcs11-id-[get|count] did not fo= llow the standard syntax, but instead looked like notifications=2E Introdu= ce a new management interface version so that clients announcing versions >= =3D 7 will receive responses in the new format while keeping compatibility = for older client versions=2E If a client announces a management version >= =3D 7 the responses conform to the common multiline + END syntax=2E At the = same time, it is now possible to query all PKCS#11 ids using "all" or a ran= ge from "start" to "end" - 1=2E Failures to retrieve an id will return a pa= rtial response terminated by an "ERROR" message including the erroneous ind= ex=2E The response format for pkcs11-id-get was changed to return a comma s= eparated list (index,id,cert_blob) which is easier to parse=2E Change-Id: = I09e55085cde6dbc0040e111a42128527d59832b8 Signed-off-by: Marvin Wunderlich = Gerrit URL: https://gerrit=2Eopenvpn=2Enet/c/openv= pn/+/2148 Message-Id: <20261201224313=2E17664-1-gert@greenie=2Emuc=2Ede> UR= L: https://www=2Email-archive=2Ecom/openvpn-devel@lists=2Esourceforge=2Enet= /msg42330=2Ehtml Signed-off-by: Gert Doering --- = M doc/management-notes=2Etxt M src/openvpn/manage=2Ec M src/openvpn/manage= =2Eh 3 files changed, 164 insertions(+), 21 deletions(-) git pull ssh:/= /gerrit=2Eopenvpn=2Enet:29418/openvpn refs/changes/48/2148/10 diff --git a= /doc/management-notes=2Etxt b/doc/management-notes=2Etxt index a98b45f=2E= =2E8c8c52e 100644 --- a/doc/management-notes=2Etxt +++ b/doc/management-not= es=2Etxt @@ -617,23 +617,109 @@ COMMAND -- pkcs11-id-count (OpenVPN 2=2E1= or higher) --------------------------------------------------- -Retriev= e available number of certificates=2E +Retrieve available number of PKCS#11= certificates=2E + +For management client versions <7: + + pkcs11-id-co= unt + +The reply is ">PKCS11ID-COUNT:"=2E Example: pkcs11= -id-count >PKCS11ID-COUNT:5 +For management client versions >=3D 7:= + + pkcs11-id-count + +The reply is a decimal count followed by "END" = on a separate line=2E + +Example: + + pkcs11-id-count + 5 + END= + COMMAND -- pkcs11-id-get (OpenVPN 2=2E1 or higher) ------------------= ------------------------------- +Retrieve PKCS#11 certificates=2E + +For = management client versions < 7: + + pkcs11-id-get + Retrieve cert= ificate by index, the ID string should be provided as PKCS#11 identity, th= e blob is a base 64 encoded certificate=2E Example: pkcs11-id-ge= t 1 - PKCS11ID-ENTRY:'1', ID:'', BLOB:'' + >PKCS11ID-EN= TRY:'1', ID:'', BLOB:'' + +For management client versions >=3D 7:= + + pkcs11-id-get + pkcs11-id-get + pkcs11-id-get= all + +Retrieve a single PKCS#11 certificate at index or multiple = +PKCS#11 certificates from index to -1=2E Alternatively + =3D "all" retrieves all PKCS#11 certificates=2E A comma separated +list = including index, PKCS#11 id and the base 64 encoded certificate +will be re= turned=2E If any id retrieval results in a failure, the returned +list will= be partial and terminated by "ERROR: =2E=2E" instead of "END"=2E +The "ERR= OR" message will include the index of failure=2E + +Example 1: + + Managem= ent interface client sends: + + pkcs11-id-get 1 + + OpenVPN daemon resp= onds with: + + 1,, + END + +Example 2: + + Management inte= rface client sends: + + pkcs11-id-get 1 3 + + OpenVPN daemon responds w= ith: + + 1,, + 2,, + END + +Example 3:= + + Management interface client sends: + + pkcs11-id-get all + + Open= VPN daemon with 3 PKCS#11 certificates responds with: + + 0,, + 1,, + 2,, + END + +Example 4: + = + Management interface client sends: + + pkcs11-id-get all + + OpenVPN= daemon with 3 PKCS#11 certificates fails to retrieve index 1 + + 0,, + ERROR: Failed to load PKCS#11 id at index: 1 + COMMAND = -- client-auth (OpenVPN 2=2E1 or higher) --------------------------------= --------------- @@ -1240,7 +1326,7 @@ "ERROR: [text]"=2E (2) For co= mmands which print multiple lines of output, - the last line will be "EN= D"=2E + the last line will be "END" or "ERROR: [text]"=2E (3) Real-ti= me messages will be in the form ">[source]:[text]", where source is "C= LIENT", "ECHO", "FATAL", "HOLD", "INFO", "LOG", diff --git a/src/openvpn/ma= nage=2Ec b/src/openvpn/manage=2Ec index 37e9b75=2E=2E6adc2c4 100644 --- a/s= rc/openvpn/manage=2Ec +++ b/src/openvpn/manage=2Ec @@ -74,6 +74,7 @@ M= CV_USERNAME_ONLY =3D 4, MCV_MULTILINE_PASSWORD =3D 5, MCV_PREFERR= ED_USERNAME =3D 6, + MCV_MULTILINE_PKCS11_RESPONSE =3D 7, }; struct = management *management; /* GLOBAL */ @@ -120,7 +121,8 @@ msg(M_CLIENT,= "pid : Show process ID of the current OpenVPN process= =2E"); #ifdef ENABLE_PKCS11 msg(M_CLIENT, "pkcs11-id-count : G= et number of available PKCS#11 identities=2E"); - msg(M_CLIENT, "pkcs11-= id-get index : Get PKCS#11 identity at index=2E"); + msg(M_CLIENT, "p= kcs11-id-get i|all [j] : Get PKCS#11 identity at index =3D i=2E"); + msg= (M_CLIENT, " For version >=3D 7 also i to j-1 or a= ll=2E"); #endif msg(M_CLIENT, "client-auth CID KID : Authenticate = client-id/key-id CID/KID (MULTILINE)"); msg(M_CLIENT, "client-auth-nt = CID KID : Authenticate client-id/key-id CID/KID"); @@ -894,26 +896,81 @@ s= tatic void man_pkcs11_id_count(const struct management *man) { - msg(M= _CLIENT, ">PKCS11ID-COUNT:%d", pkcs11_management_id_count()); -} - -static = void -man_pkcs11_id_get(struct management *man, const int index) -{ - ch= ar *id =3D NULL; - char *base64 =3D NULL; - - if (pkcs11_management_i= d_get(index, &id, &base64)) + if (man->connection=2Eclient_version >=3D = MCV_MULTILINE_PKCS11_RESPONSE) { - msg(M_CLIENT, ">PKCS11ID-ENT= RY:'%d', ID:'%s', BLOB:'%s'", index, id, base64); + msg(M_CLIENT, "%= d", pkcs11_management_id_count()); + msg(M_CLIENT, "END"); } = else { - msg(M_CLIENT, ">PKCS11ID-ENTRY:'%d'", index); + = msg(M_CLIENT, ">PKCS11ID-COUNT:%d", pkcs11_management_id_count()); + = } +} + +static void +man_pkcs11_id_get(struct management *man, const char = *p1, const char *p2) +{ + ASSERT(p1); + + if ((streq(p1, "all") || p2= !=3D NULL) && man->connection=2Eclient_version < MCV_MULTILINE_PKCS11_RESP= ONSE) + { + msg(M_CLIENT, "ERROR: Listing multiple ids is only su= pported for version >=3D %d", MCV_MULTILINE_PKCS11_RESPONSE); + retu= rn; } - free(id); - free(base64); + if (man->connection=2Ec= lient_version >=3D MCV_MULTILINE_PKCS11_RESPONSE) + { + int count= =3D pkcs11_management_id_count(); + int from =3D atoi(p1); + = int to =3D p2 ? atoi(p2) : from + 1; + + if (streq(p1, "all")) + = { + from =3D 0; + to =3D count; + } + + = bool error =3D false; + for (int i =3D from; i < min_int(to, c= ount) && !error; i++) + { + char *id =3D NULL; + = char *base64 =3D NULL; + + if (pkcs11_management_id_get(i, &i= d, &base64)) + { + msg(M_CLIENT, "%d,%s,%s", i, i= d, base64); + } + else + { + = error =3D true; + msg(M_CLIENT, "ERROR: Failed to load PKC= S#11 id at index: %d", i); + } + free(id); + = free(base64); + } + if (!error) + { + ms= g(M_CLIENT, "END"); + } + } + else + { + int index = =3D atoi(p1); + + char *id =3D NULL; + char *base64 =3D NULL;= + + if (pkcs11_management_id_get(index, &id, &base64)) + { += msg(M_CLIENT, ">PKCS11ID-ENTRY:'%d', ID:'%s', BLOB:'%s'", index= , id, base64); + } + else + { + msg(M_CLIEN= T, ">PKCS11ID-ENTRY:'%d'", index); + } + free(id); + f= ree(base64); + } } #endif /* ifdef ENABLE_PKCS11 */ @@ -1813,9 +1870= ,9 @@ } else if (streq(p[0], "pkcs11-id-get")) { - if= (man_need(p, 1, 0)) + if (man_need(p, 1, MN_AT_LEAST)) { -= man_pkcs11_id_get(man, atoi(p[1])); + man_pkcs11_id_= get(man, p[1], p[2]); } } #endif diff --git a/src/openvpn/ma= nage=2Eh b/src/openvpn/manage=2Eh index 697f830=2E=2E7f26a35 100644 --- a/s= rc/openvpn/manage=2Eh +++ b/src/openvpn/manage=2Eh @@ -50,7 +50,7 @@ #incl= ude "socket_util=2Eh" #include "mroute=2Eh" -#define MANAGEMENT_VERSION = 6 +#define MANAGEMENT_VERSION 7 #define = MANAGEMENT_N_PASSWORD_RETRIES 3 #define MANAGEMENT_LOG_HISTORY_INITI= AL_SIZE 100 #define MANAGEMENT_ECHO_BUFFER_SIZE 100 -- To view, = visit https://gerrit=2Eopenvpn=2Enet/c/openvpn/+/2148?usp=3Demail To unsubs= cribe, or for help writing mail filters, visit https://gerrit=2Eopenvpn=2En= et/settings?usp=3Demail Gerrit-MessageType: newpatchset Gerrit-Project: op= envpn Gerrit-Branch: master Gerrit-Change-Id: I09e55085cde6dbc0040e111a4212= 8527d59832b8 Gerrit-Change-Number: 2148 Gerrit-PatchSet: 10 Gerrit-Owner: M= arvin Wunderlich Gerrit-Reviewer: Arne Schwabe Gerrit-Reviewer: Frank Lichtenheld Gerrit-Reviewer: Gert Doering Gerrit-= Reviewer: Selva Nair Gerrit-CC: Yuriy Darnobyt <= yura=2Euddr@gmail=2Ecom> Gerrit-CC: openvpn-devel --XRV+1K1LaUQ= Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable

Gert Doering uploaded patch set #10 to the change originally created by Mar= vin Wunderlich=2E

View Change

The following approvals got outd= ated and were removed: Build-Request+1 by Gert Doering

Imp=
lement multiline responses for pkcs11-id commands

Responses to the m= anagement interface commands pkcs11-id-[get|count] did
not follow the st= andard syntax, but instead looked like notifications=2E

Introduce a = new management interface version so that clients announcing
versions >= ;=3D 7 will receive responses in the new format while keeping
compatibil= ity for older client versions=2E

If a client announces a management = version >=3D 7 the responses conform to
the common multiline + END sy= ntax=2E At the same time, it is now possible
to query all PKCS#11 ids us= ing "all" or a range from "start" to
"end"= - 1=2E Failures to retrieve an id will return a partial response
termin= ated by an "ERROR" message including the erroneous index=2E
Th= e response format for pkcs11-id-get was changed to return a comma
separa= ted list (index,id,cert_blob) which is easier to parse=2E

Change-Id:= I09e55085cde6dbc0040e111a42128527d59832b8
Signed-off-by: Marvin Wunderl= ich <opidopiopi@gmail=2Ecom>
Gerrit URL: https://gerrit=2Eopenvpn= =2Enet/c/openvpn/+/2148
Message-Id: <20261201224313=2E17664-1-gert@gr= eenie=2Emuc=2Ede>
URL: https://www=2Email-archive=2Ecom/openvpn-devel= @lists=2Esourceforge=2Enet/msg42330=2Ehtml
Signed-off-by: Gert Doering &= lt;gert@greenie=2Emuc=2Ede>
---
M doc/management-notes=2Etxt
M = src/openvpn/manage=2Ec
M src/openvpn/manage=2Eh
3 files changed, 164 = insertions(+), 21 deletions(-)

git pull ssh://ge=
rrit=2Eopenvpn=2Enet:29418/openvpn refs/changes/48/2148/10
diff --=
git a/doc/management-notes=2Etxt b/doc/management-notes=2Etxt
index a98b45f=2E=2E8c8c52e 100644
--- a/doc/management-n= otes=2Etxt
+++ b/doc/management-notes=2Etxt
@@ -617,23 +617,109 @@
COMMAND -- pkcs11-id-count (OpenV= PN 2=2E1 or higher)
--------------------------------------= -------------

-Retrieve available number of certificates=2E
+Retrieve available number of PKCS#11 cer= tificates=2E
+=
+For management client vers= ions <7:
+<= br>+ pkcs11-id-count=
+
+The reply is ">PKCS11ID-COUNT:<cou= nt>"=2E

Example:

pkcs11-id-count
>PKCS11ID= -COUNT:5

+For management client versions >=3D 7:
+
+ pkcs11-id-count
+
+The repl= y is a decimal count followed by "END" on a separate line=2E
+
+Example:
+
+ pkcs11-id-count
+ 5
+ END=
+
C= OMMAND -- pkcs11-id-get (OpenVPN 2=2E1 or higher)
-------= ------------------------------------------

+Retrieve PKCS#11 certificates=2E
+
+For management client versions < 7:
+
+ pkcs11-id-get <index>
= +
Retrieve cer= tificate by index, the ID string should be provided
as PKC= S#11 identity, the blob is a base 64 encoded certificate=2E

Example:

pkcs11= -id-get 1
- PKCS11I= D-ENTRY:'1', ID:'<snip>', BLOB:'<snip>'=
+ >PKCS11ID-E= NTRY:'1', ID:'<id>', BLOB:'<blob>'

+
+For management client versions >=3D 7:=
+
+ pkcs11-id-get <index>+ pkcs11-id-get <start>= ; <end>
+ pkcs= 11-id-get all
+

+Retrieve a single PKCS#11= certificate at index <index> or multiple
+PKCS#11 certificates from index <start> t= o <end>-1=2E Alternatively
+<start> =3D "all" retrieves all PKCS#11 certif= icates=2E A comma separated
+list including index, PKCS#11 id and the base 64 encoded certificat= e
+will be returned= =2E If any id retrieval results in a failure, the returned
+list will be partial and terminated = by "ERROR: =2E=2E" instead of "END"=2E
+The "ERROR" message will i= nclude the index of failure=2E
+
+Example = 1:
+
+ Management interface client sends:=
+
+ pkcs11-id-get 1
+
+ OpenVPN daemon responds with:
+
+ 1,<id>,<blob>
+ END
+
+Example 2:=
+
+ Management interface client sends:
+
+ pkcs11-id-get 1 3
+
+ OpenVPN daemon responds with:
+
+ 1,<id_a>,<blob_a>
+ 2,<id_b>,<blob_b>
+ END
+
+Example 3:
+<= /span>
+ Management interfa= ce client sends:
+
+ pkcs11-id-get all<= /span>
+
+ OpenVPN daemon with 3 PKCS#11 certifi= cates responds with:
= +
+ 0,<id_a>= ,<blob_a>
+ = 1,<id_b>,<blob_b>
+ 2,<id_c>,<blob_c>
+ END
+
+Example= 4:
+
+ Management interface client sends= :

+
+ pkcs11-id-get all
+

+ OpenVPN daemon with 3 PKCS#11 certificates fails to = retrieve index 1
+
+ 0,<id_a>,<= ;blob_a>
+ ERRO= R: Failed to load PKCS#11 id at index: 1
+

COMMAND -- client-= auth (OpenVPN 2=2E1 or higher)
--------------------------= ---------------------
@@ -1240,7 +1326,7 @@
"ERROR: [text]"=2E


(2) F= or commands which print multiple lines of output,
- the last line will be "END"=2E
+ the last line will= be "END" or "ERROR: [text]"=2E

(3) Real-time messages will be in the form ">[source]:[= text]",
where source is "CLIENT", "= ;ECHO", "FATAL", "HOLD", "INFO", "L= OG",
diff --git a/src/openvpn/manage=2Ec b/src/openvpn= /manage=2Ec
index 37e9b75=2E=2E6adc2c4 100644
--- a/src/openvpn/manage=2Ec
+++ b/src/openvpn/manage=2E= c
@@ -74,6 +74,7 @@
MCV_USERNAME_ONLY = =3D 4,
MCV_MULTILINE_PASSWORD =3D 5,
= MCV_PREFERRED_USERNAME =3D 6,
+ MCV_MULTILINE_PKCS11_RESPONSE =3D 7,
};<= /span>

struct management *management; /* GLOBAL= */
@@ -120,7 +121,8 @@
msg(M_CLIENT, = "pid : Show process ID of the current OpenVPN proce= ss=2E");
#ifdef ENABLE_PKCS11
ms= g(M_CLIENT, "pkcs11-id-count : Get number of available PKCS#11 = identities=2E");
-= msg(M_CLIENT, "pkcs11-id-get index : Get PKCS#11 identity at in= dex=2E");
+ m= sg(M_CLIENT, "pkcs11-id-get i|all [j] : Get PKCS#11 identity at index = =3D i=2E");
+ = msg(M_CLIENT, " For version >=3D 7 also i= to j-1 or all=2E");
#endif
msg(= M_CLIENT, "client-auth CID KID : Authenticate client-id/key-id CID/= KID (MULTILINE)");
msg(M_CLIENT, "client-aut= h-nt CID KID : Authenticate client-id/key-id CID/KID");
@@ -894,26 +896,81 @@

static void
man_p= kcs11_id_count(const struct management *man)
{
<= span style=3D"color: hsl(0, 100%, 40%);">- msg(M_CLIENT, ">PKCS1= 1ID-COUNT:%d", pkcs11_management_id_count());
-}
-
-static void<= /span>
-man_pkcs11_id_get(stru= ct management *man, const int index)
-{
- c= har *id =3D NULL;
- = char *base64 =3D NULL;
= -
- if (pkcs11_manag= ement_id_get(index, &id, &base64))
+ if (man->connection=2Eclient_version >=3D = MCV_MULTILINE_PKCS11_RESPONSE)
{
- msg(M_CLIENT, ">PKCS11ID-EN= TRY:'%d', ID:'%s', BLOB:'%s'", index, id, base= 64);
+ msg(M_C= LIENT, "%d", pkcs11_management_id_count());
+ msg(M_CLIENT, "END");
}
else
{
- msg(M_CLIENT, &quo= t;>PKCS11ID-ENTRY:'%d'", index);
+ msg(M_CLIENT, ">PKCS11ID-COUNT= :%d", pkcs11_management_id_count());
+ }
+}
++static void
+man_pkcs11_id_get(struct management *= man, const char *p1, const char *p2)
+{
+ = ASSERT(p1);
+
+ if ((streq(p1, "= ;all") || p2 !=3D NULL) && man->connection=2Eclient_version= < MCV_MULTILINE_PKCS11_RESPONSE)
+ {
+ return;
}


- free(id);
- = free(base64);
+ if= (man->connection=2Eclient_version >=3D MCV_MULTILINE_PKCS11_RESPONSE= )
+ {
+ int count =3D pkcs11_man= agement_id_count();

+= int from =3D atoi(p1);
+ int to =3D p2 ? atoi(p2) : from + 1;
+
+ if (streq(p1, "all"))
+ {
+ from =3D 0;
+ to =3D count;
+ }
+
+ bool error =3D false;
+ for (int i =3D from; i < min_int(to, count) &a= mp;& !error; i++)
+ {
+ = char *id =3D NULL;
+
+ = if (pkcs11_management_id_get(i, &id, &base64))+ {
+ msg(M_CLIENT, "= ;%d,%s,%s", i, id, base64);

+ }
+ else
+ {
+ = error =3D true;
+ msg(M_CLIENT, "ERROR: Failed to load PKCS#11= id at index: %d", i);
+ }
+ free(id);
+ free(base64);
+ }
+= if (!error)
+= {
+ = msg(M_CLIENT, "END");
+ }
+ }
+ else
+ {
+ int index =3D atoi(p1);

+
+ char *id =3D NULL;
+ char *base64 =3D NULL;

+
+ if (pkcs11_management_id_get(inde= x, &id, &base64))
+ {
+ = msg(M_CLIENT, ">PKCS11ID-ENTRY:'%d', ID:'%s'= ;, BLOB:'%s'", index, id, base64);
+ }
+ else
+ {
= + msg(M_CLIENT, ">PKCS11ID-ENTRY:'%d'", ind= ex);
+ }
+ free(id);<= br>+ free(base64);
+ }
}<= /span>

#endif /* ifdef ENABLE_PKCS11 */<= br>@@ -1813,9 +1870,9 @@
}
= else if (streq(p[0], "pkcs11-id-get"))
{
- if (man_need(p, 1= , 0))
+ if (ma= n_need(p, 1, MN_AT_LEAST))
{
- man_pkcs11_id_get(man, atoi(p[1= ]));
+ man= _pkcs11_id_get(man, p[1], p[2]);
}
}

#endif
diff --git a/src/openvpn/ma= nage=2Eh b/src/openvpn/manage=2Eh
index 697f830=2E=2E7f26a3= 5 100644
--- a/src/openvpn/manage=2Eh
+++ b= /src/openvpn/manage=2Eh
@@ -50,7 +50,7 @@
= #include "socket_util=2Eh"
#include "mroute= =2Eh"

-#define MANAGEMENT_VERSION 6
+#define MANAGEMENT_VERSION = 7
#define MANAGEMENT_N_PASSWORD_RETRIES 3<= br> #define MANAGEMENT_LOG_HISTORY_INITIAL_SIZE 100
= #define MANAGEMENT_ECHO_BUFFER_SIZE 100

To view,= visit change 2148=2E To unsubscribe, or for help writing mail filters, vi= sit setting= s=2E

=
Gerrit-MessageType: newpatchset
=
Gerrit-Project: openvpn
Gerrit-Branch: master
Ge= rrit-Change-Id: I09e55085cde6dbc0040e111a42128527d59832b8
Gerrit-Change-Number: 2148
Gerrit-PatchSet: 10
Gerrit-Owner= : Marvin Wunderlich <opidopiopi@gmail=2Ecom>
Gerrit-Reviewer: Arne Schwabe <arne-openvpn@rfc2549=2Eorg>= ;
Gerrit-Reviewer: Frank Lichtenheld &l= t;frank@lichtenheld=2Ecom>
Gerrit-Re= viewer: Gert Doering <gert@greenie=2Emuc=2Ede>
Gerrit-Reviewer: Selva Nair <selva=2Enair@gmail=2Ecom> =
Gerrit-CC: Yuriy Darnobyt <yura=2Eud= dr@gmail=2Ecom>
Gerrit-CC: openvpn-d= evel <openvpn-devel@lists=2Esourceforge=2Enet>
--XRV+1K1LaUQ=-- --===============1329455213902043592== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline --===============1329455213902043592== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Openvpn-devel mailing list Openvpn-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/openvpn-devel --===============1329455213902043592==--