Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rqyYI-00EyOp-CJ for pgsql-general@arkaria.postgresql.org; Sun, 31 Mar 2024 17:01:02 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1rqyXH-00CyQD-Ab for pgsql-general@arkaria.postgresql.org; Sun, 31 Mar 2024 16:59:59 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rqyXG-00CyQ5-W4 for pgsql-general@lists.postgresql.org; Sun, 31 Mar 2024 16:59:58 +0000 Received: from mail.hjp.at ([212.17.106.138] helo=rorschach.hjp.at) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rqyXB-007q3D-Nq for pgsql-general@lists.postgresql.org; Sun, 31 Mar 2024 16:59:58 +0000 Received: by rorschach.hjp.at (Postfix, from userid 1000) id 754B218634; Sun, 31 Mar 2024 18:59:51 +0200 (CEST) Date: Sun, 31 Mar 2024 18:59:51 +0200 From: "Peter J. Holzer" To: pgsql-general@lists.postgresql.org Subject: Re: how to check if the license is expired. Message-ID: <20240331165951.6qmddjdcwnz6j65j@hjp.at> Mail-Followup-To: pgsql-general@lists.postgresql.org References: MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="72e772u2j4fbxje2" Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --72e772u2j4fbxje2 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On 2024-03-30 09:23:15 -0400, Ron Johnson wrote: > On Sat, Mar 30, 2024 at 9:15=E2=80=AFAM =E9=BB=84=E5=AE=81 wrote: >=20 > I want to develop a postgresql paid extension, then there is a local > license file, how do I check if the license file is expired, check it= once > at each api execution, will that affect the performance of the api, is > there any other way? >=20 >=20 > What you're really asking is "how do I read a file from an extension?". > =C2=A0 We often chide users for falling into the "XY problem"[1] trap, so think it's nice that =E9=BB=84=E5=AE=81 asks about the bigger picture. I can't help with the extension (never wrote one), but a few thoughts: Basically I see three ways to get at the license information: * from a file (as mentioned) * from a database table * over the network (e.g. from a license server) On my (not very fast) laptop I can open and read a small text file in about 25 =C2=B5s. Selecting one row from a small database table takes about= 100 =C2=B5s, which is quite a bit slower but I tested that from an external process. A stored procedure would be faster than that and possibly even faster than the file access. A query over the network is unlikely to be faster. Plus of course you need to check the contents, which likely involves some cryptographic operation. Checking a 2048 bit RSA signature takes about 30 =C2=B5s on my laptop, most other algorithms are slower (unless you go with a simple HMAC which wouldn't be secure). So realistically we are somewhere in the 50 to 200 =C2=B5s range. Is this an acceptable performance penalty per API call? If not, is it really necessary to check this on every call? Maybe it can be done just once per session or once per hour. hp [1] You have problem X and think that Y is part of the solution. So you ask how to achieve Y. However, Z would be better than Y for solving X, but nobody can tell you because they don't know about X. --=20 _ | Peter J. Holzer | Story must make more sense than reality. |_|_) | | | | | hjp@hjp.at | -- Charles Stross, "Creative writing __/ | http://www.hjp.at/ | challenge!" --72e772u2j4fbxje2 Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEETtJbRjyPwVTYGJ5k8g5IURL+KF0FAmYJloAACgkQ8g5IURL+ KF2low/+I6e1TDngZ7M7+ehxLBpprUP4v7LwJ1evPJPgGR0b+8terZNXrwegmG4u KBnUuBM030KUT51uuSNKB/FRJvO7gQsI6XVUOJ8vIPorTFkInimZfnRk8YEH25w0 HyT+lPtNHnR46V1xPkqqyUEX/zclORQNO9asubnCE56olIn5Xe1P9Y45FcTFRk+F pOg8My/fpbgSz5/uu16uHC5i3XldcRq1xmm+X4O65hKJXARh+vY7V8VrIy2G/U+E /l6F0KEBbQwRMsN/MPzof3S2/VcF0wZNN3/f3Pvna7MuX9yZ3CwQ86TCK0K3KI3Z 1GorOJYyAYzjV1OqhFBeypZ8gc9UO84tQdP3X9hhczXKklI3zQH81fedaZr/Yphh CTs8tlbtrgAWD8jSs+HEua4RfcNVoTwCXxNLkgWM0nSvYiSoYjaWSLi9QcYgIrqe 9R8BoRFaXBnhfnYewPzncB3iZ2m58+gVuZlHOfieggt5G3AYcTc+TDvsTQjs0vzo jD4tnOqN7YnHWTtHOKbhs5d/GZe1H8bG+i319dWqKmhRKgSJB88sT7vyzNgz7Ied 5jZICKuBF/bGUQUXWwRLXti8aBXA7VHiNqxmaM+jAC3pDOPm9AOjHckX2nlIUArV Qmk50fRWoGWikHGkhki32QxqAv938AKoU8t451hEmJgYE6kHvr4= =WBK0 -----END PGP SIGNATURE----- --72e772u2j4fbxje2--