Today, I had the necessity to embed an iframe on an HTTPS web page and most browsers now won't allow you to embed an HTTP resource on an HTTPS page raising the mixed content warning. Since the code was quite experimental, I didn't want to deploy it out of localhost. So I setup a self-signed TLS certificate for localhost that was accepted by Google Chrome browser.
First, we need to create a key that will be used to sign our certificate. You will be prompted for a password, which you can enter for now:
openssl genrsa -camellia256 -out server.key 2048
Let's remove the passphrase from the key now:
cp server.key server.key.orig openssl rsa -in server.key.orig -out server.key
Next, we need to create a certificate signing request (CSR) with the above created key. Enter the information you are prompted for:
openssl req -new -key server.key -out server.csr
Create a certificate with validity of 365 days for the above CSR:
openssl x509 -req -sha256 -days 365 -in server.csr -signkey server.key -out server.crt
You can use the above server.key and server.crt in any web server or application of your choice.
Create a single file with the certificate and private key to be added into the store:
cat server.key server.crt > localhost.pem
Finally, add this certificate into our trusted store so that Chrome doesn't complain:
certutil -d sql:$HOME/.pki/nssdb -A -t "C,," -n "localhost" -i localhost.pem
Your browser shouldn't complain any more with your self-signed certificate successfully added into the store.
Elasticsearch autocomplete on related keywords
Recently, I had to work on a client request to add autocomplete to their site's search based not just on a specific list but on related keywords.
For example, suppose you had a list of TV series like Simpsons, Futurama, Tom and Jerry etc. The autosearch had to suggest the …read more
Simple Command Line Dropbox Uploader in Python
I don't use Dropbox frequently. In fact, I would prefer not to use it but work requires me to use it from time to time. My only use case was to upload files onto a shared folder. So for my usage, it makes no sense to run the desktop client …read more
Nginx Basic Auth without htpasswd-tools
Resize Qemu Image
Upload a directory to Rackspace Cloud Files from command line
Here's a simple bash script that uploads a directory to Rackspace Cloud Files and may later on be served as a static website.
First we have to authenticate to get the authentication token that has to be passed for every request:
$ curl -v -X GET -H "X-Auth-User: <username>" -H "X-Auth-Key …
The missing documentation for django.utils.datastructures
Cross posted from my work blog.
django.utils.datastructures is intentionally not documented by the django core devs because it is an internal API and is liable to change without any notice. This file is not governed by django's lenient backwards-compatible policy. You have been sufficiently warned!
With the …read more
Dissecting Phonegap's architecture
Cross-posted from my work blog.