[Flow] How to use RsaWalletServicePhp

Peter R peter at webschuppen.com
Thu Mar 20 12:37:34 CET 2014


Hello,

I try to use the RsaWalletServicePhp class to encrypt and decrypt text with RSA.

In my class:
/**
 * @Flow\Inject
 * @var \TYPO3\Flow\Security\Cryptography\RsaWalletServicePhp
 */
protected $rsaWalletServicePhp;

/**
 * @var array
 */
protected $settings;

/**
 * Inject the settings
 *
 * @param array $settings
 * @return void
 */
public function injectSettings(array $settings) {
        $this->settings = $settings;
}


In a method:
$plaintext = 'example';
$privatekey = '-----BEGIN RSA PRIVATE KEY-----' . str_replace(' ', PHP_EOL, ' MII...CPXdgQ= ') . '-----END RSA PRIVATE KEY-----';
$publickey = '-----BEGIN PUBLIC KEY-----' . str_replace(' ', PHP_EOL, ' MIGfM...AQAB ') . '-----END PUBLIC KEY-----';

#$this->rsaWalletServicePhp->injectSettings($this->settings);
#$this->rsaWalletServicePhp->registerPublicKeyFromString($publickey);
#$this->rsaWalletServicePhp->registerKeyPairFromPrivateKeyString($privatekey);
$this->rsaWalletServicePhp->generateNewKeypair();

In settings.yaml:
Foo:
  Bar:
    security:
      cryptography:
        RSAWalletServicePHP:

          # Path to the file where RSA keys shall be stored
          # Note: This file must not be accessible by the public!
          keystorePath: %FLOW_PATH_DATA%Persistent/RsaWalletData

          # Defines the openSSL configuration used for key handling.
          # See the PHP openSSL documentation for possible settings.
          openSSLConfiguration: 
            config: %FLOW_PATH_DATA%openssl.cnf
            private_key_bits: 384

I created the folder RsaWalletData in Persistent and now a get an error:
#1: Warning: file_get_contents(C:/somefolders/Data/Persistent/RsaWalletData): failed to open stream: Permission denied in C:\somefolders\Data\Temporary\Development\Cache\Code\Flow_Object_Classes\TYPO3_Flow_Security_Cryptography_RsaWalletServicePhp.php line 72

I changed permission but the error is the same.

The questions are:
Is this the right way to do this task?
Why I get a permission denied?


System:
Win7
xampp 1.8.0 (Local Webserver)
php 5.4.22
Flow 2.1


More information about the Flow mailing list