Using self-signed certificates

How to install self-signed certificates both system-wide and for a virtualenv.