##// END OF EJS Templates
hgweb: pass ui into preparehttpserver...
Gregory Szorc -
r29553:cd3e5886 default
parent child Browse files
Show More
@@ -58,7 +58,7 b' class _httprequesthandler(BaseHTTPServer'
58 58 url_scheme = 'http'
59 59
60 60 @staticmethod
61 def preparehttpserver(httpserver, ssl_cert):
61 def preparehttpserver(httpserver, ui):
62 62 """Prepare .socket of new HTTPServer instance"""
63 63 pass
64 64
@@ -222,15 +222,17 b' class _httprequesthandlerssl(_httpreques'
222 222 url_scheme = 'https'
223 223
224 224 @staticmethod
225 def preparehttpserver(httpserver, ssl_cert):
225 def preparehttpserver(httpserver, ui):
226 226 try:
227 227 import ssl
228 228 ssl.wrap_socket
229 229 except ImportError:
230 230 raise error.Abort(_("SSL support is unavailable"))
231
232 certfile = ui.config('web', 'certificate')
231 233 httpserver.socket = ssl.wrap_socket(
232 234 httpserver.socket, server_side=True,
233 certfile=ssl_cert, ssl_version=ssl.PROTOCOL_TLSv1)
235 certfile=certfile, ssl_version=ssl.PROTOCOL_TLSv1)
234 236
235 237 def setup(self):
236 238 self.connection = self.request
@@ -264,7 +266,7 b' class MercurialHTTPServer(object, _mixin'
264 266 self.daemon_threads = True
265 267 self.application = app
266 268
267 handler.preparehttpserver(self, ui.config('web', 'certificate'))
269 handler.preparehttpserver(self, ui)
268 270
269 271 prefix = ui.config('web', 'prefix', '')
270 272 if prefix:
@@ -404,12 +404,13 b' Start patched hgweb that requires client'
404 404 > from mercurial.hgweb import server
405 405 > class _httprequesthandlersslclientcert(server._httprequesthandlerssl):
406 406 > @staticmethod
407 > def preparehttpserver(httpserver, ssl_cert):
407 > def preparehttpserver(httpserver, ui):
408 > certfile = ui.config('web', 'certificate')
408 409 > sslcontext = ssl.SSLContext(ssl.PROTOCOL_TLSv1)
409 410 > sslcontext.verify_mode = ssl.CERT_REQUIRED
410 > sslcontext.load_cert_chain(ssl_cert)
411 > sslcontext.load_cert_chain(certfile)
411 412 > # verify clients by server certificate
412 > sslcontext.load_verify_locations(ssl_cert)
413 > sslcontext.load_verify_locations(certfile)
413 414 > httpserver.socket = sslcontext.wrap_socket(httpserver.socket,
414 415 > server_side=True)
415 416 > server._httprequesthandlerssl = _httprequesthandlersslclientcert
General Comments 0
You need to be logged in to leave comments. Login now