gnupg_init
(PECL gnupg:0.4-1.3.1)
gnupg_init — Initialize a connection
Описание
resource gnupg_init
( void
)
Список параметров
This function has no parameters.
Возвращаемые значения
A GnuPG resource connection used by other GnuPG functions.
Примеры
Пример #1 Procedural gnupg_init() example
<?php
$res = gnupg_init();
?>
Пример #2 OO gnupg initializer example
<?php
$gpg = new gnupg();
?>
- PHP Руководство
- Функции по категориям
- Индекс функций
- Справочник функций
- Генерация нетекстовых MIME форматов
- GNU Privacy Guard
- gnupg_adddecryptkey
- gnupg_addencryptkey
- gnupg_addsignkey
- gnupg_cleardecryptkeys
- gnupg_clearencryptkeys
- gnupg_clearsignkeys
- gnupg_decrypt
- gnupg_decryptverify
- gnupg_encrypt
- gnupg_encryptsign
- gnupg_export
- gnupg_geterror
- gnupg_getprotocol
- gnupg_import
- gnupg_init
- gnupg_keyinfo
- gnupg_setarmor
- gnupg_seterrormode
- gnupg_setsignmode
- gnupg_sign
- gnupg_verify
Коментарии
Set the correct GNUPG environment, before you call gnupg_init()!
The current FPM/FastCGI/Module User must have read - if you import write - permissions on that directory. You won't get an error message, if something is not correct.
Without a correct environment, all other gnupg functions will not work as you expected.
<?php
// Enter your .gnupg environment
putenv('GNUPGHOME=/var/www/vhosts/yourdomain/.gnupg');
error_reporting(E_ALL);
$res = gnupg_init();
gnupg_seterrormode($res,GNUPG_ERROR_WARNING);
$info = gnupg_keyinfo($res, 'your-key-id');
echo "Key - Info<pre>";
var_dump($info);
echo "</pre>";
?>
Make sure home_dir option is not too many characters or else private keys fail.
You will notice that functions take a long time (seconds).
Commandline test yield error:
> gpg: can't connect to the agent: IPC connect call failed
Executing `gpg-agent --daemon --homedir /very/long/path/to/.gnupg` gave the error.
> socket name for '/very/long/path/to/.gnupg/S.gpg-agent.extra' is too long
So you must check that home_dir + '/S.gpg-agent.extra' is:
* < 107 characters on Linux
* < 104 on BSD 4.4