Wednesday, January 19, 2011

install php from source on ubuntu 10.10

http://www.php.net/manual/en/install.unix.apache2.php
http://httpd.apache.org/download.cgi
http://us2.php.net/downloads.php
sudo apt-get install g++
sudo apt-get install libssl-dev
tar -xjvf httpd-2.2.17.tar.bz2
cd httpd-2.2.17/
./configure --enable-so
sudo make
sudo make install
sudo /usr/local/apache2/bin/apachectl start
cd ..
tar -xjvf php-5.3.5.tar.bz2
cd php-5.3.5/
sudo apt-get install libxml2-dev
sudo apt-get install libmysqlclient-dev
./configure --with-apxs2=/usr/local/apache2/bin/apxs --with-mysql
sudo make
sudo make install
cd ..

Wednesday, January 12, 2011

Fetch SSL Certificate - Public Key Details

$url = 'www.digicert.com'; // For example
$context = stream_context_create();
$res = stream_context_set_option($context, 'ssl', 'capture_peer_cert', true);
$res = stream_context_set_option($context, 'ssl', 'verify_host', true);
if ($socket = stream_socket_client("ssl://$url:443/", $errno, $errstr, 30, STREAM_CLIENT_CONNECT, $context)) {
if ($options = stream_context_get_options($context)) {
if (isset($options['ssl']) && isset($options['ssl']['peer_certificate'])) {
$x509_resource = $options['ssl']['peer_certificate'];
$cert_arr = openssl_x509_parse($x509_resource);
openssl_x509_export($x509_resource,$x509_string);

$public_key_res = openssl_pkey_get_public($x509_string);
$public_key_arr = openssl_pkey_get_details($public_key_res);

print_r($public_key_arr);
}
}
}

Monday, January 10, 2011

preg_match reference links

http://us.php.net/manual/en/reference.pcre.pattern.modifiers.php
http://us.php.net/manual/en/regexp.reference.meta.php
http://us.php.net/manual/en/regexp.reference.escape.php
http://us.php.net/manual/en/regexp.reference.unicode.php