passiomatic / coldsweat

Web RSS aggregator and reader compatible with the Fever API
MIT License
145 stars 21 forks source link

Adding support for HTTPS #111

Closed SkyCrawl closed 1 year ago

SkyCrawl commented 7 years ago

A PR for #108 . When reviewing, I recommend to go commit after commit.

Notable changes (the last two commits):

  1. The command_serve method has been rewritten. All the SSL/TLS logic has been concentrated into it.
  2. Sample HTTPS authority & server certificates have been added, along with a super user-friendly script to generate them. Both certificates will not expire for the next 100 years.
  3. As agreed, we have a new command line option --https-only which requires the user to configure an HTTPS server certificate and private key. Even if the script has been configured to generate sample certificates, everyone can easily override the values and generate their own. Despite what we agreed on, it doesn't matter whether we bind localhost or 0.0.0.0.

Futher comments to notable changes:

  1. All are well documented. I must point out:
  2. The script automatically and safely deletes the certificate authority's private key before it finishes. I used it to generate the sample certificates and hereby solemnly swear that I do not have the private key either. As such, it is safe for developers to import the authority into their browser or client (as I have) but they're also free to also generate their own (in which case it is a good idea to add the parent directory to .gitignore).
    • The server's private key is a part of this PR (in plain text) because HTTPS would not function otherwise. As long as the sample server certificate is NOT imported into a trust store, it doesn't matter that its associated private key is actually public.
    • For more information, see the script's documentation.

Final notes:

  1. I've thoroughly tested as much as I could think of but I've written no tests.
  2. Solution for the WSGI issue can be moved into the Cascade class, without the need to override it. But perhaps it's better not to.
  3. PyLint gives off some errors & warnings in the original code which I've not fixed.
  4. This PR is but a beginning of security. On no account should anyone think that their site is secure because of HTTPS. As for Coldsweat, I'm quite sure it contains multiple web-related security vulnerabilites.

EDIT:
If you decide to accept the solution and porting it to Python 3 is desirable, just give me a shout :).

passiomatic commented 1 year ago

I'm closing this since next version will be based on Flask and this is not usable anymore.