]> git.mxchange.org Git - friendica.git/blobdiff - src/Module/PublicRSAKey.php
Merge pull request #12222 from MrPetovan/bug/12219-hovercard-stay-local
[friendica.git] / src / Module / PublicRSAKey.php
index ad9bb6db849dffb48322324f0c5569b86fc4e066..523ab174fbf785d42995a61e5ead8de3a2d1f299 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /**
- * @copyright Copyright (C) 2010-2021, the Friendica project
+ * @copyright Copyright (C) 2010-2022, the Friendica project
  *
  * @license GNU AGPL version 3 or any later version
  *
 namespace Friendica\Module;
 
 use Friendica\BaseModule;
+use Friendica\Core\System;
 use Friendica\DI;
 use Friendica\Model\User;
 use Friendica\Network\HTTPException\BadRequestException;
 use Friendica\Util\Crypto;
 use Friendica\Util\Strings;
-use phpseclib\File\ASN1;
 
 /**
  * prints the public RSA key of a user
  */
 class PublicRSAKey extends BaseModule
 {
-       public static function rawContent(array $parameters = [])
+       protected function rawContent(array $request = [])
        {
-               $app = DI::app();
-
-               // @TODO: Replace with parameter from router
-               if ($app->argc !== 2) {
+               if (empty($this->parameters['nick'])) {
                        throw new BadRequestException();
                }
 
-               // @TODO: Replace with parameter from router
-               $nick = $app->argv[1];
+               $nick = $this->parameters['nick'];
 
                $user = User::getByNickname($nick, ['spubkey']);
                if (empty($user) || empty($user['spubkey'])) {
@@ -53,9 +49,7 @@ class PublicRSAKey extends BaseModule
 
                Crypto::pemToMe($user['spubkey'], $modulus, $exponent);
 
-               header('Content-type: application/magic-public-key');
-               echo 'RSA' . '.' . Strings::base64UrlEncode($modulus, true) . '.' . Strings::base64UrlEncode($exponent, true);
-
-               exit();
+               $content = 'RSA' . '.' . Strings::base64UrlEncode($modulus, true) . '.' . Strings::base64UrlEncode($exponent, true);
+               System::httpExit($content, Response::TYPE_BLANK, 'application/magic-public-key');
        }
 }