Rocksolid Light

Welcome to RetroBBS

mail  files  register  newsreader  groups  login

Message-ID:  

Nondeterminism means never having to say you are wrong.


devel / comp.lang.php / gnupg::encrypt(): get_key failed

SubjectAuthor
* gnupg::encrypt(): get_key failedFx ROOM
`* Re: gnupg::encrypt(): get_key failedDe ongekruisigde
 `* Re: gnupg::encrypt(): get_key failedFx ROOM
  `* Re: gnupg::encrypt(): get_key failedJ.O. Aho
   `- Re: gnupg::encrypt(): get_key failedFx ROOM

1
gnupg::encrypt(): get_key failed

<t6sljc$1i9$1@gioia.aioe.org>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=518&group=comp.lang.php#518

  copy link   Newsgroups: comp.lang.php
Path: i2pn2.org!i2pn.org!aioe.org!x3ACC2qrBjQXx8cNs6QrPQ.user.46.165.242.91.POSTED!not-for-mail
From: naso@tata.new (Fx ROOM)
Newsgroups: comp.lang.php
Subject: gnupg::encrypt(): get_key failed
Date: Sat, 28 May 2022 10:13:32 +0200
Organization: Aioe.org NNTP Server
Message-ID: <t6sljc$1i9$1@gioia.aioe.org>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Info: gioia.aioe.org; logging-data="1609"; posting-host="x3ACC2qrBjQXx8cNs6QrPQ.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101
Thunderbird/91.9.1
Content-Language: it-IT
X-Notice: Filtered by postfilter v. 0.9.2
 by: Fx ROOM - Sat, 28 May 2022 08:13 UTC

$gpg = new gnupg();
$gpg->addencryptkey("8660281B6051D071D94B5B230549F9DC851566DC");

var_dump(
$gpg->geterror(),
$gpg->encrypt("just a test")
);

OUTPUT:

string(14) "get_key failed"
bool(false)

Why?

Re: gnupg::encrypt(): get_key failed

<t6sm26$9bp$1@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=519&group=comp.lang.php#519

  copy link   Newsgroups: comp.lang.php
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: ongekruisigde@news.eternal-september.org (De ongekruisigde)
Newsgroups: comp.lang.php
Subject: Re: gnupg::encrypt(): get_key failed
Date: Sat, 28 May 2022 08:21:26 -0000 (UTC)
Organization: Ongekruisigden
Lines: 26
Message-ID: <t6sm26$9bp$1@dont-email.me>
References: <t6sljc$1i9$1@gioia.aioe.org>
Reply-To: ongekruisigde@holymenandwomen.catholic
Injection-Date: Sat, 28 May 2022 08:21:26 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="85bf8125066adec5f301cb98f65ab5b7";
logging-data="9593"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+QNp2Y7n0C1SU4M7/Y7PZn0oHRpQpMmnHsNpPs3dGmsA=="
User-Agent: slrn/1.0.3 (Linux)
Cancel-Lock: sha1:h0uJ3QksigLbBV8kpaylEnbGxYA=
 by: De ongekruisigde - Sat, 28 May 2022 08:21 UTC

On 2022-05-28, Fx ROOM <naso@tata.new> wrote:
> $gpg = new gnupg();
> $gpg->addencryptkey("8660281B6051D071D94B5B230549F9DC851566DC");
>
> var_dump(
> $gpg->geterror(),
> $gpg->encrypt("just a test")
> );
>
> OUTPUT:
>
> string(14) "get_key failed"
> bool(false)
>
> Why?

The addencryptkey() makes a call to gnupg (do you have that installed,
is GNUPGHOME environment variable set, is the key known to gnupg? etc.)

https://www.php.net/manual/en/function.gnupg-addencryptkey.php

--
I've heard a Jew and a Muslim argue in a Damascus cafe with less
passion than the emacs wars." [Ronald Florence <ron@18james.com> in
<ueu1c4mbrc.fsf@auda.18james.com>]

Re: gnupg::encrypt(): get_key failed

<t6t1i1$l52$1@gioia.aioe.org>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=520&group=comp.lang.php#520

  copy link   Newsgroups: comp.lang.php
Path: i2pn2.org!i2pn.org!aioe.org!x3ACC2qrBjQXx8cNs6QrPQ.user.46.165.242.91.POSTED!not-for-mail
From: naso@tata.new (Fx ROOM)
Newsgroups: comp.lang.php
Subject: Re: gnupg::encrypt(): get_key failed
Date: Sat, 28 May 2022 13:37:36 +0200
Organization: Aioe.org NNTP Server
Message-ID: <t6t1i1$l52$1@gioia.aioe.org>
References: <t6sljc$1i9$1@gioia.aioe.org> <t6sm26$9bp$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Info: gioia.aioe.org; logging-data="21666"; posting-host="x3ACC2qrBjQXx8cNs6QrPQ.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101
Thunderbird/91.9.1
Content-Language: it-IT
X-Notice: Filtered by postfilter v. 0.9.2
 by: Fx ROOM - Sat, 28 May 2022 11:37 UTC

Il 28/05/22 10:21, De ongekruisigde ha scritto:
> On 2022-05-28, Fx ROOM <naso@tata.new> wrote:
>> $gpg = new gnupg();
>> $gpg->addencryptkey("8660281B6051D071D94B5B230549F9DC851566DC");
>>
>> var_dump(
>> $gpg->geterror(),
>> $gpg->encrypt("just a test")
>> );
>>
>> OUTPUT:
>>
>> string(14) "get_key failed"
>> bool(false)
>>
>> Why?
>
> The addencryptkey() makes a call to gnupg (do you have that installed,
> is GNUPGHOME environment variable set, is the key known to gnupg? etc.)
>
> https://www.php.net/manual/en/function.gnupg-addencryptkey.php
>

????
It is the first time I do these things.

In any case

$ echo $GNUPGHOME
/tmp/key4656

$ mkdir /tmp/key4656

$ cat encrypt
#!/usr/bin/php
<?php
$gpg = new gnupg();
$gpg->addencryptkey("8660281B6051D071D94B5B230549F9DC851566DC");

var_dump(
$gpg->geterror(),
$gpg->encrypt("just a test")
);

$ ./encrypt
string(14) "get_key failed"
bool(false)

Also if it serves something

$ tree ~/.ssh
├── authorized_keys
├── id_rsa2
├── id_rsa.pub
└── known_hosts

Re: gnupg::encrypt(): get_key failed

<jffj5bF3q3oU1@mid.individual.net>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=521&group=comp.lang.php#521

  copy link   Newsgroups: comp.lang.php
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: user@example.net (J.O. Aho)
Newsgroups: comp.lang.php
Subject: Re: gnupg::encrypt(): get_key failed
Date: Sat, 28 May 2022 23:39:54 +0200
Lines: 45
Message-ID: <jffj5bF3q3oU1@mid.individual.net>
References: <t6sljc$1i9$1@gioia.aioe.org> <t6sm26$9bp$1@dont-email.me>
<t6t1i1$l52$1@gioia.aioe.org>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: individual.net YTEfF8fpRhthS2BlPTpTUQ0B4KAaYhJjNyxCN3E1Sx6l1M61DG
Cancel-Lock: sha1:4jidCwzR6Wg1lau0U2Cp6JONm4c=
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101
Thunderbird/91.9.0
Content-Language: en-US-large
In-Reply-To: <t6t1i1$l52$1@gioia.aioe.org>
 by: J.O. Aho - Sat, 28 May 2022 21:39 UTC

On 28/05/2022 13.37, Fx ROOM wrote:

> In any case
>
> $ echo $GNUPGHOME
> /tmp/key4656
>
> $ mkdir /tmp/key4656
>
> $ cat encrypt
> #!/usr/bin/php
> <?php
> $gpg = new gnupg();
> $gpg->addencryptkey("8660281B6051D071D94B5B230549F9DC851566DC");

I see you just copied the example from php.net, the fingerprint has to
belong to one of the pgp keys that is in the users default keystorage or
one that is assigned by setting the GNUPGHOME environment variable.

As you will never have the same fingerprint for the key as the one used
in the example, the example will never work.

What you need to do is to create a new pgp key with gpg and then use the
fingerprint for the public key as the argument for your addencryptkey().

> Also if it serves something
>
> $ tree ~/.ssh
> ├── authorized_keys
> ├── id_rsa2
> ├── id_rsa.pub
> └── known_hosts

No, that ain't the same as pgp keys (the above are ssl), I would suggest
you take a loot at the gpg man page, just type in your terminal: man gpg
or you can visit the following page: https://manpages.org/gpg

--

//Aho

Re: gnupg::encrypt(): get_key failed

<t6vgk9$1nhd$1@gioia.aioe.org>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=524&group=comp.lang.php#524

  copy link   Newsgroups: comp.lang.php
Path: i2pn2.org!i2pn.org!aioe.org!wH1RlLPRbBuMIFTkB8yv2Q.user.46.165.242.91.POSTED!not-for-mail
From: naso@tata.new (Fx ROOM)
Newsgroups: comp.lang.php
Subject: Re: gnupg::encrypt(): get_key failed
Date: Sun, 29 May 2022 12:07:05 +0200
Organization: Aioe.org NNTP Server
Message-ID: <t6vgk9$1nhd$1@gioia.aioe.org>
References: <t6sljc$1i9$1@gioia.aioe.org> <t6sm26$9bp$1@dont-email.me>
<t6t1i1$l52$1@gioia.aioe.org> <jffj5bF3q3oU1@mid.individual.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Info: gioia.aioe.org; logging-data="56877"; posting-host="wH1RlLPRbBuMIFTkB8yv2Q.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101
Thunderbird/91.9.1
X-Notice: Filtered by postfilter v. 0.9.2
Content-Language: it-IT
 by: Fx ROOM - Sun, 29 May 2022 10:07 UTC

Il 28/05/22 23:39, J.O. Aho ha scritto:
> What you need to do is to create a new pgp key with gpg and then use the
> fingerprint for the public key as the argument for your addencryptkey().

//-----BEGIN SCRIPT-----

/*
* Installazione estensione
* $ sudo apt install php-gnupg
*
* Generazione chiave
* $ gpg --gen-key
*/

$gpg = new gnupg();
$key = file_get_contents(__DIR__ . "/../etc/key");
$gpg->addencryptkey($key);

var_dump(
$gpg->geterror(),
$encrypted_text = $gpg->encrypt("just a test"),
$gpg->decrypt($encrypted_text),
);
//-----END SCRIPT-----

bool(false)
string(699) "-----BEGIN PGP MESSAGE-----

hQGMA950B1qyHrK/AQwAm0nogiPFkFzBnYP5CjDUipMkzSXmu0ti9nh1/9gsruZM
HIeehoDQZIPTteY29PqH4t/Ijy59Chl3+CW8Lz1lNycAz0kMDeTRgkxIO7jG7GiQ
BRQ4qH67epZZqAx1xgMRPh/NOR11sqAvARnVUI/UxWUtcLvtjH7huMFSDcyl1+1k
3fpc2wu+u1wBMWvWIsZ7rreJNtSxgbMzZ9/yX8ykORFbDr945CaOxBtejkfPZLmi
3vpjfEiUWimlU8X2C2BLf5VU2rVVJpyp0ZkUJ/dgfNyyoDBUge6jLZkpojHtZBHd
lIdym7BjpAAOCUGWxDEUPZjJyk1Oc3B/j0svC+vymtXpm1VBXVjnGheuHgREV2+c
05a7P9KOhnq/DQ02jMGa/MpMnRaxjwd/rshSlh4PfY6spdLeETglhXn/3iNBpSRE
M42jgYA1h4wb4JyWoojiGgkTR7I3"...
string(11) "just a test"

Good!!!

1
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor