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 97498606A336 for ; Tue, 1 Dec 2026 17:38:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key, unprotected) header.d=lists.sourceforge.net header.i=@lists.sourceforge.net header.a=rsa-sha256 header.s=beta header.b=WbL+0HGk; 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=nPwaC5sp; 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=kwPRki4L; dkim=neutral header.d=openvpn.net header.i=@openvpn.net header.a=rsa-sha256 header.s=google header.b=Z4xH50aV 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=7WDKbnbhdJaP8V0BLfKdjVCk3pKI4f+HRzABLuq2P90=; b=WbL+0HGkw1XvpSu+m6nfbU6/ZN XdEg4yfi5te/lcmhwhdwXsmHtn0OqToooKpuKd0uqKqvEv34TN2b3S5gyyddO2363TX4/H8sVzBN0 PPQSu85DX1dpJwlcNGeB51nz32qulVIFZgCRHwucpESe0PIch2kV6YcR4cUgn9iO5F4Y=; 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.100.1) (envelope-from ) id 1xYRnt-000000005aW-1jNP; Tue, 01 Dec 2026 17:38:09 +0000 Received: from [172.30.29.66] (helo=mx.sourceforge.net) by sfs-ml-4.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.100.1) (envelope-from ) id 1xYRns-000000005aP-0xXO for openvpn-devel@lists.sourceforge.net; Tue, 01 Dec 2026 17:38:08 +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=+OY9OlFh2pi180Hn9E7WT5H1qDqNK6s6bUqD+NZqHvY=; b=nPwaC5spbXfUo4cBqRgnTEKEfn 8sTQ+HdZ0sXdcJKoCiGPHYDFrSmkwf3CRd0DUlXntRfLkLAoUmgRk6+K9ziwFVxdNXVhb5AfdmwLG 4r27uCjWyuEsousiCkNdNoSu3GqWXnYpniVLszhHeooXM1EihtJ6T5PZYfdx7MVsymdU=; 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=+OY9OlFh2pi180Hn9E7WT5H1qDqNK6s6bUqD+NZqHvY=; b=kwPRki4LAU9+b4w4J02qN3gmbg 9TE28BQyQom3i7P6zKnO/mOyqX97DROpmifvwRRXomVlPcdxgh7DU1qi6YzPDrDayG/Nc1DqA06jq W8tXZ8CcVSX1OlcQvBgd8Qp4zdkSxRhIS/gU8OHN429d4O2kcGXAGM1ETLt2f2pvR5wA=; Received: from mail-wm1-f45.google.com ([209.85.128.45]) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.100.1) id 1xYRnq-000000008EK-0rJg for openvpn-devel@lists.sourceforge.net; Tue, 01 Dec 2026 17:38:08 +0000 Received: by mail-wm1-f45.google.com with SMTP id 5b1f17b1804b1-4a35ac4475dso86038925e9.2 for ; Tue, 01 Dec 2026 09:38:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=openvpn.net; s=google; t=1796146680; x=1796751480; 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=+OY9OlFh2pi180Hn9E7WT5H1qDqNK6s6bUqD+NZqHvY=; b=Z4xH50aVPpTOzfxgQ9AWt+61Yu+S6zavyw+wjG8EnxqCDK1z65iK893K0+DVdbQ3H1 lmi5Rq9gIjkC+xJ/N53YtTGMZuNY2+woL3qUdR3f+7iHwml492thVnQOt1jb6FOrbook 52Je+JJDSBONsTrh9X6QGK5JuuX669CTOQsNIAfhA+SMCA+kGwXJ7n3i3of88i7Y7GVL WhLHANkFuNxkoWPHhKArDUf6TSmrNzs6htxtSQZ5KVCvYtKyzDh236keQXRNjBlC/QIg Sq8qVTP6z2StLCElWRP8qIM/JrQqwtLhL0a9nuPp9ZeBS40b1CH6q5czwnOFCxcqjnBg 4J4g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796146680; x=1796751480; 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=+OY9OlFh2pi180Hn9E7WT5H1qDqNK6s6bUqD+NZqHvY=; b=wAH+lJtXW5popvVQph6znJjC1dYfCiXZvNgTv1VpuwSjci5G46SxJcCpW5QjaGOHbF lq2RD4BYpxSLJJqBvu8LJak/RKg+wg0BxXC9E/CB9DmdfIk4VTOJBl/XTUhP+x09SJ9N 8yERH1JL8eP10/qnSebpCc1ovmJeHy1uF7Db7ZVL1Un6TQltj9C5hv0NCwXMt0u/Ns/O 17CEoDGtaVlLSXN4iITMnxoSkHYcC+armkveF9e5eTjEdwwH9UcmT/RoxZGXuU0t10gR 62IumEZLstcyWxBUKKeo+7cpLTXY6UvSzuuGesR5zAJnhKLVG9Hm1N5IKXciGxCG+MBg d9YA== X-Gm-Message-State: APuU4Z9iEtDNdNz842LeYGL7IhVHAPgVVtog+98k+ZnJqLAVNW8/TGTR Rh1j9693TQ9Bk02wumO1Y4/MCbmR9HYxTXPfA8n8X/D/yroFZyO7vP9J6WRL++8LSim8io/eeiF azHZqWiivAoMzjPaG1XIeZiCmcXwMlinfFgZoB5qbnAkjDEswVjUE9Mb8+Z64vwhDa989 X-Gm-Gg: AZFdTZfyGgzzUXPRNos4zobdXCfOK4baCFjdbzB7QqFy/i9oe+7YAfiISp2D5IIGdIr y67TLmZO9ASXMGSjHBjXIlKUxgMjcywJXP3+5H0ptzsTHIihytJzU8pE3BYMVV8XUciz3luYfXc HDlaoIHf0O4BJV+ME1ZVHKRgVSPQ4Xz6Kwhdta9EfcbgisNzWy1/PctbOBKag7jhwtSRj+AxMR3 MfQgwI5TxK1IEs2MjM9vmadsvfYU3wTkDWYxVM3xTqx/QQAQszCXFlzcn8tkoYoHMjMoOGs8AaJ 7Js+LN01d8MgUmsPrQqV5c8+Zy5nP5SeTLSQygDHcYN3NLGffQzJveaqCHNl9QPBAU6GHApkZ9K qgqywErDo05PnslD/i0LPuSsBiZ5vYZe2PYT3PD1Vd+vVQQs+IWB4LuOC5t3DOCahUY9dHtKJ02 GuFo4ORCgRHAfZ5PZzhqq4xuKvzGCR7aYzoLug7V5dQW/e5R4xooS7RXZhoMVkozTRwr4l1XYuS MK/0XN9GG1wL/qTBaxtBpaBay87VpPZWDUBCXzd07yVn35jF4lX665qqbWeH0CxkdGeEr9sRHlt 3Kg8j2JZ+g/pFjMUfa/kyRJ7sMLqCqqZLV3Ei3PF8qssHateAgsVsZo430FMKhlI0O5ufyJ3xr2 HTxOg9UttfdakHe0CdIe6t2F9Uo2up9zYQVahhcemayMbMH0bwIVovPyK9sGstH8RmfyTxf23TH UXZuhUHhq73OFwIbkMAwzj2qPBBtHDL2Rbld4= X-Received: by 2002:a05:600c:1389:b0:4bb:6519:477e with SMTP id 5b1f17b1804b1-4bb88813b35mr767587575e9.17.1796146679216; Tue, 01 Dec 2026 09:37:59 -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 5b1f17b1804b1-4bb906cdcc1sm663030005e9.2.2026.12.01.09.37.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Dec 2026 09:37:58 -0800 (PST) X-Google-Original-From: "Marvin Wunderlich (Code Review)" Date: Tue, 1 Dec 2026 17:37:57 +0000 To: Selva Nair , Arne Schwabe , Frank Lichtenheld Auto-Submitted: auto-generated X-Gerrit-MessageType: newpatchset X-Gerrit-PatchSet: 9 X-Gerrit-Change-Id: I09e55085cde6dbc0040e111a42128527d59832b8 X-Gerrit-Change-Number: 2148 X-Gerrit-Project: openvpn X-Gerrit-ChangeURL: X-Gerrit-Commit: 382bf29416a23eaff8d3d2a4c4eb37522ccfa7ba In-Reply-To: References: Thread-Index: PGdlcnJpdC4xNzk0MDU5NDM3MDAwLkkwOWU1NTA4NWNkZTZkYmMwMDQwZTExMWE0MjEyODUyN2Q1OTgzMmI4QGdlcnJpdC5vcGVudnBuLm5ldD4= Message-ID: <2037f41cb42045bee63a45e2f44e9af84bf6d75e-EmailReplacePatchSet-HTML@gerrit.openvpn.net> X-Archived-By: MIME-Version: 1.0 User-Agent: Gerrit/3.14.5 X-Spam-Score: 0.8 (/) X-Headers-End: 1xYRnq-000000008EK-0rJg 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: "Marvin Wunderlich \(Code Review\) via Openvpn-devel" Reply-To: opidopiopi@gmail.com, arne-openvpn@rfc2549.org, selva.nair@gmail.com, openvpn-devel@lists.sourceforge.net, frank@lichtenheld.com, yura.uddr@gmail.com, gert@greenie.muc.de Cc: "Marvin Wunderlich \(Code Review\)" , Yuriy Darnobyt , openvpn-devel Content-Type: multipart/mixed; boundary="===============2723377092731032239==" 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 --===============2723377092731032239== Content-Transfer-Encoding: 8bit Content-Disposition: inline Content-Type: multipart/alternative; boundary="/uZj20bKtxE="; charset=UTF-8 --/uZj20bKtxE= Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Attention is currently required from: Arne Schwabe, Frank Lichtenheld, Gert= Doering, Marvin Wunderlich, Selva Nair, Yuriy Darnobyt=2E Hello Arne Schw= abe, Frank Lichtenheld, Gert Doering, Selva Nair, I'd like you to reexami= ne a change=2E Please visit https://gerrit=2Eopenvpn=2Enet/c/openvpn/+= /2148?usp=3Demail to look at the new patch set (#9)=2E The following appr= ovals got outdated and were removed: Build-Request+1 by Gert Doering, Code-= Review-1 by Frank Lichtenheld Change subject: Implement multiline respons= es 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 Respons= es to the management interface commands pkcs11-id-[get|count] did not follo= w the standard 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 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 range f= rom "start" to "end" - 1=2E Failures to retrieve an id will return a partia= l response terminated by an "ERROR" message including the erroneous index= =2E The response format for pkcs11-id-get was changed to return a comma sep= arated list (index,id,cert_blob) which is easier to parse=2E Change-Id: I0= 9e55085cde6dbc0040e111a42128527d59832b8 Signed-off-by: Marvin Wunderlich --- M doc/management-notes=2Etxt M src/openvpn/manag= e=2Ec M src/openvpn/manage=2Eh 3 files changed, 164 insertions(+), 21 delet= ions(-) git pull ssh://gerrit=2Eopenvpn=2Enet:29418/openvpn refs/change= s/48/2148/9 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-notes=2Etxt @@ -617,23 +617,109 @@ COMMAND -- pkcs11-i= d-count (OpenVPN 2=2E1 or higher) ---------------------------------------= ------------ -Retrieve available number of certificates=2E +Retrieve avai= lable number of PKCS#11 certificates=2E + +For management client versions <= 7: + + pkcs11-id-count + +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 c= ount followed by "END" on a separate line=2E + +Example: + + pkcs11-id-= count + 5 + END + COMMAND -- pkcs11-id-get (OpenVPN 2=2E1 or high= er) ------------------------------------------------- +Retrieve PKCS#11 = certificates=2E + +For management client versions < 7: + + pkcs11-id-get <= index> + Retrieve certificate by index, the ID string should be provided = as PKCS#11 identity, the blob is a base 64 encoded certificate=2E Exampl= e: pkcs11-id-get 1 - PKCS11ID-ENTRY:'1', ID:'', BLOB:'' + >PKCS11ID-ENTRY:'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 ind= ex 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 returned=2E If any id retrieval results in a failure,= the returned +list will be partial and terminated by "ERROR: =2E=2E" inste= ad of "END"=2E +The "ERROR" message will include the index of failure=2E + = +Example 1: + + Management interface client sends: + + pkcs11-id-get 1 = + + OpenVPN daemon responds with: + + 1,, + END + +Example= 2: + + Management interface client sends: + + pkcs11-id-get 1 3 + + O= penVPN daemon responds with: + + 1,, + 2,, + END + +Example 3: + + Management interface client sends: + + pkc= s11-id-get all + + OpenVPN daemon with 3 PKCS#11 certificates responds wit= h: + + 0,, + 1,, + 2,, += END + +Example 4: + + Management interface client sends: + + pkcs11= -id-get all + + OpenVPN daemon with 3 PKCS#11 certificates fails to retrie= ve index 1 + + 0,, + ERROR: Failed to load PKCS#11 id a= t index: 1 + COMMAND -- client-auth (OpenVPN 2=2E1 or higher) --------= --------------------------------------- @@ -1240,7 +1326,7 @@ "ERROR: = [text]"=2E (2) For commands which print multiple lines of output, - t= he 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", "LOG", dif= f --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=2Ec= @@ -74,6 +74,7 @@ MCV_USERNAME_ONLY =3D 4, MCV_MULTILINE_PASSWOR= D =3D 5, MCV_PREFERRED_USERNAME =3D 6, + MCV_MULTILINE_PKCS11_RESPO= NSE =3D 7, }; struct management *management; /* GLOBAL */ @@ -120,7 +12= 1,8 @@ msg(M_CLIENT, "pid : Show process ID of the = current OpenVPN process=2E"); #ifdef ENABLE_PKCS11 msg(M_CLIENT, "pkc= s11-id-count : Get number of available PKCS#11 identities=2E"); - = msg(M_CLIENT, "pkcs11-id-get index : Get PKCS#11 identity at index=2E")= ; + msg(M_CLIENT, "pkcs11-id-get i|all [j] : Get PKCS#11 identity at ind= ex =3D i=2E"); + msg(M_CLIENT, " For version >= =3D 7 also i to j-1 or all=2E"); #endif msg(M_CLIENT, "client-auth CI= D 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 @@ static void man_pkcs11_id_count(const struct manage= ment *man) { - msg(M_CLIENT, ">PKCS11ID-COUNT:%d", pkcs11_management_id= _count()); -} - -static void -man_pkcs11_id_get(struct management *man, con= st int index) -{ - char *id =3D NULL; - char *base64 =3D NULL; - - = if (pkcs11_management_id_get(index, &id, &base64)) + if (man->connectio= n=2Eclient_version >=3D MCV_MULTILINE_PKCS11_RESPONSE) { - msg(= M_CLIENT, ">PKCS11ID-ENTRY:'%d', ID:'%s', BLOB:'%s'", index, id, base64); += msg(M_CLIENT, "%d", pkcs11_management_id_count()); + msg(M_C= LIENT, "END"); } else { - msg(M_CLIENT, ">PKCS11ID-EN= TRY:'%d'", index); + msg(M_CLIENT, ">PKCS11ID-COUNT:%d", pkcs11_mana= gement_id_count()); + } +} + +static void +man_pkcs11_id_get(struct mana= gement *man, const char *p1, const char *p2) +{ + ASSERT(p1); + + if = ((streq(p1, "all") || p2 !=3D NULL) && man->connection=2Eclient_version < M= CV_MULTILINE_PKCS11_RESPONSE) + { + msg(M_CLIENT, "ERROR: Listing= multiple ids is only supported for version >=3D %d", MCV_MULTILINE_PKCS11_= RESPONSE); + return; } - free(id); - free(base64); + = if (man->connection=2Eclient_version >=3D MCV_MULTILINE_PKCS11_RESPONSE) += { + int count =3D pkcs11_management_id_count(); + int fro= m =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) && !error; i++) + { + char = *id =3D NULL; + char *base64 =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, "E= RROR: 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(index, &id,= &base64)) + { + msg(M_CLIENT, ">PKCS11ID-ENTRY:'%d', ID:= '%s', BLOB:'%s'", index, id, base64); + } + else + { += msg(M_CLIENT, ">PKCS11ID-ENTRY:'%d'", index); + } + = free(id); + free(base64); + } } #endif /* ifdef ENABLE_PKC= S11 */ @@ -1813,9 +1870,9 @@ } else if (streq(p[0], "pkcs11-id-ge= t")) { - 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/manage=2Eh b/src/openvpn/manage=2Eh index 697f830=2E= =2E7f26a35 100644 --- a/src/openvpn/manage=2Eh +++ b/src/openvpn/manage=2Eh= @@ -50,7 +50,7 @@ #include "socket_util=2Eh" #include "mroute=2Eh" -#d= efine MANAGEMENT_VERSION 6 +#define MANAGEMENT_VERSION = 7 #define MANAGEMENT_N_PASSWORD_RETRIES 3 #define MAN= AGEMENT_LOG_HISTORY_INITIAL_SIZE 100 #define MANAGEMENT_ECHO_BUFFER_SIZE = 100 -- To view, visit https://gerrit=2Eopenvpn=2Enet/c/openvpn/+/2= 148?usp=3Demail To unsubscribe, or for help writing mail filters, visit htt= ps://gerrit=2Eopenvpn=2Enet/settings?usp=3Demail Gerrit-MessageType: newpa= tchset Gerrit-Project: openvpn Gerrit-Branch: master Gerrit-Change-Id: I09e= 55085cde6dbc0040e111a42128527d59832b8 Gerrit-Change-Number: 2148 Gerrit-Pat= chSet: 9 Gerrit-Owner: Marvin Wunderlich Gerrit-Re= viewer: Arne Schwabe Gerrit-Reviewer: Frank Li= chtenheld Gerrit-Reviewer: Gert Doering Gerrit-Reviewer: Selva Nair Ger= rit-CC: Yuriy Darnobyt Gerrit-CC: openvpn-devel <= openvpn-devel@lists=2Esourceforge=2Enet> Gerrit-Attention: Selva Nair Gerrit-Attention: Marvin Wunderlich Gerrit-Attention: Arne Schwabe Gerrit-= Attention: Gert Doering Gerrit-Attention: Frank L= ichtenheld Gerrit-Attention: Yuriy Darnobyt --/uZj20bKtxE= Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable

Attention is cur= rently required from: Arne Schwabe, Frank Lichtenheld, Gert Doering, Marvin= Wunderlich, Selva Nair, Yuriy Darnobyt=2E

Marvin Wunderlich uploaded patch set #9 to this change=2E

View Change

The following approvals got outdated and were removed: Build-Request+1 by = Gert Doering, Code-Review-1 by Frank Lichtenheld

Implement=
 multiline responses for pkcs11-id commands

Responses to the managem= ent interface commands pkcs11-id-[get|count] did
not follow the standard= syntax, but instead looked like notifications=2E

Introduce a new ma= nagement interface version so that clients announcing
versions >=3D 7= will receive responses in the new format while keeping
compatibility fo= r older client versions=2E

If a client announces a management versio= n >=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 range from "start" to
"end" - 1= =2E Failures to retrieve an id will return a partial response
terminated= by an "ERROR" message including the erroneous index=2E
The re= sponse format for pkcs11-id-get was changed to return a comma
separated = list (index,id,cert_blob) which is easier to parse=2E

Change-Id: I09= e55085cde6dbc0040e111a42128527d59832b8
Signed-off-by: Marvin Wunderlich = <opidopiopi@gmail=2Ecom>
---
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/9
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: 9
Gerrit-Owner:= Marvin Wunderlich <opidopiopi@gmail=2Ecom>
Gerrit-Reviewer: Arne Schwabe <arne-openvpn@rfc2549=2Eorg>=
Gerrit-Reviewer: Frank Lichtenheld <= ;frank@lichtenheld=2Ecom>
Gerrit-Rev= iewer: Gert Doering <gert@greenie=2Emuc=2Ede>
Gerrit-Reviewer: Selva Nair <selva=2Enair@gmail=2Ecom> <= /div>
Gerrit-CC: Yuriy Darnobyt <yura=2Eudd= r@gmail=2Ecom>
Gerrit-CC: openvpn-de= vel <openvpn-devel@lists=2Esourceforge=2Enet>
Gerrit-Attention: Selva Nair <selva=2Enair@gmail=2Ecom> =
Gerrit-Attention: Marvin Wunderlich <= ;opidopiopi@gmail=2Ecom>
Gerrit-Atte= ntion: Arne Schwabe <arne-openvpn@rfc2549=2Eorg>
Gerrit-Attention: Gert Doering <gert@greenie=2Emuc=2Ede&= gt;
Gerrit-Attention: Frank Lichtenheld= <frank@lichtenheld=2Ecom>
Gerrit= -Attention: Yuriy Darnobyt <yura=2Euddr@gmail=2Ecom>
<= /html> --/uZj20bKtxE=-- --===============2723377092731032239== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline --===============2723377092731032239== 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 --===============2723377092731032239==--