Cherrypy Ssl Generate Private Key

Feb 16, 2014  Code example to get a Sharepoint Access Token to use with the Sharepoint REST API using a python 3 provider-hosted Sharepoint App (using cherrypy). This code takes the data POSTed to it when you click on the app in Sharepoint, and authenticates using OAuth to get the access token. To use the Sharepoint REST API with OAuth, the app needs to be registered with. Those two files are required when setting up an SSL/TLS server. The private key should always be kept secret. Generating a self signed certificate consists of a few steps. You can generate your private key with or without a passphrase to protect it. You only need to choose one of these options. This will generate a 2048-bit RSA private key.

CherryPy handles HTTP requests, packing and unpacking the low-level details, then passing control to your application’s page handler, which produce the body of the response. CherryPy allows you to return body content in a variety of types: a string, a list of strings, a file. CherryPy also allows you to yield content, rather than return.

If you want to convert your website from HTTP to HTTPS, you need to get a SSL certificate from a valid organization like Verisign or Thawte. You can also generate self signed SSL certificate for testing purpose.

In this article, let us review how to generate private key file (server.key), certificate signing request file (server.csr) and webserver certificate file (server.crt) that can be used on Apache server with mod_ssl.

Key, CSR and CRT File Naming Convention

I typically like to name the files with the domain name of the HTTPS URL that will be using this certificate. This makes it easier to identify and maintain.

  • Instead of server.key, I use www.thegeekstuff.com.key
  • Instead of server.csr, I use www.thegeekstuff.com.csr
  • Instead of server.crt, I use www.thegeekstuff.com.crt

1. Generate Private Key on the Server Running Apache + mod_ssl

First, generate a private key on the Linux server that runs Apache webserver using openssl command as shown below.

The generated private key looks like the following.

2. Generate a Certificate Signing Request (CSR)

Using the key generate above, you should generate a certificate request file (csr) using openssl as shown below.

3. Generate a Self-Signed SSL Certificate

For testing purpose, you can generate a self-signed SSL certificate that is valid for 1 year using openssl command as shown below.


You can use this method to generate Apache SSL Key, CSR and CRT file in most of the Linux, Unix systems including Ubuntu, Debian, CentOS, Fedora and Red Hat.

4. Get a Valid Trial SSL Certificate (Optional)

Instead of signing it youself, you can also generate a valid trial SSL certificate from thawte. i.e Before spending the money on purchasing a certificate, you can also get a valid fully functional 21 day trial SSL certificates from Thawte. Once this valid certificate works, you can either decide to purchase it from Thawte or any other SSL signing organization.

This step is optional and not really required. For testing purpose, you can always use the self-signed certificate that was generated from the above step.

Go to Thwate trial certificate request page and do the following:

Cherrypy Ssl Generate Private Key For Putty

  • Select “SSL Web Server Certificate (All servers)” under the “select your trial certificate”.
  • Do not check the PKCS #7 check-box under the “configure certificate”
  • Copy/Paste the *.csr file that you generate above in the textbox under “certificate signing request (CSR)”
  • Click on next at the bottom, which will give you a 21-day free trial certificate.


Copy/Paste the trial certificate to the www.thegeekstuff.com.crt file as shown below.

> Add your comment

If you enjoyed this article, you might also like.



Next post: Google Chrome OS – Beginning of End of Microsoft?

Previous post: Blog Makeover: New Thesis Theme In Action

Now that your nginx configuration works locally, let's make it accessible from the internet.

Configure ssl

If you want to access saltpad and your salt-api over the internet, you're likely to want to configure SSL on nginx.

Your configuration should currently looks like:

Mozilla has a very nice ssl generator website that could helps tweak your nginx configuration, but here is a most secure nginx configuration for reference:

You will need a ssl certificate for activating ssl, you can either buy one, generate one or use let's encrypt for generating one.

From your salt-master, let's check that the configuration works correctly.

If you have enabled ssl, replace http://localhost/ by https://SALTPAD.YOURDNS/ in below commands.

Check that nginx proxy saltpad correclty:

Expected output:

Check that nginx proxy saltpad config file correctly:

The output should match the content of the settings.json file you deployed earlier.

Cherrypy Ssl Generate Private Key From Public Key

Saltpad configuration

Now that your salt-api instance is accessible from internet (don't forget to open the port and whitelist your IPs if necessary), we need to tweak the saltpad configuration a little.

You will need to change API_URL to match the DNS of your salt-api server (in our example it was SALTPAD.YOURDNS).

If you enabled ssl, you will also need to set SECURE_HTTP to true or saltpad will try to connect over a non encrypted connection.

Free emulator download for mac. You don't need to reload the webserver, just save the settings.json file and go at http://SALTPAD.YOURDNS/ or https://SALTPAD.YOURNDS/ to access Saltpad and start mastering your Saltstack environment.