/** * Import a private key * * Read a PEM formatted private key from stdin and import it into the * RSAWalletService. The public key will be automatically extracted and stored * together with the private key as a key pair. * * @param boolean $usedForPasswords If the private key should be used for passwords * @return void * @see typo3.flow3:security:importpublickey */ public function importPrivateKeyCommand($usedForPasswords = FALSE) { $keyData = ''; // no file_get_contents here because it does not work on php://stdin $fp = fopen('php://stdin', 'rb'); while (!feof($fp)) { $keyData .= fgets($fp, 4096); } fclose($fp); $uuid = $this->rsaWalletService->registerKeyPairFromPrivateKeyString($keyData, $usedForPasswords); $this->outputLine('The keypair has been successfully imported. Use the following uuid to refer to it in the RSAWalletService: ' . PHP_EOL . PHP_EOL . $uuid . PHP_EOL); }
/** * @test */ public function shutdownDoesNotSavesKeysToKeystoreFileIfKeysWereNotModified() { $this->assertFalse(file_exists('vfs://Foo/EncryptionKey')); $keyPairUuid = $this->rsaWalletService->generateNewKeypair(TRUE); $this->rsaWalletService->shutdownObject(); $this->assertTrue(file_exists('vfs://Foo/EncryptionKey')); $this->rsaWalletService->initializeObject(); $this->rsaWalletService->getPublicKey($keyPairUuid); // Hack: remove the file so we can actually detect if shutdown() would write it: unlink('vfs://Foo/EncryptionKey'); $this->rsaWalletService->shutdownObject(); $this->assertFalse(file_exists('vfs://Foo/EncryptionKey')); }