Ubuntu server 12.0.4 SSL23_GET_SERVER_HELLO:sslv3 alert handshake failure

Ran into some trouble with Ubuntu 12.0.4 and an “SSL23_GET_SERVER_HELLO:sslv3 alert handshake failure” error while accessing the Zoho Docs API through Python. Apparently Zoho’s API endpoint enforces a certain SSL version. The full python error was:

SSLError: [Errno 1] _ssl.c:504: error:14077410:SSL routines:SSL23_GET_SERVER_HELLO:sslv3 alert handshake failure

After ruling out python and openssl, the fix was to simply update to Ubuntu 12.0.4.1 through apt:

apt-get update
apt-get upgrade

And for the hell of it did a distribution upgrade:

apt-get dist-upgrade

phpFlickr 3.1 cache unserialize error

I came across a problem today with phpFlickr 3.1 and the way it handles its database caching. I believe it has to do with commas in the serialized data that is being inserted into the cache table. After grabbing the cache result php gave me this error in the phpFlickr library:

Notice: unserialize(): Error at offset ... phpFlickr.php

To fix this error you need to base64 encode and decode the data going into the database.

in phpFlickr modify line 144 to decode the response:

return base64_decode($result['response']);

line 177 on cache row update:

$sql = "UPDATE " . $this->cache_table . " SET response = '" . str_replace("'", "''", base64_encode($response)) . "', expiration = '" . strftime("%Y-%m-%d %H:%M:%S") . "' WHERE request = '" . $reqhash . "'";

line 180 on cache row insert:

$sql = "INSERT INTO " . $this->cache_table . " (request, response, expiration) VALUES ('$reqhash', '" . str_replace("'", "''", base64_encode($response)) . "', '" . strftime("%Y-%m-%d %H:%M:%S") . "')";

Thanks to David Walsh for his php serialize tips:
http://davidwalsh.name/php-serialize-unserialize-issues