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 20AED606A32C for ; Wed, 2 Dec 2026 08:40:00 +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=kGORAYmo; 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=LLY9j8Oq; 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=NPATmfgn; dkim=neutral header.d=openvpn.net header.i=@openvpn.net header.a=rsa-sha256 header.s=google header.b=UANBcfh3 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=RmRs8eHWEdsen7eGyj2YzdehEs44oaHL4NFLmtUx/3k=; b=kGORAYmo9Kd8GUfNZww5S5yujh xqiYzE4+PkpYapOkvrTJMIRuxsxmXDVfQ/B7JE8XAWqXyx1oPdlwjZyMyT5ZLmG611k0bobml0NrG ertGkcr7Xp2vYtiwpLbLgZrNqdMmsQWhAh/rSpX5Ho0+na81EHYwg2cOYt42pOKm8Xfs=; 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 1xYfsd-000000006sQ-3StM; Wed, 02 Dec 2026 08:39:59 +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 1xYfsc-000000006sJ-01Iy for openvpn-devel@lists.sourceforge.net; Wed, 02 Dec 2026 08:39:58 +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=izEhJoKyJqngsI0v8SnhV9M8V+50LLV/DlDsWNUa+3M=; b=LLY9j8Oq7xMFS54B2U7xOqAp26 Z5BMWIEc98+1SC0e3dSBbfeYmpgW1x++EY1fBGL4k6mhCXtoARXup97xCJhw3/xB1Zm4CLz64mTQx jOjYx996mTU4fg9oSqzOZ1YkjtAH9l/6Csh2/LKXHTfYkuC2Ntmk/Xot/32dcWgw/UUM=; 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=izEhJoKyJqngsI0v8SnhV9M8V+50LLV/DlDsWNUa+3M=; b=NPATmfgnnvnfOln8JO7OvAXDB8 DhWNYiHnN7f6HhGVB0mqXWcC7RNBCIOui7PClmgupAIARD6l97laASVD7l65JsTxBMnpJC6pT7Sre fAtB694n2UfenyJ1zQrNjrCoVUTVS82jNyi6Udl5K82IXmoe6lsnlTbIvmtMCwJdSNw0=; Received: from mail-wm1-f51.google.com ([209.85.128.51]) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.100.1) id 1xYfsZ-00000000564-1ryX for openvpn-devel@lists.sourceforge.net; Wed, 02 Dec 2026 08:39:57 +0000 Received: by mail-wm1-f51.google.com with SMTP id 5b1f17b1804b1-4bb69f5b161so84604235e9.0 for ; Wed, 02 Dec 2026 00:39:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=openvpn.net; s=google; t=1796200789; x=1796805589; 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=izEhJoKyJqngsI0v8SnhV9M8V+50LLV/DlDsWNUa+3M=; b=UANBcfh3DzYDTQtxIr4nWQga3VuaZ8OgpyDQp4bX6XD7qBKniBi3MlJcpbOs+bNeKi 8ORPZIs5TYyBH3LX38LsmUeIESQaMNozFUb1aWNAF3kJosscX16IuPwqBJ8NsVuDtMxa uVYcuEWDQR2gZmXf9G+oZrQAKQHK/Jx/37koX28WntjQ0z9PyQOIKr9kyL/FFBfjSu/l /GjJM6+tzdsLR3AKDJfyj1ho7JbmGvSqWdYlQpvPGM1WdV0psGXr17j911cwH70t3wMR 4qRU54M5uwOLHpH59sc7c/3PHukeoDWydvT2gPnRmYbq1oD9Tn171mSL5vayQE0IaEBT 8Yaw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796200789; x=1796805589; 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=izEhJoKyJqngsI0v8SnhV9M8V+50LLV/DlDsWNUa+3M=; b=xVS036W46m6dineRqTtHZWNZMj9slYY6jUrUC7do99b/t+w+Q6+Tg1v2bZy03NgAbZ 4/7z+yByjL3dhkgGEeVH26mDFIpw+Phb3Q189DXqIh19OExAxpdOLcbQXrPC1aPSygR6 p9VpyXVnJrQPwO0zTYsNipPhjeVWpnRhN/QEPxsNcJR+oQm6fyNQJLufNIV32BuX8kqa 8NJCagnGmlhEQGhSw3BoFYn/CBMMDUJvfLFmEAXDUFfemdC8LDG/wJeMgoSJsFSQuVvP fCyXappvWNOUQOaX8u3FBodHoPRU/5fNlgnRFVVT2TfofqNJDm/9BwRqzR2cuxgSMvo+ rFfg== X-Forwarded-Encrypted: i=1; AL+hErG/RhKZAXpzmtBWHqvHqGo9r83RuSc16UivrxEiemrr5JQGUg4iecuHSjenT80GJJAKuFjjjOKgmQUuYwIS@lists.sourceforge.net X-Gm-Message-State: APuU4Z8UWVzyZVL2YJmsrPhCHt5OU6ZjQB1WzFxz8RJ1xC1SQsikw4QE cXFVs6NV0uRo2V8bWSjYHvnvHZbJ/aIyzlD2HDpC59g9btbJZExspeaLDnCXgc/42WyKNHgUdfu IWa7WvbwI2bGkbS3bFdzHZ+O0okx9OpqpxaTFIfV5Y8sryHt/B2DNIbx47+QveJDOIep7 X-Gm-Gg: AZFdTZfXeZNZWIYRTxo7kZJaFFCKeNAo+DG67lgdf5Pw3UdkOkxNwp/cbjWjJkTY6L0 mbEWSnNOUeKfmMtzDM1ZEL1QuCdroMXyKX8fv0bWwDQFHmSB7MUFDosFzITLE9rdyuCJ8mGEzIv BIINThcCbOCUN4j8Hxq/bc5fui6BzeFhlJLe+FVk9aubrUScPBhcO7i6ODjt1h0Uu9lpmNhYYPb OfoMWCY85nMeg8gYee9wwfxaXkxqkX+xyaNWOH80XgkGJJ8Y9Ja8Tj+jIqlhwmRcI1fMeZc5GhD qBbtR6vO64RTimjOPQIKxXflwpsrQWdhLh0Vsp7G+NeHz3JOCE8D59ADGjSigyqlKyt8BASqauK h7xA5qp268Wt2ADkPXrW0cplN3PL6xDEFcK74Qq1FRpll0hpsl/qB6OtfejW41GqrkxDSMuLbRL MkQGxC70BlOeNx9BBsAByJT93Hg+VO4YvMKqtEBIAOVXkf9nOqQsjBXM10/dt6Wxuky7+RC4zf9 IuRXgDJ0M4vvwqJRk9mVBpSH5rQp0pZ159XyvFzyhucFwYcw076Hsj7+arN80AwjlaaS4pelN+3 w0YcOoh9QaBwJHmREXy1d/Z5qY0fVx9qfaR1sltIndNfvi14QN43DFA7587x/IHgSTVC3tSUqmC Mw6CzXuI499fNS7mx+lpQXjuMazp6DvCDyoId5dSg3HYYh3RDAhJ1nEJMUDPhw1j6jtob+WxvJu 8IUV56db5biT6oMA== X-Received: by 2002:a05:600c:19d0:b0:4bb:ac6c:de67 with SMTP id 5b1f17b1804b1-4bbac6ce1aemr395182765e9.14.1796200788656; Wed, 02 Dec 2026 00:39:48 -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-4bbc98e876asm190089065e9.7.2026.12.02.00.39.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Dec 2026 00:39:48 -0800 (PST) X-Google-Original-From: "Gert Doering (Code Review)" Date: Wed, 2 Dec 2026 08:39:47 +0000 To: Marvin Wunderlich Auto-Submitted: auto-generated X-Gerrit-MessageType: merged 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-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: 1xYfsZ-00000000564-1ryX 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, yura.uddr@gmail.com Cc: "Gert Doering \(Code Review\)" , Yuriy Darnobyt , Arne Schwabe , openvpn-devel Content-Type: multipart/mixed; boundary="===============4625320256734197020==" 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 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 --===============4625320256734197020== Content-Transfer-Encoding: 8bit Content-Disposition: inline Content-Type: multipart/alternative; boundary="YpW00qsgnhA="; charset=UTF-8 --YpW00qsgnhA= Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Gert Doering has submitted this change=2E ( https://gerrit=2Eopenvpn=2Enet/= c/openvpn/+/2148?usp=3Demail ) 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 Gerrit URL: https://gerrit=2Eopenvpn=2Enet/c/openvpn= /+/2148 Message-Id: <20261201224313=2E17664-1-gert@greenie=2Emuc=2Ede> URL:= https://www=2Email-archive=2Ecom/openvpn-devel@lists=2Esourceforge=2Enet/m= sg42330=2Ehtml Signed-off-by: Gert Doering --- M = doc/management-notes=2Etxt M src/openvpn/manage=2Ec M src/openvpn/manage=2E= h 3 files changed, 164 insertions(+), 21 deletions(-) diff --git a/doc/= management-notes=2Etxt b/doc/management-notes=2Etxt index a98b45f=2E=2E8c8c= 52e 100644 --- a/doc/management-notes=2Etxt +++ b/doc/management-notes=2Etx= t @@ -617,23 +617,109 @@ COMMAND -- pkcs11-id-count (OpenVPN 2=2E1 or hig= her) --------------------------------------------------- -Retrieve avail= able number of certificates=2E +Retrieve available number of PKCS#11 certif= icates=2E + +For management client versions <7: + + pkcs11-id-count + += The reply is ">PKCS11ID-COUNT:"=2E Example: pkcs11-id-cou= nt >PKCS11ID-COUNT:5 +For management client versions >=3D 7: + + = pkcs11-id-count + +The reply is a decimal count followed by "END" on a se= parate line=2E + +Example: + + pkcs11-id-count + 5 + END + COM= MAND -- pkcs11-id-get (OpenVPN 2=2E1 or higher) -------------------------= ------------------------ +Retrieve PKCS#11 certificates=2E + +For managem= ent 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 Example: pkcs11-id-get 1 - = PKCS11ID-ENTRY:'1', ID:'', BLOB:'' + >PKCS11ID-ENTRY:'1'= , ID:'', BLOB:'' + +For management client versions >=3D 7: + + p= kcs11-id-get + pkcs11-id-get + pkcs11-id-get all + = +Retrieve a single PKCS#11 certificate at index or multiple +PKCS#1= 1 certificates from index to -1=2E Alternatively + =3D = "all" retrieves all PKCS#11 certificates=2E A comma separated +list includi= ng 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 pa= rtial and terminated by "ERROR: =2E=2E" instead of "END"=2E +The "ERROR" me= ssage will include the index of failure=2E + +Example 1: + + Management in= terface client sends: + + pkcs11-id-get 1 + + OpenVPN daemon responds w= ith: + + 1,, + END + +Example 2: + + Management interface = client sends: + + pkcs11-id-get 1 3 + + OpenVPN daemon responds with: += + 1,, + 2,, + END + +Example 3: + + = Management interface client sends: + + pkcs11-id-get all + + OpenVPN da= emon with 3 PKCS#11 certificates responds with: + + 0,, + = 1,, + 2,, + END + +Example 4: + + Man= agement interface client sends: + + pkcs11-id-get all + + OpenVPN daemo= n with 3 PKCS#11 certificates fails to retrieve index 1 + + 0,, + ERROR: Failed to load PKCS#11 id at index: 1 + COMMAND -- cli= ent-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 mes= sages will be in the form ">[source]:[text]", where source is "CLIENT"= , "ECHO", "FATAL", "HOLD", "INFO", "LOG", diff --git a/src/openvpn/manage= =2Ec b/src/openvpn/manage=2Ec index 37e9b75=2E=2E6adc2c4 100644 --- a/src/o= penvpn/manage=2Ec +++ b/src/openvpn/manage=2Ec @@ -74,6 +74,7 @@ MCV_U= SERNAME_ONLY =3D 4, MCV_MULTILINE_PASSWORD =3D 5, MCV_PREFERRED_U= SERNAME =3D 6, + MCV_MULTILINE_PKCS11_RESPONSE =3D 7, }; struct mana= gement *management; /* GLOBAL */ @@ -120,7 +121,8 @@ msg(M_CLIENT, "pi= d : Show process ID of the current OpenVPN process=2E");= #ifdef ENABLE_PKCS11 msg(M_CLIENT, "pkcs11-id-count : Get num= ber 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_CLI= ENT, " 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-auth-nt CID KI= D : Authenticate client-id/key-id CID/KID"); @@ -894,26 +896,81 @@ static = void man_pkcs11_id_count(const struct management *man) { - msg(M_CLIEN= T, ">PKCS11ID-COUNT:%d", pkcs11_management_id_count()); -} - -static void -= man_pkcs11_id_get(struct management *man, const int index) -{ - char *id= =3D NULL; - char *base64 =3D NULL; - - if (pkcs11_management_id_get(= index, &id, &base64)) + if (man->connection=2Eclient_version >=3D MCV_MU= LTILINE_PKCS11_RESPONSE) { - msg(M_CLIENT, ">PKCS11ID-ENTRY:'%d= ', ID:'%s', BLOB:'%s'", index, id, base64); + msg(M_CLIENT, "%d", pk= cs11_management_id_count()); + msg(M_CLIENT, "END"); } els= e { - msg(M_CLIENT, ">PKCS11ID-ENTRY:'%d'", index); + ms= g(M_CLIENT, ">PKCS11ID-COUNT:%d", pkcs11_management_id_count()); + } +} = + +static void +man_pkcs11_id_get(struct management *man, const char *p1, c= onst char *p2) +{ + ASSERT(p1); + + if ((streq(p1, "all") || p2 !=3D = NULL) && man->connection=2Eclient_version < MCV_MULTILINE_PKCS11_RESPONSE) = + { + msg(M_CLIENT, "ERROR: Listing multiple ids is only supporte= d 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 p= kcs11_management_id_count(); + int from =3D atoi(p1); + int t= o =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; + cha= r *base64 =3D NULL; + + if (pkcs11_management_id_get(i, &id, &ba= se64)) + { + msg(M_CLIENT, "%d,%s,%s", i, id, bas= e64); + } + else + { + erro= r =3D true; + msg(M_CLIENT, "ERROR: Failed to load PKCS#11 i= d at index: %d", i); + } + free(id); + fre= e(base64); + } + if (!error) + { + msg(M_CL= IENT, "END"); + } + } + else + { + int index =3D ato= i(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, b= ase64); + } + else + { + msg(M_CLIENT, ">PK= CS11ID-ENTRY:'%d'", index); + } + free(id); + free(bas= e64); + } } #endif /* ifdef ENABLE_PKCS11 */ @@ -1813,9 +1870,9 @@ = } else if (streq(p[0], "pkcs11-id-get")) { - if (man_n= eed(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=2E= h b/src/openvpn/manage=2Eh index 697f830=2E=2E7f26a35 100644 --- a/src/open= vpn/manage=2Eh +++ b/src/openvpn/manage=2Eh @@ -50,7 +50,7 @@ #include "so= cket_util=2Eh" #include "mroute=2Eh" -#define MANAGEMENT_VERSION = 6 +#define MANAGEMENT_VERSION 7 #define MANAGEM= ENT_N_PASSWORD_RETRIES 3 #define MANAGEMENT_LOG_HISTORY_INITIAL_SIZE= 100 #define MANAGEMENT_ECHO_BUFFER_SIZE 100 -- To view, visit h= ttps://gerrit=2Eopenvpn=2Enet/c/openvpn/+/2148?usp=3Demail To unsubscribe, = or for help writing mail filters, visit https://gerrit=2Eopenvpn=2Enet/sett= ings?usp=3Demail Gerrit-MessageType: merged Gerrit-Project: openvpn Gerrit= -Branch: master Gerrit-Change-Id: I09e55085cde6dbc0040e111a42128527d59832b8= Gerrit-Change-Number: 2148 Gerrit-PatchSet: 10 Gerrit-Owner: Marvin Wunder= lich Gerrit-Reviewer: Arne Schwabe Gerrit-Reviewer: Frank Lichtenheld = Gerrit-Reviewer: Gert Doering Gerrit-Reviewer: Se= lva Nair Gerrit-CC: Yuriy Darnobyt Gerrit-CC: openvpn-devel --YpW00qsgnhA= Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable

Gert Doering submitted this change=2E

View Change

Implement multiline responses for =
pkcs11-id commands

Responses to the management interface commands pk= cs11-id-[get|count] did
not follow the standard syntax, but instead look= ed like notifications=2E

Introduce a new management interface versio= n so that clients announcing
versions >=3D 7 will receive responses i= n the new format while keeping
compatibility for older client versions= =2E

If a client announces a management version >=3D 7 the respons= es 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 rang= e 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 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: I09e55085cde6dbc0040e111a421= 28527d59832b8
Signed-off-by: Marvin Wunderlich <opidopiopi@gmail=2Eco= m>
Gerrit URL: https://gerrit=2Eopenvpn=2Enet/c/openvpn/+/2148
Mes= sage-Id: <20261201224313=2E17664-1-gert@greenie=2Emuc=2Ede>
URL: h= ttps://www=2Email-archive=2Ecom/openvpn-devel@lists=2Esourceforge=2Enet/msg= 42330=2Ehtml
Signed-off-by: Gert Doering <gert@greenie=2Emuc=2Ede>=
---
M doc/management-notes=2Etxt
M src/openvpn/manage=2Ec
M sr= c/openvpn/manage=2Eh
3 files changed, 164 insertions(+), 21 deletions(-)=

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-no= tes=2Etxt
@@ -617,23 +617,109 @@
COMMAND -= - pkcs11-id-count (OpenVPN 2=2E1 or higher)
-------------= --------------------------------------

-Retrieve available number of certificate= s=2E
+Retrieve availa= ble number of PKCS#11 certificates=2E
+
+F= or management client versions <7:
+
+ = pkcs11-id-count
+<= /span>
+The reply is "&= gt;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"= on a separate line=2E
+Example:<= br>+
+ pkcs11-id-count
+ 5
+ END
+
COMMAND -- pkcs11-id-get (OpenVPN 2=2E1 or higher)=
-------------------------------------------------<= br>
+Retrieve = PKCS#11 certificates=2E
+
+For management = client versions < 7:
+
+ pkcs11-id-get= <index>
+
Retrieve certificate by index, the ID string should be provide= d
as PKCS#11 identity, the blob is a base 64 encoded certi= ficate=2E

Example:

pkcs11-id-get 1
- PKCS11ID-ENTRY:'1', ID:'<snip>', BL= OB:'<snip>'
+ >PKCS11ID-ENTRY:'1', ID:'<id>', BLOB:&#= 39;<blob>'
= +
+For management cli= ent versions >=3D 7:
+
+ pkcs11-id-get= <index>
+ pkc= s11-id-get <start> <end>
+ pkcs11-id-get all
+
+Re= trieve a single PKCS#11 certificate at index <index> or multiple
+PKCS#11 certificates fro= m index <start> to <end>-1=2E Alternatively
+<start> =3D "all" retri= eves all PKCS#11 certificates=2E A comma separated
+list including index, PKCS#11 id and the bas= e 64 encoded certificate
+will be returned=2E If any id retrieval results in a failure, the retu= rned
+list will be pa= rtial and terminated by "ERROR: =2E=2E" instead of "END"= ;=2E
+The "ERROR= " message will include the index of failure=2E
+
+Example 1:
+
+ Management = interface client sends:
+
+ pkcs11-id-g= et 1
+
+ OpenVPN daemon responds with:
+
+ 1,<id>,<blob>
<= span style=3D"color: hsl(120, 100%, 40%);">+ 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=2E6= adc2c4 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, "%d,%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: %d", 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: merged
Gerrit-Project: = openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I09e55085cde6dbc0040e111a42128= 527d59832b8
Gerrit-Change-Number: 2148 =
Gerrit-PatchSet: 10
Gerrit-Owner: Marvin Wunderlich <opidopiopi@gmail=2Ec= om>
Gerrit-Reviewer: Arne Schwabe &l= t;arne-openvpn@rfc2549=2Eorg>
Gerrit= -Reviewer: Frank Lichtenheld <frank@lichtenheld=2Ecom>
Gerrit-Reviewer: Gert Doering <gert@greenie=2Emuc= =2Ede>
Gerrit-Reviewer: Selva Nair &= lt;selva=2Enair@gmail=2Ecom>
Gerrit-= CC: Yuriy Darnobyt <yura=2Euddr@gmail=2Ecom>
Gerrit-CC: openvpn-devel <openvpn-devel@lists=2Esourceforge= =2Enet>
--YpW00qsgnhA=-- --===============4625320256734197020== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline --===============4625320256734197020== 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 --===============4625320256734197020==--