Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for existing SSL certificates #32

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

Updog is a replacement for Python's `SimpleHTTPServer`.
It allows uploading and downloading via HTTP/S,
can set ad hoc SSL certificates and use HTTP basic auth.
can set ad hoc or existing SSL certificates and use HTTP basic auth.

<p align="center">
<img src="https://sc0tfree.squarespace.com/s/updog-screenshot.png" alt="Updog screenshot"/>
Expand All @@ -31,6 +31,8 @@ Install using pip:
| -p PORT, --port PORT | Port to serve [Default=9090] |
| --password PASSWORD | Use a password to access the page. (No username) |
| --ssl | Enable transport encryption via SSL |
| --sslcert | Path to existing SSL certificate |
| --sslkey | Path to existing SSL key (Passwords supported) |
| --version | Show version |
| -h, --help | Show help |

Expand Down Expand Up @@ -60,6 +62,10 @@ enter the password in the password field.

`updog --ssl`

Use a specific SSL certificate and SSL key (password protected keys supported):

`updog --sslcert /path/to/certificate --sslkey /path/to/certificate_key`

## Thanks

A special thank you to [Nicholas Smith](http://nixmith.com) for
Expand Down
6 changes: 5 additions & 1 deletion updog/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ def parse_arguments():
parser.add_argument('-p', '--port', type=int, default=9090,
help='Port to serve [Default=9090]')
parser.add_argument('--password', type=str, default='', help='Use a password to access the page. (No username)')
parser.add_argument('--ssl', action='store_true', help='Use an encrypted connection')
parser.add_argument('--ssl', action='store_true', help='Use an encrypted connection (temporary SSL/TLS certificate)')
parser.add_argument('--sslcert', type=str, help='Use an encrypted connection (existing SSL/TLS certificate)')
parser.add_argument('--sslkey', type=str, help='Use an encrypted connection (existing SSL/TLS certificate key)')
parser.add_argument('--version', action='version', version='%(prog)s v'+VERSION)

args = parser.parse_args()
Expand Down Expand Up @@ -176,6 +178,8 @@ def handler(signal, frame):
ssl_context = None
if args.ssl:
ssl_context = 'adhoc'
elif args.sslcert and args.sslkey:
ssl_context = (args.sslcert, args.sslkey)

run_simple("0.0.0.0", int(args.port), app, ssl_context=ssl_context)

Expand Down