Blog / Security

How to share your local web server to the Internet using a reverse SSH tunnel

July 25, 2013

I was recently working with integrating Stripe payments with a Django app. Since it's a subscription-based web application, it made a lot of sense for us to use webhooks, which Stripe supports. You basically set a URL in your Stripe account settings where Stripe could POST when an event occurs (eg. trial ends, subscription canceled due to an unpaid invoice, etc.). This eliminates the need of having to poll the Stripe server to check …

How to add self-signed certificates to the certificate store on Ubuntu Linux 12.04 to remove security warnings in Google Chrome

January 28, 2013

I use self-signed certificates for my websites and I finally found the security warnings in Google Chrome (Chromium) annoying enough that I decided to do something about it. When you’re accessing your sites many times a day, that extra step of clicking “continue” adds up. The solution is to add the certificate and make it “trusted” in the certificate store that Google Chrome uses.

On Windows, this is very easy to do. You simply export …

How to create a self-signed SSL certificate on Ubuntu 12.04 in one command line

January 21, 2013

My self-signed certificate for this blog just expired and I just created a new one. I remember having to type in multiple commands before to create one, but I found this command in one of my notes in Evernote (don’t remember where I got it from) which lets you create a self-signed certificate by just typing in one command line:

sudo openssl req -x509 -nodes -days 1825 -newkey rsa:2048 -keyout /etc/apache2/ssl/apache.key -out /etc/apache2/ssl/apache.crt

The above …

Error Message: “Peer authentication failed for user ‘username’” when connecting to a PostgreSQL database from a Django application

December 4, 2012

Error Message:

psycopg2.OperationalError: FATAL: Peer authentication failed for user “username”

I was setting up a friend’s project on my Ubuntu 12.04 laptop last night and ran into this database connection problem when I tried to ran his Django application.

There are actually 2 solutions to this problem:

Solution 1:

In your settings.py file, in the database settings, set the ‘HOST’ to ‘localhost’ instead of an empty string.

Solution 2:

Modify the /etc/postgresql/9.1/main/pg_hba.conf file and change …

How to allow remote connections to your PostgreSQL 9.0 database server on Ubuntu 10.04 LTS

September 8, 2011

Change directory to /etc/postgresql/9.0/main and modify the following configs (I know you’re sick of hearing this, but I recommend you back up your original configs before making any changes):

postgresql.conf

In “Connections and Authentication” section:

From

#listen_addresses = 'localhost'
#password_encryption = on

To

listen_addresses = '*'
password_encryption = on

pg_hba.conf

From

host    all    all    127.0.0.1/32    md5
host    all    all    ::1/128         md5

To

host    all    all    0.0.0.0/0   md5
host    all    all    ::0/0       md5

Restart the ssh …