Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/novnc/websockify into pyi…
Browse files Browse the repository at this point in the history
…nstaller
  • Loading branch information
Giuseppe Corbelli committed Apr 3, 2019
2 parents 8df802f + e4658ad commit 1a7481b
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 12 deletions.
3 changes: 2 additions & 1 deletion run
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@

import websockify

websockify.websocketproxy.websockify_init()
if __name__ == '__main__':
websockify.websocketproxy.websockify_init()
6 changes: 3 additions & 3 deletions tests/test_websockifyserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ class fake_create_default_context():
def __init__(self, purpose):
self.verify_mode = None
self.options = 0
def load_cert_chain(self, certfile, keyfile):
def load_cert_chain(self, certfile, keyfile, password):
pass
def set_default_verify_paths(self):
pass
Expand Down Expand Up @@ -310,7 +310,7 @@ class fake_create_default_context():
def __init__(self, purpose):
self.verify_mode = None
self.options = 0
def load_cert_chain(self, certfile, keyfile):
def load_cert_chain(self, certfile, keyfile, password):
pass
def set_default_verify_paths(self):
pass
Expand Down Expand Up @@ -351,7 +351,7 @@ class fake_create_default_context(object):
def __init__(self, purpose):
self.verify_mode = None
self._options = 0
def load_cert_chain(self, certfile, keyfile):
def load_cert_chain(self, certfile, keyfile, password):
pass
def set_default_verify_paths(self):
pass
Expand Down
8 changes: 5 additions & 3 deletions websockify/websocketproxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
import signal, socket, optparse, time, os, sys, subprocess, logging, errno, ssl
import locale
try:
from socketserver import ForkingMixIn
from socketserver import ThreadingMixIn
except ImportError:
from SocketServer import ForkingMixIn
from SocketServer import ThreadingMixIn

try:
from http.server import HTTPServer
Expand Down Expand Up @@ -482,6 +482,8 @@ def websockify_init():
help="SSL certificate file")
parser.add_option("--key", default=None,
help="SSL key file (if separate from cert)")
parser.add_option("--key-password", default=None,
help="SSL key password")
parser.add_option("--ssl-only", action="store_true",
help="disallow non-encrypted client connections")
parser.add_option("--ssl-target", action="store_true",
Expand Down Expand Up @@ -728,7 +730,7 @@ def websockify_init():
server.start_server()


class LibProxyServer(ForkingMixIn, HTTPServer):
class LibProxyServer(ThreadingMixIn, HTTPServer):
"""
Just like WebSocketProxy, but uses standard Python SocketServer
framework.
Expand Down
8 changes: 3 additions & 5 deletions websockify/websockifyserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,6 @@
if sys.platform == 'win32':
# make sockets pickle-able/inheritable
import multiprocessing.reduction
# the multiprocesssing module behaves much differently on Windows,
# and we have yet to fix all the bugs
sys.exit("Windows is not supported at this time")

from websockify.websocket import WebSocket, WebSocketWantReadError, WebSocketWantWriteError
from websockify.websocketserver import WebSocketRequestHandlerMixIn
Expand Down Expand Up @@ -340,7 +337,7 @@ class Terminate(Exception):

def __init__(self, RequestHandlerClass, listen_fd=None,
listen_host='', listen_port=None, source_is_ipv6=False,
verbose=False, cert='', key='', ssl_only=None,
verbose=False, cert='', key='', key_password=None, ssl_only=None,
verify_client=False, cafile=None,
daemon=False, record='', web='', web_auth=False,
file_only=False,
Expand Down Expand Up @@ -380,6 +377,7 @@ def __init__(self, RequestHandlerClass, listen_fd=None,

# keyfile path must be None if not specified
self.key = None
self.key_password = key_password

# Make paths settings absolute
self.cert = os.path.abspath(cert)
Expand Down Expand Up @@ -577,7 +575,7 @@ def do_handshake(self, sock, address):
if self.ssl_ciphers is not None:
context.set_ciphers(self.ssl_ciphers)
context.options = self.ssl_options
context.load_cert_chain(certfile=self.cert, keyfile=self.key)
context.load_cert_chain(certfile=self.cert, keyfile=self.key, password=self.key_password)
if self.verify_client:
context.verify_mode = ssl.CERT_REQUIRED
if self.cafile:
Expand Down

0 comments on commit 1a7481b

Please sign in to comment.