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 C9922606A31A for ; Tue, 1 Dec 2026 16:44:18 +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=ETaFtgK8; dkim=fail reason="signature verification failed" (1024-bit key, unprotected) header.d=sourceforge.net header.i=@sourceforge.net header.a=rsa-sha256 header.s=x header.b=VxWoDKAh; dkim=fail reason="signature verification failed" (1024-bit key, unprotected) header.d=sf.net header.i=@sf.net header.a=rsa-sha256 header.s=x header.b=YNQ8qQoi; dkim=neutral header.d=openvpn.net header.i=@openvpn.net header.a=rsa-sha256 header.s=google header.b=gY6LkR+z 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=zulV633cythhjWvTyXUTdG0iOT2OBeD5665d1RK3z8o=; b=ETaFtgK8GoArntbXI98o1Vu5ku aPvyVM2PplqX++i4675v6pDaf6R7ykZPPwjeS6XK0ViFKyDfD1h+JWrP6NktvGxznJPYTLvGYvFRy wY4nDjLc71jBsH0mVMzbkBlRJvAMo3b4UvV/zrL41fISbWPI9dIhA5Comtl3VunwgjQw=; 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 1xYQxj-000000004Z1-48Pe; Tue, 01 Dec 2026 16:44:16 +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 1xYQxj-000000004Ys-1BOE for openvpn-devel@lists.sourceforge.net; Tue, 01 Dec 2026 16:44:15 +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=4D7PKIW/fsQIXjoJ0ImWbDLBm+eq6iM3NLSmsDBG3aU=; b=VxWoDKAhSkrp3zMEKntMS41fAe BtyBdPymn4YYMdu4KIIdBy/Pqi49Q7ZF96EpkuEPFcJSVAf5+h/ZxB1ZdpjzxBoLp/UmScFEaUKkV aXnlfSx0KUfotL9KXuCM8dK1UewKFv3Xp+6eEIvUxLj0fSgkM5wVQctJLfu1SoZXotj8=; 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=4D7PKIW/fsQIXjoJ0ImWbDLBm+eq6iM3NLSmsDBG3aU=; b=YNQ8qQoi3CDxYHwlrCBD3xHkb3 5oTKZcMY68cNFRFgaYblanpeOOBBwJBmmt7HSdFN46rPr1n83YTITvFGTplhUtk6gahnqLBlVUmhZ JzAIr72iJUgaFQiMFQrQZ4hj6Gt5qphfomUf29gQAKwEhXlnC5UAZOtz0iqMPa4W239c=; Received: from mail-wr1-f46.google.com ([209.85.221.46]) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.100.1) id 1xYQxg-000000002Yb-05eO for openvpn-devel@lists.sourceforge.net; Tue, 01 Dec 2026 16:44:15 +0000 Received: by mail-wr1-f46.google.com with SMTP id ffacd0b85a97d-492fcbfaa88so8123188f8f.3 for ; Tue, 01 Dec 2026 08:44:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=openvpn.net; s=google; t=1796143445; x=1796748245; 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=4D7PKIW/fsQIXjoJ0ImWbDLBm+eq6iM3NLSmsDBG3aU=; b=gY6LkR+zecaTmyQwlMo9XdBvHOhasPeQ8d5vydkf7YtI4k0kXVhfnwGBTwyKlx2uDO PUzRsySrPkHFPOeBxZBqfSk5SzpQDTPZglqSwrilU1pN54mnkhMEkV9Q0sxY/ZKuAG1L nN5KJEM/B7Az766TEbSM1tFAQIIAHTHnl0kVQD2lAQlumKiY9g8ifnnuolw/BtmnF3I0 Tkf1PaVcjzr6fmUcLi8t7IqzNLW5GMc24GpysXNXzZFi4Fqd8zfTsMh3O8psHJezJvhT 6T3qOU1m0020s5XPqNLeElgmyx1HQmBxe/H6eQlqCLpsjsrahNn8MJMb384pLzzkC2GR ZV9Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796143445; x=1796748245; 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=4D7PKIW/fsQIXjoJ0ImWbDLBm+eq6iM3NLSmsDBG3aU=; b=sP6GFAzE1eD0EUjNIlQZ/ybe/anV5yFNsoesR/WRmPw3m10vl/bJW6JFWPVpSuYhVU XlPZc3Gh8UTqNcULKjWW34kfd5LqrkHAVR40cZfKaewZOH5exCpchan5/gQZDqhZaOGt dnPtY27FakV2441w9JTfcVCuA9w/Nh0OB2Q3HMQVh0BN6Vp53u5BmsvBrvhLr0QEL8zK Ukn1u22VhQ/vcArEwx04hTgAkbNNF6hwKLtVpZQ7fM2GYC+IIVUuiI+tUugclXn7b03l DwFcWGv2Vf05PHmeSspZhAHRkrIkU8i5yROrAZrfDn7YLQS53/4h8P0EJvbAhmTp+GOc vFxw== X-Gm-Message-State: APuU4Z+hFgGbK243qD3XAssd7I3KMNtJzAXVvkFFk1wf45ceMYuFzfUl 0vj+booswpdAV6ka/7YFmYBkRWZohtPR97jIyyrQjvSl8ALSA/wixGWyZDt3WqLtbBNqsEmH52O 5L5/iW107wlRNC3SxeZT7bJ8O96cuBeeXsDuvYHHX+FpEHEyveHfa2jH5l+N7sZl2SB3+ X-Gm-Gg: AZFdTZeHVQsDxdZSwx61DMmjMdvVCX+Nr5rgCaUEpLheRU9xroR/+Zbo48urLubzSHw lgUhUCo57qZC7u856kc7VX68/U0AG4rlUZ+g181KbH/0PwnAjmq/8JN6hAKOQ0PUUDSHiYq/AvX co9Eo07/9+CxQCKX98p3kf1C4b8ZnbEHSRb6vqWQaQy1ErB8YRCBKjWN+TDnVXsL4agI/1Liaic SSUcwpPbGxZUzrS0qLPtIHmQEPZIoY0Vs2j9baSEsUs1wd7bdcztmH/OGC51wH0EAO2DQsvDdAU YquM1FA8Xs9KGk/y91EhOQPApxyd50Wd4jpyvMpIIkQDnRZAidHi+pidQEL9/RNrguW0DXzoXF8 a1LTIJ+/STNqiHFWmyVm8cXQOITcczyfQ2SLJr/TrN2rtEXg78krIXooTxKlKXTLLmd6QGl7Zri eJ6C/hCXs55hUfSArot3wbQ1fFfRrVGHVWKhg85gIxgE4RqXUTAIMVfjEDZjuRGbICfGI3llLOj HjFVfAIAz5x13d6xnd6d1wltBrOku+xJVINxQow39tcoMWeJZj2pOf/5jOWdR55B768vhK8CxX9 oy6rZ2KLL48/TEYhNO1JLo7UApbmlbHY8AkznV2MTx7dEhWLWzCPRXvvsjerQRLD4rr+08HvT96 UjzwNCCq9N5vCY1UKwLc3Hfi4MuNWLO685igW1ESmk1YVnU+E4AFIzAjq3APfGMGca0OFXbU/6Z 9hD7KgjDSZgZNTow== X-Received: by 2002:adf:e014:0:20b0:491:8462:20cc with SMTP id ffacd0b85a97d-4abb400c0cbmr56160645f8f.37.1796143445055; Tue, 01 Dec 2026 08:44:05 -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-4ab6c61f558sm73930787f8f.58.2026.12.01.08.44.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Dec 2026 08:44:04 -0800 (PST) X-Google-Original-From: "Name of user not set (Code Review)" Date: Tue, 1 Dec 2026 16:44:02 +0000 To: Selva Nair , Arne Schwabe Auto-Submitted: auto-generated X-Gerrit-MessageType: newpatchset X-Gerrit-PatchSet: 8 X-Gerrit-Change-Id: I09e55085cde6dbc0040e111a42128527d59832b8 X-Gerrit-Change-Number: 2148 X-Gerrit-Project: openvpn X-Gerrit-ChangeURL: X-Gerrit-Commit: 23523b26a61933863981bb3752e320d1a13fa109 In-Reply-To: References: Thread-Index: PGdlcnJpdC4xNzk0MDU5NDM3MDAwLkkwOWU1NTA4NWNkZTZkYmMwMDQwZTExMWE0MjEyODUyN2Q1OTgzMmI4QGdlcnJpdC5vcGVudnBuLm5ldD4= Message-ID: X-Archived-By: MIME-Version: 1.0 User-Agent: Gerrit/3.14.5 X-Spam-Score: 0.8 (/) X-Headers-End: 1xYQxg-000000002Yb-05eO 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: "Name of user not set \(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: "Name of user not set \(Code Review\)" , Yuriy Darnobyt , openvpn-devel Content-Type: multipart/mixed; boundary="===============2880232678068184982==" 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 --===============2880232678068184982== Content-Transfer-Encoding: 8bit Content-Disposition: inline Content-Type: multipart/alternative; boundary="0Fd2RjRehAg="; charset=UTF-8 --0Fd2RjRehAg= Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Attention is currently required from: Arne Schwabe, Frank Lichtenheld, Gert= Doering, Selva Nair, Yuriy Darnobyt, opidopiopi@gmail=2Ecom=2E Hello Arne= Schwabe, Gert Doering, Selva Nair, I'd like you to reexamine a change=2E= Please visit https://gerrit=2Eopenvpn=2Enet/c/openvpn/+/2148?usp=3Dem= ail to look at the new patch set (#8)=2E The following approvals got outd= ated and were removed: Code-Review+2 by Selva Nair, Code-Review-1 by Gert D= oering The change is no longer submittable: Code-Review and checks~ChecksS= ubmitRule are unsatisfied now=2E Change subject: Implement multiline resp= onses 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 = --- M doc/management-notes=2Etxt M src/openvpn/man= age=2Ec M src/openvpn/manage=2Eh 3 files changed, 164 insertions(+), 21 del= etions(-) git pull ssh://gerrit=2Eopenvpn=2Enet:29418/openvpn refs/chan= ges/48/2148/8 diff --git a/doc/management-notes=2Etxt b/doc/management-not= es=2Etxt index a98b45f=2E=2E8c8c52e 100644 --- a/doc/management-notes=2Etxt= +++ b/doc/management-notes=2Etxt @@ -617,23 +617,109 @@ COMMAND -- pkcs11= -id-count (OpenVPN 2=2E1 or higher) -------------------------------------= -------------- -Retrieve available number of certificates=2E +Retrieve av= ailable 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 managemen= t client versions >=3D 7: + + pkcs11-id-count + +The reply is a decimal= count followed by "END" on a separate line=2E + +Example: + + pkcs11-i= d-count + 5 + END + COMMAND -- pkcs11-id-get (OpenVPN 2=2E1 or hi= gher) ------------------------------------------------- +Retrieve PKCS#1= 1 certificates=2E + +For management client versions < 7: + + pkcs11-id-get= + Retrieve certificate by index, the ID string should be provided= as PKCS#11 identity, the blob is a base 64 encoded certificate=2E Exam= ple: pkcs11-id-get 1 - PKCS11ID-ENTRY:'1', ID:'', BLOB:'<= snip>' + >PKCS11ID-ENTRY:'1', ID:'', BLOB:'' + +For managemen= t client versions >=3D 7: + + pkcs11-id-get + pkcs11-id-get + pkcs11-id-get all + +Retrieve a single PKCS#11 certificate at i= ndex 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 encode= d 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" inst= ead 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 + +Exampl= e 2: + + Management interface client sends: + + pkcs11-id-get 1 3 + + = OpenVPN daemon responds with: + + 1,, + 2,, + END + +Example 3: + + Management interface client sends: + + pk= cs11-id-get all + + OpenVPN daemon with 3 PKCS#11 certificates responds wi= th: + + 0,, + 1,, + 2,, = + END + +Example 4: + + Management interface client sends: + + pkcs1= 1-id-get all + + OpenVPN daemon with 3 PKCS#11 certificates fails to retri= eve 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 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", "LOG", di= ff --git a/src/openvpn/manage=2Ec b/src/openvpn/manage=2Ec index 37e9b75=2E= =2Ee274cc4 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, "%u,%s,%s", i, id, base64); + } + else + = { + error =3D true; + msg(M_CLIENT, "E= RROR: Failed to load PKCS#11 id at index: %u", 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: 8 Gerrit-Owner: opidopiopi@gmail=2Ecom Gerrit-Reviewer: Arne Schwabe= Gerrit-Reviewer: Gert Doering Gerrit-Reviewer: Selva Nair Gerrit-= CC: Frank Lichtenheld Gerrit-CC: Yuriy Darnobyt <= yura=2Euddr@gmail=2Ecom> Gerrit-CC: openvpn-devel Gerrit-Attention: Selva Nair Ge= rrit-Attention: opidopiopi@gmail=2Ecom Gerrit-Attention: Arne Schwabe Gerrit-Attention: Gert Doering Gerrit-Attention: Frank Lichtenheld Gerrit= -Attention: Yuriy Darnobyt --0Fd2RjRehAg= Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable

Attention is cur= rently required from: Arne Schwabe, Frank Lichtenheld, Gert Doering, Selva = Nair, Yuriy Darnobyt, opidopiopi@gmail=2Ecom=2E

opidopiopi@gmail=2E= com uploaded patch set #8 to this change=2E

View Chang= e

The following approvals got outdated and were removed: Code-Rev= iew+2 by Selva Nair, Code-Review-1 by Gert Doering

The change is no l= onger submittable: Code-Review and checks~ChecksSubmitRule are unsatisfied = now=2E

Implement multiline responses for pkcs11-id command=
s

Responses to the management interface commands pkcs11-id-[get|coun= t] did
not follow the standard syntax, but instead looked like notificat= ions=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 cli= ent announces a management version >=3D 7 the responses conform to
th= e 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&= quot; to
"end" - 1=2E Failures to retrieve an id will return a= partial response
terminated by an "ERROR" message including t= he erroneous index=2E
The response 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: I09e55085cde6dbc0040e111a42128527d59832b8
Si= gned-off-by: Marvin Wunderlich <opidopiopi@gmail=2Ecom>
---
M d= oc/management-notes=2Etxt
M src/openvpn/manage=2Ec
M src/openvpn/mana= ge=2Eh
3 files changed, 164 insertions(+), 21 deletions(-)

=
git pull ssh://gerrit=2Eopenvpn=2Enet:29418/openvpn refs/chan=
ges/48/2148/8
diff --git a/doc/management-notes=2Etxt b/doc/managem=
ent-notes=2Etxt
index a98b45f=2E=2E8c8c52e 100644--- a/doc/management-notes=2Etxt
+++ b/doc/managemen= t-notes=2Etxt
@@ -617,23 +617,109 @@
COMMA= ND -- pkcs11-id-count (OpenVPN 2=2E1 or higher)
---------= ------------------------------------------

-Retrieve available number of certifi= cates=2E
+Retrieve av= ailable number of PKCS#11 certificates=2E
+
+
+ pkcs11-id-count
+The reply is &qu= ot;>PKCS11ID-COUNT:<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&quo= t; on a separate line=2E
+
+Example:
+
+ pkcs11-id-count
+ 5
+ END
+
COMMAND -- pkcs11-id-get (OpenVPN 2=2E1 or hig= her)
-------------------------------------------------

+Retri= eve PKCS#11 certificates=2E
+
+For managem= ent client versions < 7:
+
+ pkcs11-id= -get <index>
+<= /span>
Retrieve certificate by index, the ID string should be pro= vided
as PKCS#11 identity, the blob is a base 64 encoded c= ertificate=2E

Example:
=
pkcs11-id-get 1
- PKCS11ID-ENTRY:'1', ID:'<snip>'= , BLOB:'<snip>'
+ >PKCS11ID-ENTRY:'1', ID:'<id>', BLO= B:'<blob>'
+
+For management= client versions >=3D 7:
+
+ pkcs11-id= -get <index>
+ = pkcs11-id-get <start> <end>
+ pkcs11-id-get all
+
+Retrieve a single PKCS#11 certificate at index <index> or multiple<= /span>
+PKCS#11 certificates= from index <start> to <end>-1=2E Alternatively
+<start> =3D "all" r= etrieves 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 b= e partial and terminated by "ERROR: =2E=2E" instead of "END&= quot;=2E
+The "E= RROR" message will include the index of failure=2E
+
+Example 1:
+
+ Managemen= t interface client sends:
+
+ pkcs11-id= -get 1
+
+ OpenVPN daemon responds with:<= /span>
+
+ 1,<id>,<blob>+ END
+
+Example 2:
+
+ Management = interface client sends:
+
+ pkcs11-id-g= et 1 3
+
+ OpenVPN daemon responds with:<= /span>
+
+ 1,<id_a>,<blob_a>
+ 2,<id_b>,<bl= ob_b>
+ END
+
+Example 3:
+
+ Management interface client sends:
+
+ pkcs11-id-get all
+
+ OpenVPN dae= mon with 3 PKCS#11 certificates responds with:
+
+ 0,<id_a>,<blob_a>
+ 1,<id_b>,<blob_b>
+ 2,<id_c>,<blob_c>
+ END
+
+Example 4:
+
+ Managem= ent interface client sends:
+
+ pkcs11-= id-get all
++ OpenVPN daemon with 3 PKCS= #11 certificates fails to retrieve index 1
+
+ 0,<id_a>,<blob_a>
+ 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 commands which print multiple lines of output,=
- the last line wil= l be "END"=2E
+ the last line will be "END" or "ERROR: [text]"= =2E

(3) Real-time messages will be in th= e form ">[source]:[text]",
where source i= s "CLIENT", "ECHO", "FATAL", "HOLD"= , "INFO", "LOG",
diff --git a/src/openv= pn/manage=2Ec b/src/openvpn/manage=2Ec
index 37e9b75=2E=2Ee= 274cc4 100644
--- a/src/openvpn/manage=2Ec
= +++ b/src/openvpn/manage=2Ec
@@ -74,6 +74,7 @@
MCV_USERNAME_ONLY =3D 4,

MCV_MULTILINE_PASSWO= RD =3D 5,
MCV_PREFERRED_USERNAME =3D 6,
+ MCV_MULTILINE_PKCS11_RESPONSE = =3D 7,

};

struct manage= ment *management; /* GLOBAL */
@@ -120,7 +121,8 @@ msg(M_CLIENT, "pid : Show process ID o= f the current OpenVPN process=2E");
#ifdef ENABLE_PKC= S11
msg(M_CLIENT, "pkcs11-id-count : Get n= umber 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 index =3D i=2E");
+ msg(M_CLIENT, " F= or version >=3D 7 also i to j-1 or all=2E");
#endi= f
msg(M_CLIENT, "client-auth CID KID : Authent= icate 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 management *man)
{
- ms= g(M_CLIENT, ">PKCS11ID-COUNT:%d", pkcs11_management_id_count()= );
-}
-
-static void
-man_pkcs11_id_get(struct management *man, const int index)
<= span style=3D"color: hsl(0, 100%, 40%);">-{

- 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_CL= IENT, ">PKCS11ID-ENTRY:'%d', ID:'%s', BLOB:'%s&= #39;", index, id, base64);
+ msg(M_CLIENT, "%d", pkcs11_management_id_coun= t());
+ msg(M_= CLIENT, "END");
}
else<= /span>
{
= - msg(M_CLIENT, ">PKCS11ID-ENTRY:'%d'", index);=
+ msg(M_CLIEN= T, ">PKCS11ID-COUNT:%d", pkcs11_management_id_count());=
+ }
+}
+
+st= atic void
+man_pkcs11= _id_get(struct management *man, const char *p1, const char *p2)
<= span style=3D"color: hsl(120, 100%, 40%);">+{

+ ASSERT(p1);
+
+ {
+ msg(M_CLIENT, "ERROR: Listing mu= ltiple ids is only supported for version >=3D %d", MCV_MULTILINE_PK= CS11_RESPONSE);
+ = return;
}

- free(id);
- free(base64);
+ if (man->connection=2Eclient_version >=3D M= CV_MULTILINE_PKCS11_RESPONSE)
+ {
+ = int count =3D pkcs11_management_id_count();
+ int from =3D atoi(p1);
+ int to =3D p2 ? atoi(p2) : f= rom + 1;
+
= + if (streq(p1, "al= l"))
+ {<= /span>
+ 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, &= amp;id, &base64))
+ {
+ = msg(M_CLIENT, "%u,%s,%s", i, id, base64);
<= span style=3D"color: hsl(120, 100%, 40%);">+ }

+ else
+ {
+ error =3D true;
+ msg(M_CLIENT, &quo= t;ERROR: Failed to load PKCS#11 id at index: %u", i);

+ }
+ free(id);
+ free(base64);
+ }

+ if (!error)
+ {
+ msg(M_CLIENT, "END");<= br>+ }
+ }
+ else
+ {
+ = int index =3D atoi(p1);
+
+ = char *id =3D NULL;
+ = char *base64 =3D NULL;
+
+ i= f (pkcs11_management_id_get(index, &id, &base64))
+ {
+ msg(M_CLIENT, ">PKCS11ID-EN= TRY:'%d', ID:'%s', BLOB:'%s'", index, id, base= 64);
+ }
+ else
+ {

+ msg(M_CLIENT, ">PKCS1= 1ID-ENTRY:'%d'", index);
+ }
+ free(id);
+ free(base64);
+ }
}

#endif = /* ifdef ENABLE_PKCS11 */
@@ -1813,9 +1870,9 @@
<= span> }

else if (streq(p[0], "pkcs11-id-get&q= uot;))
{
- 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=2Ehindex 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"

-#define MANAGEMENT_VERSION = 6

+#define M= ANAGEMENT_VERSION 7
#define MANAGEMENT_N_= PASSWORD_RETRIES 3
#define MANAGEMENT_LOG_HISTORY_IN= ITIAL_SIZE 100
#define MANAGEMENT_ECHO_BUFFER_SIZE = 100

To view, visit change 2148=2E To unsubscribe, or = for help writing mail filters, visit settings=2E

Gerr= it-MessageType: newpatchset
Gerrit-Proj= ect: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I09e55085cde6dbc0040e111a= 42128527d59832b8
Gerrit-Change-Number: = 2148
Gerrit-PatchSet: 8
Gerrit-Owner: opidopiopi@gmail=2Ecom
Gerrit-Reviewer: Arne Schwabe <arne-openvpn@rfc2549= =2Eorg>
Gerrit-Reviewer: Gert Doerin= g <gert@greenie=2Emuc=2Ede>
Gerri= t-Reviewer: Selva Nair <selva=2Enair@gmail=2Ecom>
Gerrit-CC: Frank Lichtenheld <frank@lichtenheld=2Ecom= >
Gerrit-CC: Yuriy Darnobyt <yura= =2Euddr@gmail=2Ecom>
Gerrit-CC: open= vpn-devel <openvpn-devel@lists=2Esourceforge=2Enet>
Gerrit-Attention: Selva Nair <selva=2Enair@gmail=2Eco= m>
Gerrit-Attention: opidopiopi@gmai= l=2Ecom
Gerrit-Attention: Arne Schwabe = <arne-openvpn@rfc2549=2Eorg>
Gerr= it-Attention: Gert Doering <gert@greenie=2Emuc=2Ede>
Gerrit-Attention: Frank Lichtenheld <frank@lichtenhe= ld=2Ecom>
Gerrit-Attention: Yuriy Da= rnobyt <yura=2Euddr@gmail=2Ecom>
--0Fd2RjRehAg=-- --===============2880232678068184982== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline --===============2880232678068184982== 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 --===============2880232678068184982==--