Search code examples
pythonlinuxsslweb2py

How to add a SSL certificate after running Web2py 'one step production deployment'


I have set up a web2py environment on a linux server using the 'one step production deployment' descriped in the web2py document. Now I can go to my website by typing my domain name into a web browser, except now it is untrusted by the browser.

Then I got a ssl certificate that I want to add to my server. So my question is how to add ssl certificate after using the one step deployment?

I searched online, but most tutorial is to setup every thing from scratch.


Solution

  • If you look into the one-step-production-deployment script, you can see that it generated a self-signed cert:

    echo "creating a self signed certificate"
    echo "=================================="
    openssl genrsa 1024 > /etc/apache2/ssl/self_signed.key
    chmod 400 /etc/apache2/ssl/self_signed.key
    openssl req -new -x509 -nodes -sha1 -days 365 -key /etc/apache2/ssl/self_signed.key > /etc/apache2/ssl/self_signed.cert
    openssl x509 -noout -fingerprint -text < /etc/apache2/ssl/self_signed.cert > /etc/apache2/ssl/self_signed.info
    

    And let Apache use it:

    <VirtualHost *:443>
      SSLEngine on
      SSLCertificateFile /etc/apache2/ssl/self_signed.cert
      SSLCertificateKeyFile /etc/apache2/ssl/self_signed.key
      # ...
    

    So I think what you need to do is changing the path above to your new cert.