What's the basic PHP command used to open an SQLCipher DB?

1,114 views
Skip to first unread message

Dean

unread,
Feb 8, 2013, 1:23:26 PM2/8/13
to SQLCipher Users
What's the basic PHP command used to open an SQLCipher DB? I'm a bit
new to PHP, and SQLite for that matter, but I'm able to connect to an
SQLCipher DB with the following code:

$sqliteDB = new PDO('sqlite:test.db');

Problem is that I can't seem to register the password. I tried the
following without success:

$result = $sqliteDB->query("PRAGMA key = 'thisismypassphrase'");

Any help is appreciated.

Nick Parker

unread,
Feb 8, 2013, 2:27:03 PM2/8/13
to sqlc...@googlegroups.com, Dean
Hi Dean,

You would need to build SQLCipher into the SQLite extension used within
PHP. We have documented the steps in an article here [1]. Once you
have done that, you could execute something like the following:

<?php

try {

$db = new SQLite3("test.db");
$db->exec("PRAGMA key = 'test';");
$result = $db->query("select * from t1;");
if(!$result) {
throw new Exception($db->lastErrorMsg());
}
var_dump($result->fetchArray());
$db->close();
}
catch(Exception $e) {
echo "Exception", $e->getMessage(), "\n";
}

?>


1. http://sqlcipher.net/sqlcipher-for-php

--
Nick Parker

DRA

unread,
Feb 9, 2013, 2:53:44 AM2/9/13
to Nick Parker, sqlc...@googlegroups.com
Hi Nick,

Creating the db object in the form you specified ($db = new SQLite3("test.db");) causes the following error:  

    php: symbol lookup error: /root/php-5.4.0/ext/sqlite3/modules/sqlite3.so: undefined symbol: object_properties_init

Using the PDO object along with the "exec" method still does not unencrypt the db.

I'm quite sure that I'm using SQLCipher since I've gone through the referenced instructions successfully and I haven't installed SQLite from the repo.  Within the directory where I built SQLCipher, I can execute the sqlite3 executable from the command line and successfully encrypt/decrypt a database.  But within a PHP script I can only work with an SQLite database that's not encrypted.  Mind you this I believe is with SQLCipher because I haven't installed SQLite, but I can't be 100% sure.

Nick Parker

unread,
Feb 11, 2013, 10:30:45 AM2/11/13
to DRA, sqlc...@googlegroups.com
Hi DRA,

If you are using a recent version of SQLCipher, could you run the
strings tool against the sqlite3.so you compiled to verify that various
SQLCipher functions exist within the library? Try running something like:

strings libsqlite3.so | grep cipher_version

Can you check to see if you are getting any results from that command?

--
Nick Parker

DRA

unread,
Feb 11, 2013, 2:04:24 PM2/11/13
to Nick Parker, sqlc...@googlegroups.com
Hi Nick,

# strings /root/php-5.4.0/ext/sqlite3/modules/sqlite3.so | grep cipher_version
codec_get_cipher_version
cipher_version

# strings /root/sqlcipher/.libs/libsqlite3.so | grep cipher_version
codec_get_cipher_version
cipher_version


The files are still where I built them.

Dean

Nick Parker

unread,
Feb 11, 2013, 3:28:43 PM2/11/13
to DRA, sqlc...@googlegroups.com
Hi Dean,

It is good to see the compilation of the module worked with SQLCipher.  Next up is to verify your module is being loaded.  The error message you receive (i.e., undefined symbol object_properties_init) is not from SQLCipher itself, so I have a feeling it comes from either your PHP installation, or the PHP module itself.  Can you create a PHP page that dumps the contents of phpinfo(); to see if your module is loaded?  Thanks!

Nick Parker

DRA

unread,
Feb 11, 2013, 3:59:03 PM2/11/13
to Nick Parker, sqlc...@googlegroups.com
There you go.  Thanks again Nick.


PHP Logo

PHP Version 5.3.10-1ubuntu3.5


SystemLinux my-desktop 3.2.0-23-generic #36-Ubuntu SMP Tue Apr 10 20:39:51 UTC 2012 x86_64
Build Date Jan 18 2013 23:24:03
Server API Apache 2.0 Handler
Virtual Directory Support disabled
Configuration File (php.ini) Path/etc/php5/apache2
Loaded Configuration File/etc/php5/apache2/php.ini
Scan this dir for additional .ini files/etc/php5/apache2/conf.d
Additional .ini files parsed /etc/php5/apache2/conf.d/mysql.ini, /etc/php5/apache2/conf.d/mysqli.ini, /etc/php5/apache2/conf.d/pdo.ini, /etc/php5/apache2/conf.d/pdo_mysql.ini, /etc/php5/apache2/conf.d/pdo_sqlite.ini, /etc/php5/apache2/conf.d/sqlcipher.ini, /etc/php5/apache2/conf.d/sqlite3.ini
PHP API 20090626
PHP Extension 20090626
Zend Extension 220090626
Zend Extension Build API220090626,NTS
PHP Extension Build API20090626,NTS
Debug Build no
Thread Safety disabled
Zend Memory Manager enabled
Zend Multibyte Support disabled
IPv6 Support enabled
Registered PHP Streams https, ftps, compress.zlib, compress.bzip2, php, file, glob, data, http, ftp, phar, zip
Registered Stream Socket Transportstcp, udp, unix, udg, ssl, sslv3, tls
Registered Stream Filters zlib.*, bzip2.*, convert.iconv.*, string.rot13, string.toupper, string.tolower, string.strip_tags, convert.*, consumed, dechunk

Suhosin logoThis server is protected with the Suhosin Patch 0.9.10
Copyright (c) 2006-2007 Hardened-PHP Project Copyright (c) 2007-2009 SektionEins GmbH

Zend logoThis program makes use of the Zend Scripting Language Engine:
Zend Engine v2.3.0, Copyright (c) 1998-2012 Zend Technologies


PHP Credits


Configuration

apache2handler

Apache Version Apache/2.2.22 (Ubuntu)
Apache API Version 20051115
Server Administratorwebmaster@localhost
Hostname:Port127.0.1.1:80
User/Group www-data(33)/33
Max Requests Per Child: 0 - Keep Alive: on - Max Per Connection: 100
TimeoutsConnection: 300 - Keep-Alive: 5
Virtual ServerYes
Server Root/etc/apache2
Loaded Modulescore mod_log_config mod_logio prefork http_core mod_so mod_alias mod_auth_basic mod_authn_file mod_authz_default mod_authz_groupfile mod_authz_host mod_authz_user mod_autoindex mod_cgi mod_deflate mod_dir mod_env mod_include mod_mime mod_negotiation mod_php5 mod_reqtimeout mod_setenvif mod_status

DirectiveLocal Value Master Value
engine 11
last_modified0 0
xbithack 00

Apache Environment

VariableValue
HTTP_HOSTlocalhost
HTTP_CONNECTIONkeep-alive
HTTP_ACCEPTtext/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
HTTP_USER_AGENT Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.17 (KHTML, like Gecko) Chrome/24.0.1312.56 Safari/537.17
HTTP_REFERERhttp://localhost/sqlcipher/
HTTP_ACCEPT_ENCODING gzip,deflate,sdch
HTTP_ACCEPT_LANGUAGE en-GB,en-US;q=0.8,en;q=0.6
HTTP_ACCEPT_CHARSET ISO-8859-1,utf-8;q=0.7,*;q=0.3
HTTP_COOKIEstyle=Light Style
PATH/usr/local/bin:/usr/bin:/bin
SERVER_SIGNATURE<address>Apache/2.2.22 (Ubuntu) Server at localhost Port 80</address>
SERVER_SOFTWARE Apache/2.2.22 (Ubuntu)
SERVER_NAME localhost
SERVER_ADDR 127.0.0.1
SERVER_PORT 80
REMOTE_ADDR 127.0.0.1
DOCUMENT_ROOT /var/www
SERVER_ADMIN webmaster@localhost
SCRIPT_FILENAME /var/www/sqlcipher/test.php
REMOTE_PORT 36434
GATEWAY_INTERFACE CGI/1.1
SERVER_PROTOCOL HTTP/1.1
REQUEST_METHOD GET
QUERY_STRING no value
REQUEST_URI /sqlcipher/test.php
SCRIPT_NAME /sqlcipher/test.php

HTTP Headers Information

HTTP Request Headers
HTTP RequestGET /sqlcipher/test.php HTTP/1.1
Hostlocalhost
Connectionkeep-alive
Accepttext/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
User-Agent Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.17 (KHTML, like Gecko) Chrome/24.0.1312.56 Safari/537.17
Refererhttp://localhost/sqlcipher/
Accept-Encoding gzip,deflate,sdch
Accept-Language en-GB,en-US;q=0.8,en;q=0.6
Accept-Charset ISO-8859-1,utf-8;q=0.7,*;q=0.3
Cookiestyle=Light Style
HTTP Response Headers
X-Powered-ByPHP/5.3.10-1ubuntu3.5
VaryAccept-Encoding
Content-Encodinggzip

bcmath

BCMath supportenabled

Directive Local ValueMaster Value
bcmath.scale0 0

bz2

BZip2 SupportEnabled
Stream Wrapper supportcompress.bzip2://
Stream Filter supportbzip2.decompress, bzip2.compress
BZip2 Version1.0.6, 6-Sept-2010

calendar

Calendar supportenabled

Core

PHP Version5.3.10-1ubuntu3.5

Directive Local ValueMaster Value
allow_call_time_pass_referenceOff Off
allow_url_fopen OnOn
allow_url_includeOff Off
always_populate_raw_post_data OffOff
arg_separator.input& &
arg_separator.output &&
asp_tagsOff Off
auto_append_file no valueno value
auto_globals_jitOn On
auto_prepend_file no valueno value
browscapno value no value
default_charset no valueno value
default_mimetypetext/html text/html
define_syslog_variables OffOff
disable_classesno value no value
disable_functions pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority, pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,
display_errors OffOff
display_startup_errorsOff Off
doc_root no valueno value
docref_extno value no value
docref_root no valueno value
enable_dlOff Off
error_append_string no valueno value
error_logno value no value
error_prepend_string no valueno value
error_reporting22527 22527
exit_on_timeout OffOff
expose_phpOn On
extension_dir /usr/lib/php5/20090626/usr/lib/php5/20090626
file_uploadsOn On
highlight.bg #FFFFFF #FFFFFF
highlight.comment#FF8000 #FF8000
highlight.default#0000BB #0000BB
highlight.html#000000 #000000
highlight.keyword #007700#007700
highlight.string #DD0000#DD0000
html_errors OffOff
ignore_repeated_errorsOff Off
ignore_repeated_source OffOff
ignore_user_abortOff Off
implicit_flush OffOff
include_path.:/usr/share/php:/usr/share/pear .:/usr/share/php:/usr/share/pear
log_errors On On
log_errors_max_len 10241024
magic_quotes_gpcOff Off
magic_quotes_runtime OffOff
magic_quotes_sybaseOff Off
mail.add_x_header OnOn
mail.force_extra_parametersno value no value
mail.log no valueno value
max_execution_time30 30
max_file_uploads 2020
max_input_nesting_level64 64
max_input_time 6060
max_input_vars1000 1000
memory_limit 128M128M
open_basedirno value no value
output_buffering 40964096
output_handlerno value no value
post_max_size 8M8M
precision14 14
realpath_cache_size 16K16K
realpath_cache_ttl120 120
register_argc_argv OffOff
register_globalsOff Off
register_long_arrays OffOff
report_memleaksOn On
report_zend_debug OnOn
request_orderGP GP
safe_mode OffOff
safe_mode_exec_dirno value no value
safe_mode_gid OffOff
safe_mode_include_dirno value no value
sendmail_from no valueno value
sendmail_path/usr/sbin/sendmail -t -i  /usr/sbin/sendmail -t -i 
serialize_precision 17 17
short_open_tag OnOn
SMTPlocalhost localhost
smtp_port 2525
sql.safe_modeOff Off
track_errors OffOff
unserialize_callback_funcno value no value
upload_max_filesize 2M2M
upload_tmp_dirno value no value
user_dir no valueno value
user_ini.cache_ttl300 300
user_ini.filename .user.ini.user.ini
variables_orderGPCS GPCS
xmlrpc_error_number 00
xmlrpc_errorsOff Off
y2k_compliance OnOn
zend.enable_gcOn On

ctype

ctype functions enabled

date

date/time support enabled
"Olson" Timezone Database Version 0.system
Timezone Databaseinternal
Default timezoneAmerica/Los_Angeles

Directive Local ValueMaster Value
date.default_latitude31.7667 31.7667
date.default_longitude 35.233335.2333
date.sunrise_zenith90.583333 90.583333
date.sunset_zenith 90.58333390.583333
date.timezoneno value no value

dba

DBA support enabled
Supported handlers cdb cdb_make db4 inifile flatfile

Directive Local ValueMaster Value
dba.default_handlerflatfile flatfile

dom

DOM/XML enabled
DOM/XML API Version 20031129
libxml Version 2.7.8
HTML Support enabled
XPath Support enabled
XPointer Support enabled
Schema Support enabled
RelaxNG Support enabled

ereg

Regex Library Bundled library enabled

exif

EXIF Support enabled
EXIF Version 1.4 $Id: exif.c 321634 2012-01-01 13:15:04Z felipe $
Supported EXIF Version0220
Supported filetypesJPEG,TIFF

Directive Local ValueMaster Value
exif.decode_jis_intelJIS JIS
exif.decode_jis_motorola JISJIS
exif.decode_unicode_intelUCS-2LE UCS-2LE
exif.decode_unicode_motorola UCS-2BEUCS-2BE
exif.encode_jisno value no value
exif.encode_unicode ISO-8859-15ISO-8859-15

fileinfo

fileinfo support enabled
version 1.0.5-dev

filter

Input Validation and Filtering enabled
Revision $Revision: 321634 $

Directive Local ValueMaster Value
filter.defaultunsafe_raw unsafe_raw
filter.default_flags no valueno value

ftp

FTP supportenabled

gettext

GetText Supportenabled

hash

hash supportenabled
Hashing Enginesmd2 md4 md5 sha1 sha224 sha256 sha384 sha512 ripemd128 ripemd160 ripemd256 ripemd320 whirlpool tiger128,3 tiger160,3 tiger192,3 tiger128,4 tiger160,4 tiger192,4 snefru snefru256 gost adler32 crc32 crc32b salsa10 salsa20 haval128,3 haval160,3 haval192,3 haval224,3 haval256,3 haval128,4 haval160,4 haval192,4 haval224,4 haval256,4 haval128,5 haval160,5 haval192,5 haval224,5 haval256,5

iconv

iconv supportenabled
iconv implementationglibc
iconv library version2.15

Directive Local ValueMaster Value
iconv.input_encodingISO-8859-1 ISO-8859-1
iconv.internal_encoding ISO-8859-1ISO-8859-1
iconv.output_encodingISO-8859-1 ISO-8859-1

json

json support enabled
json version 1.2.1

libxml

libXML support active
libXML Compiled Version 2.7.8
libXML Loaded Version 20708
libXML streams enabled

mbstring

Multibyte Support enabled
Multibyte string engine libmbfl
HTTP input encoding translation disabled

mbstring extension makes use of "streamable kanji code filter and converter", which is distributed under the GNU Lesser General Public License version 2.1.

Multibyte (japanese) regex supportenabled
Multibyte regex (oniguruma) backtrack checkOn
Multibyte regex (oniguruma) version4.7.1

DirectiveLocal Value Master Value
mbstring.detect_order no valueno value
mbstring.encoding_translationOff Off
mbstring.func_overload 00
mbstring.http_inputpass pass
mbstring.http_output passpass
mbstring.http_output_conv_mimetypes^(text/|application/xhtml\+xml) ^(text/|application/xhtml\+xml)
mbstring.internal_encodingno value no value
mbstring.language neutralneutral
mbstring.strict_detectionOff Off
mbstring.substitute_character no valueno value

mhash

MHASH supportEnabled
MHASH API VersionEmulated Support

mysql

MySQL Support enabled
Active Persistent Links 0
Active Links 0
Client API version 5.5.29
MYSQL_MODULE_TYPE external
MYSQL_SOCKET /var/run/mysqld/mysqld.sock
MYSQL_INCLUDE -I/usr/include/mysql
MYSQL_LIBS-L/usr/lib/x86_64-linux-gnu -lmysqlclient_r

DirectiveLocal Value Master Value
mysql.allow_local_infile OnOn
mysql.allow_persistentOn On
mysql.connect_timeout 6060
mysql.default_hostno value no value
mysql.default_password no valueno value
mysql.default_portno value no value
mysql.default_socket /var/run/mysqld/mysqld.sock/var/run/mysqld/mysqld.sock
mysql.default_userno value no value
mysql.max_links UnlimitedUnlimited
mysql.max_persistentUnlimited Unlimited
mysql.trace_mode OffOff

mysqli

MysqlI Supportenabled
Client API library version5.5.29
Active Persistent Links0
Inactive Persistent Links0
Active Links0
Client API header version5.5.29
MYSQLI_SOCKET/var/run/mysqld/mysqld.sock

DirectiveLocal Value Master Value
mysqli.allow_local_infile OnOn
mysqli.allow_persistentOn On
mysqli.default_host no valueno value
mysqli.default_port3306 3306
mysqli.default_pw no valueno value
mysqli.default_socket/var/run/mysqld/mysqld.sock /var/run/mysqld/mysqld.sock
mysqli.default_user no value no value
mysqli.max_links UnlimitedUnlimited
mysqli.max_persistentUnlimited Unlimited
mysqli.reconnect OffOff

openssl

OpenSSL supportenabled
OpenSSL Library VersionOpenSSL 1.0.1 14 Mar 2012
OpenSSL Header VersionOpenSSL 1.0.1 14 Mar 2012

pcre

PCRE (Perl Compatible Regular Expressions) Supportenabled
PCRE Library Version 8.12 2011-01-15

Directive Local ValueMaster Value
pcre.backtrack_limit1000000 1000000
pcre.recursion_limit 100000100000

PDO

PDO supportenabled
PDO driversmysql, sqlite

pdo_mysql

PDO Driver for MySQL enabled
Client API version 5.5.29

Directive Local ValueMaster Value
pdo_mysql.default_socket/var/run/mysqld/mysqld.sock /var/run/mysqld/mysqld.sock

pdo_sqlite

PDO Driver for SQLite 3.x enabled
SQLite Library 3.7.9

Phar

Phar: PHP Archive support enabled
Phar EXT version 2.0.1
Phar API version 1.1.1
SVN revision $Revision: 321634 $
Phar-based phar archives enabled
Tar-based phar archivesenabled
ZIP-based phar archivesenabled
gzip compressionenabled
bzip2 compressionenabled
Native OpenSSL supportenabled

Phar based on pear/PHP_Archive, original concept by Davey Shafik.
Phar fully realized by Gregory Beaver and Marcus Boerger.
Portions of tar implementation Copyright (c) 2003-2009 Tim Kientzle.

Directive Local ValueMaster Value
phar.cache_listno value no value
phar.readonly OnOn
phar.require_hashOn On

posix

Revision $Revision: 321634 $

Reflection

Reflection enabled
Version $Revision: 321634 $

session

Session Support enabled
Registered save handlers files user
Registered serializer handlers php php_binary wddx

Directive Local ValueMaster Value
session.auto_startOff Off
session.bug_compat_42 OffOff
session.bug_compat_warnOff Off
session.cache_expire 180180
session.cache_limiternocache nocache
session.cookie_domain no valueno value
session.cookie_httponlyOff Off
session.cookie_lifetime 00
session.cookie_path/ /
session.cookie_secure OffOff
session.entropy_fileno value no value
session.entropy_length 00
session.gc_divisor1000 1000
session.gc_maxlifetime 14401440
session.gc_probability0 0
session.hash_bits_per_character 55
session.hash_function0 0
session.name PHPSESSID PHPSESSID
session.referer_check no valueno value
session.save_handlerfiles files
session.save_path /var/lib/php5/var/lib/php5
session.serialize_handlerphp php
session.use_cookies OnOn
session.use_only_cookiesOn On
session.use_trans_sid 00

shmop

shmop supportenabled

SimpleXML

Simplexml support enabled
Revision $Revision: 321634 $
Schema support enabled

soap

Soap Client enabled
Soap Server enabled

Directive Local ValueMaster Value
soap.wsdl_cache1 1
soap.wsdl_cache_dir /tmp/tmp
soap.wsdl_cache_enabled1 1
soap.wsdl_cache_limit 55
soap.wsdl_cache_ttl86400 86400

sockets

Sockets Support enabled

SPL

SPL support enabled
Interfaces Countable, OuterIterator, RecursiveIterator, SeekableIterator, SplObserver, SplSubject
ClassesAppendIterator, ArrayIterator, ArrayObject, BadFunctionCallException, BadMethodCallException, CachingIterator, DirectoryIterator, DomainException, EmptyIterator, FilesystemIterator, FilterIterator, GlobIterator, InfiniteIterator, InvalidArgumentException, IteratorIterator, LengthException, LimitIterator, LogicException, MultipleIterator, NoRewindIterator, OutOfBoundsException, OutOfRangeException, OverflowException, ParentIterator, RangeException, RecursiveArrayIterator, RecursiveCachingIterator, RecursiveDirectoryIterator, RecursiveFilterIterator, RecursiveIteratorIterator, RecursiveRegexIterator, RecursiveTreeIterator, RegexIterator, RuntimeException, SplDoublyLinkedList, SplFileInfo, SplFileObject, SplFixedArray, SplHeap, SplMinHeap, SplMaxHeap, SplObjectStorage, SplPriorityQueue, SplQueue, SplStack, SplTempFileObject, UnderflowException, UnexpectedValueException

sqlite3

SQLite3 support enabled
SQLite3 module version 0.7
SQLite Library 3.7.14.1

Directive Local ValueMaster Value
sqlite3.extension_dirno value no value

standard

Dynamic Library Support enabled
Path to sendmail /usr/sbin/sendmail -t -i

Directive Local ValueMaster Value
assert.active1 1
assert.bail 00
assert.callbackno value no value
assert.quiet_eval 00
assert.warning1 1
auto_detect_line_endings 00
default_socket_timeout60 60
from no valueno value
safe_mode_allowed_env_varsPHP_ PHP_
safe_mode_protected_env_vars LD_LIBRARY_PATHLD_LIBRARY_PATH
url_rewriter.tagsa=href,area=href,frame=src,input=src,form=fakeentry a=href,area=href,frame=src,input=src,form=fakeentry
user_agentno value no value

sysvmsg

sysvmsg support enabled
Revision $Revision: 321634 $

tokenizer

Tokenizer Support enabled

wddx

WDDX Support enabled
WDDX Session Serializer enabled

xml

XML Support active
XML Namespace Support active
libxml2 Version 2.7.8

xmlreader

XMLReader enabled

xmlwriter

XMLWriter enabled

zip

Zip enabled
Extension Version $Id: php_zip.c 321634 2012-01-01 13:15:04Z felipe $
Zip version1.9.1
Libzip version0.9.0

zlib

ZLib Supportenabled
Stream Wrapper supportcompress.zlib://
Stream Filter supportzlib.inflate, zlib.deflate
Compiled Version1.2.1.1
Linked Version1.2.3.4

Directive Local ValueMaster Value
zlib.output_compressionOff Off
zlib.output_compression_level -1-1
zlib.output_handlerno value no value

Additional Modules

Module Name
sysvsem
sysvshm

Environment

Variable Value
APACHE_RUN_DIR /var/run/apache2
APACHE_PID_FILE /var/run/apache2.pid
PATH /usr/local/bin:/usr/bin:/bin
APACHE_LOCK_DIR /var/lock/apache2
LANGC
APACHE_RUN_USERwww-data
APACHE_RUN_GROUPwww-data
APACHE_LOG_DIR/var/log/apache2
PWD/

PHP Variables

VariableValue
_COOKIE["style"]Light Style
_SERVER["HTTP_HOST"]localhost
_SERVER["HTTP_CONNECTION"]keep-alive
_SERVER["HTTP_ACCEPT"]text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
_SERVER["HTTP_USER_AGENT"] Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.17 (KHTML, like Gecko) Chrome/24.0.1312.56 Safari/537.17
_SERVER["HTTP_REFERER"]http://localhost/sqlcipher/
_SERVER["HTTP_ACCEPT_ENCODING"] gzip,deflate,sdch
_SERVER["HTTP_ACCEPT_LANGUAGE"] en-GB,en-US;q=0.8,en;q=0.6
_SERVER["HTTP_ACCEPT_CHARSET"]ISO-8859-1,utf-8;q=0.7,*;q=0.3
_SERVER["HTTP_COOKIE"] style=Light Style
_SERVER["PATH"] /usr/local/bin:/usr/bin:/bin
_SERVER["SERVER_SIGNATURE"]<address>Apache/2.2.22 (Ubuntu) Server at localhost Port 80</address>
_SERVER["SERVER_SOFTWARE"] Apache/2.2.22 (Ubuntu)
_SERVER["SERVER_NAME"] localhost
_SERVER["SERVER_ADDR"]127.0.0.1
_SERVER["SERVER_PORT"]80
_SERVER["REMOTE_ADDR"]127.0.0.1
_SERVER["DOCUMENT_ROOT"]/var/www
_SERVER["SERVER_ADMIN"]webmaster@localhost
_SERVER["SCRIPT_FILENAME"]/var/www/sqlcipher/test.php
_SERVER["REMOTE_PORT"] 36434
_SERVER["GATEWAY_INTERFACE"] CGI/1.1
_SERVER["SERVER_PROTOCOL"]HTTP/1.1
_SERVER["REQUEST_METHOD"]GET
_SERVER["QUERY_STRING"]no value
_SERVER["REQUEST_URI"]/sqlcipher/test.php
_SERVER["SCRIPT_NAME"]/sqlcipher/test.php
_SERVER["PHP_SELF"]/sqlcipher/test.php
_SERVER["REQUEST_TIME"]1360616214

PHP License

This program is free software; you can redistribute it and/or modify it under the terms of the PHP License as published by the PHP Group and included in the distribution in the file: LICENSE

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

If you did not receive a copy of the PHP license, or have any questions about PHP licensing, please contact lic...@php.net.


1

Nick Parker

unread,
Feb 11, 2013, 4:28:58 PM2/11/13
to DRA, sqlc...@googlegroups.com
On 2/11/13 2:59 PM, DRA wrote:
> There you go. Thanks again Nick.
>
>
> PHP Logo <http://www.php.net/>
> Suhosin logo <http://www.suhosin.org/>This server is protected with the
> Suhosin Patch 0.9.10
> Copyright (c) 2006-2007 Hardened-PHP Project
> <http://www.hardened-php.net/> Copyright (c) 2007-2009 SektionEins GmbH
> <http://www.sektioneins.de/>
>
>
> Zend logo <http://www.zend.com/>This program makes use of the Zend
> Scripting Language Engine:
> Zend Engine v2.3.0, Copyright (c) 1998-2012 Zend Technologies
>
>
> ------------------------------------------------------------------------
>
>
> PHP Credits
> <http://localhost/sqlcipher/test.php?=PHPB8B5F2A0-3C92-11d3-A3A9-4C7B08C10000>
>
> ------------------------------------------------------------------------
>
>
> Configuration
>
>
> apache2handler
>
> Apache Version Apache/2.2.22 (Ubuntu)
> Apache API Version 20051115
> Server Administrator webmaster@localhost
> Hostname:Port 127.0.1.1:80 <http://127.0.1.1:80>
> QUERY_STRING /no value/
> auto_append_file /no value/ /no value/
> auto_globals_jit On On
> auto_prepend_file /no value/ /no value/
> browscap /no value/ /no value/
> default_charset /no value/ /no value/
> default_mimetype text/html text/html
> define_syslog_variables Off Off
> disable_classes /no value/ /no value/
> disable_functions
> pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,
> pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,
> display_errors Off Off
> display_startup_errors Off Off
> doc_root /no value/ /no value/
> docref_ext /no value/ /no value/
> docref_root /no value/ /no value/
> enable_dl Off Off
> error_append_string /no value/ /no value/
> error_log /no value/ /no value/
> error_prepend_string /no value/ /no value/
> error_reporting 22527 22527
> exit_on_timeout Off Off
> expose_php On On
> extension_dir /usr/lib/php5/20090626 /usr/lib/php5/20090626
> file_uploads On On
> highlight.bg <http://highlight.bg> #FFFFFF #FFFFFF
> highlight.comment #FF8000 #FF8000
> highlight.default #0000BB #0000BB
> highlight.html #000000 #000000
> highlight.keyword #007700 #007700
> highlight.string #DD0000 #DD0000
> html_errors Off Off
> ignore_repeated_errors Off Off
> ignore_repeated_source Off Off
> ignore_user_abort Off Off
> implicit_flush Off Off
> include_path .:/usr/share/php:/usr/share/pear
> .:/usr/share/php:/usr/share/pear
> log_errors On On
> log_errors_max_len 1024 1024
> magic_quotes_gpc Off Off
> magic_quotes_runtime Off Off
> magic_quotes_sybase Off Off
> mail.add_x_header On On
> mail.force_extra_parameters /no value/ /no value/
> mail.log /no value/ /no value/
> max_execution_time 30 30
> max_file_uploads 20 20
> max_input_nesting_level 64 64
> max_input_time 60 60
> max_input_vars 1000 1000
> memory_limit 128M 128M
> open_basedir /no value/ /no value/
> output_buffering 4096 4096
> output_handler /no value/ /no value/
> post_max_size 8M 8M
> precision 14 14
> realpath_cache_size 16K 16K
> realpath_cache_ttl 120 120
> register_argc_argv Off Off
> register_globals Off Off
> register_long_arrays Off Off
> report_memleaks On On
> report_zend_debug On On
> request_order GP GP
> safe_mode Off Off
> safe_mode_exec_dir /no value/ /no value/
> safe_mode_gid Off Off
> safe_mode_include_dir /no value/ /no value/
> sendmail_from /no value/ /no value/
> sendmail_path /usr/sbin/sendmail -t -i /usr/sbin/sendmail -t -i
> serialize_precision 17 17
> short_open_tag On On
> SMTP localhost localhost
> smtp_port 25 25
> sql.safe_mode Off Off
> track_errors Off Off
> unserialize_callback_func /no value/ /no value/
> upload_max_filesize 2M 2M
> upload_tmp_dir /no value/ /no value/
> user_dir /no value/ /no value/
> user_ini.cache_ttl 300 300
> user_ini.filename .user.ini .user.ini
> variables_order GPCS GPCS
> xmlrpc_error_number 0 0
> xmlrpc_errors Off Off
> y2k_compliance On On
> zend.enable_gc On On
>
>
> ctype
>
> ctype functions enabled
>
>
> date
>
> date/time support enabled
> "Olson" Timezone Database Version 0.system
> Timezone Database internal
> Default timezone America/Los_Angeles
>
>
> Directive Local Value Master Value
> date.default_latitude 31.7667 31.7667
> date.default_longitude 35.2333 35.2333
> date.sunrise_zenith 90.583333 90.583333
> date.sunset_zenith 90.583333 90.583333
> date.timezone /no value/ /no value/
> exif.encode_jis /no value/ /no value/
> exif.encode_unicode ISO-8859-15 ISO-8859-15
>
>
> fileinfo
>
> fileinfo support enabled
> version 1.0.5-dev
>
>
> filter
>
> Input Validation and Filtering enabled
> Revision $Revision: 321634 $
>
>
> Directive Local Value Master Value
> filter.default unsafe_raw unsafe_raw
> filter.default_flags /no value/ /no value/
> mbstring.detect_order /no value/ /no value/
> mbstring.encoding_translation Off Off
> mbstring.func_overload 0 0
> mbstring.http_input pass pass
> mbstring.http_output pass pass
> mbstring.http_output_conv_mimetypes ^(text/|application/xhtml\+xml)
> ^(text/|application/xhtml\+xml)
> mbstring.internal_encoding /no value/ /no value/
> mbstring.language neutral neutral
> mbstring.strict_detection Off Off
> mbstring.substitute_character /no value/ /no value/
>
>
> mhash
>
> MHASH support Enabled
> MHASH API Version Emulated Support
>
>
> mysql
>
> MySQL Support enabled
> Active Persistent Links 0
> Active Links 0
> Client API version 5.5.29
> MYSQL_MODULE_TYPE external
> MYSQL_SOCKET /var/run/mysqld/mysqld.sock
> MYSQL_INCLUDE -I/usr/include/mysql
> MYSQL_LIBS -L/usr/lib/x86_64-linux-gnu -lmysqlclient_r
>
>
> Directive Local Value Master Value
> mysql.allow_local_infile On On
> mysql.allow_persistent On On
> mysql.connect_timeout 60 60
> mysql.default_host /no value/ /no value/
> mysql.default_password /no value/ /no value/
> mysql.default_port /no value/ /no value/
> mysql.default_socket /var/run/mysqld/mysqld.sock /var/run/mysqld/mysqld.sock
> mysql.default_user /no value/ /no value/
> mysql.max_links Unlimited Unlimited
> mysql.max_persistent Unlimited Unlimited
> mysql.trace_mode Off Off
>
>
> mysqli
>
> MysqlI Support enabled
> Client API library version 5.5.29
> Active Persistent Links 0
> Inactive Persistent Links 0
> Active Links 0
> Client API header version 5.5.29
> MYSQLI_SOCKET /var/run/mysqld/mysqld.sock
>
>
> Directive Local Value Master Value
> mysqli.allow_local_infile On On
> mysqli.allow_persistent On On
> mysqli.default_host /no value/ /no value/
> mysqli.default_port 3306 3306
> mysqli.default_pw /no value/ /no value/
> mysqli.default_socket /var/run/mysqld/mysqld.sock
> /var/run/mysqld/mysqld.sock
> mysqli.default_user /no value/ /no value/
> phar.cache_list /no value/ /no value/
> phar.readonly On On
> phar.require_hash On On
>
>
> posix
>
> Revision $Revision: 321634 $
>
>
> Reflection
>
> Reflection enabled
> Version $Revision: 321634 $
>
>
> session
>
> Session Support enabled
> Registered save handlers files user
> Registered serializer handlers php php_binary wddx
>
>
> Directive Local Value Master Value
> session.auto_start Off Off
> session.bug_compat_42 Off Off
> session.bug_compat_warn Off Off
> session.cache_expire 180 180
> session.cache_limiter nocache nocache
> session.cookie_domain /no value/ /no value/
> session.cookie_httponly Off Off
> session.cookie_lifetime 0 0
> session.cookie_path / /
> session.cookie_secure Off Off
> session.entropy_file /no value/ /no value/
> session.entropy_length 0 0
> session.gc_divisor 1000 1000
> session.gc_maxlifetime 1440 1440
> session.gc_probability 0 0
> session.hash_bits_per_character 5 5
> session.hash_function 0 0
> session.name <http://session.name> PHPSESSID PHPSESSID
> session.referer_check /no value/ /no value/
> sqlite3.extension_dir /no value/ /no value/
>
>
> standard
>
> Dynamic Library Support enabled
> Path to sendmail /usr/sbin/sendmail -t -i
>
>
> Directive Local Value Master Value
> assert.active 1 1
> assert.bail 0 0
> assert.callback /no value/ /no value/
> assert.quiet_eval 0 0
> assert.warning 1 1
> auto_detect_line_endings 0 0
> default_socket_timeout 60 60
> from /no value/ /no value/
> safe_mode_allowed_env_vars PHP_ PHP_
> safe_mode_protected_env_vars LD_LIBRARY_PATH LD_LIBRARY_PATH
> url_rewriter.tags a=href,area=href,frame=src,input=src,form=fakeentry
> a=href,area=href,frame=src,input=src,form=fakeentry
> user_agent /no value/ /no value/
> zlib.output_handler /no value/ /no value/
> _SERVER["QUERY_STRING"] /no value/
> _SERVER["REQUEST_URI"] /sqlcipher/test.php
> _SERVER["SCRIPT_NAME"] /sqlcipher/test.php
> _SERVER["PHP_SELF"] /sqlcipher/test.php
> _SERVER["REQUEST_TIME"] 1360616214
>
>
> PHP License
>
> This program is free software; you can redistribute it and/or modify it
> under the terms of the PHP License as published by the PHP Group and
> included in the distribution in the file: LICENSE
>
> This program is distributed in the hope that it will be useful, but
> WITHOUT ANY WARRANTY; without even the implied warranty of
> MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
>
> If you did not receive a copy of the PHP license, or have any questions
> about PHP licensing, please contact lic...@php.net
> <mailto:lic...@php.net>.
> > <mailto:npa...@zetetic.net <mailto:npa...@zetetic.net>>>
Hi Dean,

I can see it is loading /etc/php5/apache2/conf.d/sqlite3.ini, what is
the content of that file? Does it reference your new module that you
have built for SQLCipher?

--
Nick Parker

DRA

unread,
Feb 11, 2013, 4:51:23 PM2/11/13
to Nick Parker, sqlc...@googlegroups.com
I believe so.

# cat /etc/php5/conf.d/sqlcipher.ini 
extension=/root/php-5.4.0/ext/sqlite3/modules/sqlite3.so


# cat /etc/php5/conf.d/sqlite3.ini.bak 
; configuration for php SQLite module
extension=sqlite3.so

The .bak extension I applied just now (restarted apache) so I could try a version of sqlite3.ini with the exact same content of sqlcipher.ini.

More info: I don't believe I ever installed sqlite.  I just went straight to sqlcipher.

Nick Parker

unread,
Feb 11, 2013, 5:01:58 PM2/11/13
to DRA, sqlc...@googlegroups.com
> > Hostname:Port 127.0.1.1:80 <http://127.0.1.1:80> <http://127.0.1.1:80>
> > highlight.bg <http://highlight.bg> <http://highlight.bg>
> > session.name <http://session.name> <http://session.name>
> > <mailto:lic...@php.net <mailto:lic...@php.net>>.
> >
> >
> > 1
> >
> > On Mon, Feb 11, 2013 at 12:28 PM, Nick Parker <npa...@zetetic.net
> <mailto:npa...@zetetic.net>
> > <mailto:npa...@zetetic.net <mailto:npa...@zetetic.net>>> wrote:
> >
> > Hi Dean,
> >
> > It is good to see the compilation of the module worked with
> > SQLCipher. Next up is to verify your module is being loaded. The
> > error message you receive (i.e., undefined symbol
> > object_properties_init) is not from SQLCipher itself, so I have a
> > feeling it comes from either your PHP installation, or the PHP
> > module itself. Can you create a PHP page that dumps the
> contents of
> > phpinfo(); to see if your module is loaded? Thanks!
> >
> > Nick Parker
> >
> >
> > On Mon, Feb 11, 2013 at 1:04 PM, DRA <s2c...@gmail.com
> <mailto:s2c...@gmail.com>
> > <mailto:s2c...@gmail.com <mailto:s2c...@gmail.com>>> wrote:
> >
> > Hi Nick,
> >
> > # strings /root/php-5.4.0/ext/sqlite3/modules/sqlite3.so |
> grep
> > cipher_version
> > codec_get_cipher_version
> > cipher_version
> >
> > # strings /root/sqlcipher/.libs/libsqlite3.so | grep
> cipher_version
> > codec_get_cipher_version
> > cipher_version
> >
> >
> > The files are still where I built them.
> >
> > Dean
> >
> >
> > On Mon, Feb 11, 2013 at 7:30 AM, Nick Parker
> > <npa...@zetetic.net <mailto:npa...@zetetic.net>
Hi Dean,

I think it may have trouble loading the module based on that path, even
though it is absolute. Could you dropping the SQLCipher based
sqlite3.so into the directory on your machine where the other PHP
modules are loaded from? You will want to rename the sqlite3.so if it
exists for backup purposes. This will allow you to change the
sqlite3.ini file back to extension=sqlite3.so. Of course you will want
to restart Apache to make sure everything reloads.

--
Nick Parker

DRA

unread,
Feb 11, 2013, 5:23:37 PM2/11/13
to Nick Parker, sqlc...@googlegroups.com
Backed up sqlight3.so in the module default directory.  Moved in our new sqlcipher version of sqlite3.so.  Pointed sqlite3.ini to that default directory, as well as sqlcipher.ini after the first failed attempt.  Restarted apache after each attempt.

Right out of the apache error log:  "/usr/sbin/apache2: symbol lookup error: /usr/lib/php5/20090626/sqlite3.so: undefined symbol: object_properties_init"

Mind you apache didn't look in that default module directory until I changed /etc/php/conf.d/sqlcipher.ini to be just "extension=sqlite3.so".

Without apache:
# php test.php 
PHP Warning:  Module 'sqlite3' already loaded in Unknown on line 0

php: symbol lookup error: /usr/lib/php5/20090626/sqlite3.so: undefined symbol: object_properties_init

DRA

unread,
Feb 14, 2013, 9:30:35 AM2/14/13
to Nick Parker, sqlc...@googlegroups.com
Hi Nick,

Thanks for your time and help.  I did figure out a sort of 'work around' you could say, so I'm going to reply here so that there's some record of it for others who follow this path.

Thinking it had to do with the apache php module for sqlite, I decided to try recompiling it, but from the source of the exact same version of PHP on my system.  It worked.  In my case the Debian repos had version 5.3.7 of PHP, and so I altered the curl command (as stated in the instructions on sqlcipher.net) to download the same version and followed the same instructions there after.  Maybe this was implied in the instructions, but I didn't get.

I'm not sure if this will break when the repos are updated with a new version of PHP.  Any thoughts?

Also, I think it's worth mentioning that the instructions on sqlcipher.net need a bit of a touch up where they state to run "phpize".  I needed to change a file's name before running phpize, config0.m4 is what exists in the directory, but it needs config.m4.  This was something I gleaned from the archive of this list, but only after much hair pulling.

Also also, I'm just realizing the subject of this thread might make it hard for someone to find this solution.  I'll leave it to you guys to figure out how and if you want to put it somewhere else.

Triple also, how would you advise buttoning this up?  What files should reside where?  I don't want to keep things in the root directory the way they are now.

Dean

Nick Parker

unread,
Feb 14, 2013, 9:59:17 AM2/14/13
to DRA, sqlc...@googlegroups.com
On 2/14/13 8:30 AM, DRA wrote:
> Hi Nick,
>
> Thanks for your time and help. I did figure out a sort of 'work around'
> you could say, so I'm going to reply here so that there's some record of
> it for others who follow this path.
>
> Thinking it had to do with the apache php module for sqlite, I decided
> to try recompiling it, but from the source of the exact same version of
> PHP on my system. It worked. In my case the Debian repos had version
> 5.3.7 of PHP, and so I altered the curl command (as stated in the
> instructions on sqlcipher.net <http://sqlcipher.net>) to download the
> same version and followed the same instructions there after. Maybe this
> was implied in the instructions, but I didn't get.
>
> I'm not sure if this will break when the repos are updated with a new
> version of PHP. Any thoughts?
>
> Also, I think it's worth mentioning that the instructions on
> sqlcipher.net <http://sqlcipher.net> need a bit of a touch up where they
> state to run "phpize". I needed to change a file's name before running
> phpize, config0.m4 is what exists in the directory, but it needs
> config.m4. This was something I gleaned from the archive of this list,
> but only after much hair pulling.
>
> Also also, I'm just realizing the subject of this thread might make it
> hard for someone to find this solution. I'll leave it to you guys to
> figure out how and if you want to put it somewhere else.
>
> Triple also, how would you advise buttoning this up? What files should
> reside where? I don't want to keep things in the root directory the way
> they are now.
>
> Dean
>

Hi Dean,

I'm glad to hear you were able to get your build working correctly. I
will adjust the article to reflect the user should be grabbing the
source of the module for the same version of PHP they are running as
well as an update to the config.m4 file. Thanks for the update.

As far as file location goes, the exact location will depend on where
the installation occurs on the platform you are running. I can't speak
specifically for a Debian distribution, however I would look for where
other PHP modules are stored on the system as a starting location.

--
Nick Parker
Reply all
Reply to author
Forward
0 new messages