diff --git a/cli/Commands/OAuth2/Keys.php b/cli/Commands/OAuth2/Keys.php
index 609ac4e6b5ae072f5e14610f76f8341ed8a56aa0..93282ba3153e02db3c88b6a2ff2800d8fb56ad53 100644
--- a/cli/Commands/OAuth2/Keys.php
+++ b/cli/Commands/OAuth2/Keys.php
@@ -47,8 +47,8 @@ class Keys extends Command
         $this->storeKeyContentsToFile($encryptionKey, $this->generateEncryptionKey());
 
         $keys = RSA::createKey(4096);
-        $this->storeKeyContentsToFile($publicKey, $keys->getPublicKey()->toString('PKCS1'));
-        $this->storeKeyContentsToFile($privateKey, $keys->toString('PKCS1'));
+        $this->storeKeyContentsToFile($publicKey, (string) $key->getPublicKey());
+        $this->storeKeyContentsToFile($privateKey, (string) $key);
 
         $io->info('Schlüsseldateien erfolgreich angelegt.');