AcmePhp\Ssl\PrivateKey::getResource PHP Method

getResource() public method

public getResource ( )
    public function getResource()
    {
        if (!($resource = openssl_pkey_get_private($this->keyPEM))) {
            throw new KeyFormatException(sprintf('Fail to convert key into resource: %s', openssl_error_string()));
        }
        return $resource;
    }

Usage Example

Example #1
0
 /**
  * Generate a signature of the given data using a private key and an algorithm.
  *
  * @param string     $data
  * @param PrivateKey $privateKey
  * @param int        $algorithm
  *
  * @return string
  */
 public function signData($data, PrivateKey $privateKey, $algorithm = OPENSSL_ALGO_SHA256)
 {
     if (!openssl_sign($data, $signature, $privateKey->getResource(), $algorithm)) {
         throw new DataSigningException(sprintf('OpenSSL data signing failed with error: %s', openssl_error_string()));
     }
     return $signature;
 }
PrivateKey