public function export_key($key_id)
 {
     $this->set_env();
     try {
         $gpg = new gnupg();
         // throw exception if error occurs
         $gpg->seterrormode(gnupg::ERROR_EXCEPTION);
         $key_data = $gpg->export($key_id);
         $this->restore_env();
         return $key_data;
     } catch (Exception $e) {
         // restore the envelope
         $this->restore_env();
         // re-throw the exception
         throw $e;
     }
 }
示例#2
0
function elggpg_export_key($user)
{
    $gpg = new gnupg();
    return $gpg->export($user->openpgp_publickey);
}