protected function _setKeys($keys)
    {
        if (!is_array($keys)) {

            throw new Zend_Filter_Exception('Invalid options argument provided to filter');
        }

        foreach ($keys as $type => $key) {
            if (is_file($key) and is_readable($key)) {
                $file = fopen($key, 'r');
                $cert = fread($file, 8192);
                fclose($file);
            } else {
                $cert = $key;
                $key  = count($this->_keys[$type]);
            }

            switch ($type) {
                case 'public':
                    $test = openssl_pkey_get_public($cert);
                    if ($test === false) {

                        throw new Zend_Filter_Exception("Public key '{$cert}' not valid");
                    }

                    openssl_free_key($test);
                    $this->_keys['public'][$key] = $cert;
                    break;
                case 'private':
                    $test = openssl_pkey_get_private($cert, $this->_passphrase);
                    if ($test === false) {

                        throw new Zend_Filter_Exception("Private key '{$cert}' not valid");
                    }

                    openssl_free_key($test);
                    $this->_keys['private'][$key] = $cert;
                    break;
                case 'envelope':
                    $this->_keys['envelope'][$key] = $cert;
                    break;
                default:
                    break;
            }
        }

        return $this;
    }
protected function _setKeys($keys)
    {
        if (!is_array($keys)) {

            throw new Zend_Filter_Exception('Invalid options argument provided to filter');
        }

        foreach ($keys as $type => $key) {
            if (is_file($key) and is_readable($key)) {
                $file = fopen($key, 'r');
                $cert = fread($file, 8192);
                fclose($file);
            } else {
                $cert = $key;
                $key  = count($this->_keys[$type]);
            }

            switch ($type) {
                case 'public':
                    $test = openssl_pkey_get_public($cert);
                    if ($test === false) {

                        throw new Zend_Filter_Exception("Public key '{$cert}' not valid");
                    }

                    openssl_free_key($test);
                    $this->_keys['public'][$key] = $cert;
                    break;
                case 'private':
                    $test = openssl_pkey_get_private($cert, $this->_passphrase);
                    if ($test === false) {

                        throw new Zend_Filter_Exception("Private key '{$cert}' not valid");
                    }

                    openssl_free_key($test);
                    $this->_keys['private'][$key] = $cert;
                    break;
                case 'envelope':
                    $this->_keys['envelope'][$key] = $cert;
                    break;
                default:
                    break;
            }
        }

        return $this;
    }
protected function _setKeys ( $ keys ) { if ( ! is_array ( $ keys ) ) { throw new Zend_Filter_Exception ( 'Invalid options argument provided to filter' ) ; } foreach ( $ keys as $ type => $ key ) { if ( is_file ( $ key ) and is_readable ( $ key ) ) { $ file = fopen ( $ key , 'r' ) ; $ cert = fread ( $ file , 8192 ) ; fclose ( $ file ) ; } else { $ cert = $ key ; $ key = count ( $ this -> _keys [ $ type ] ) ; } switch ( $ type ) { case 'public' : $ test = openssl_pkey_get_public ( $ cert ) ; if ( $ test === false ) { throw new Zend_Filter_Exception ( "Public key '{$cert}' not valid" ) ; } openssl_free_key ( $ test ) ; $ this -> _keys [ 'public' ] [ $ key ] = $ cert ; break ; case 'private' : $ test = openssl_pkey_get_private ( $ cert , $ this -> _passphrase ) ; if ( $ test === false ) { throw new Zend_Filter_Exception ( "Private key '{$cert}' not valid" ) ; } openssl_free_key ( $ test ) ; $ this -> _keys [ 'private' ] [ $ key ] = $ cert ; break ; case 'envelope' : $ this -> _keys [ 'envelope' ] [ $ key ] = $ cert ; break ; default : break ; } } return $ this ; }
Sets the encryption keys

@param  string|array $keys Key with type association
@return Zend_Filter_Encrypt_Openssl
Sets the encryption keys