| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
There was a problem hiding this comment.
Sorry, something went wrong.
| .. class:: HTTPServer(server_address, RequestHandlerClass, \ | ||
| bind_and_activate=True, *, tls=None) |
There was a problem hiding this comment.
This should be a separate class, not an argument.
Sorry, something went wrong.
| import socket # For gethostbyaddr() | ||
| import socketserver | ||
| import sys | ||
| import ssl |
There was a problem hiding this comment.
ssl support is optional, you have to wrap the import in a try/except block.
Sorry, something went wrong.
| """Wrap the socket in SSLSocket if TLS is enabled""" | ||
| super().server_activate() | ||
| if self.tls_cert and self.tls_key: | ||
| context = ssl.SSLContext(ssl.PROTOCOL_TLS_SERVER) |
There was a problem hiding this comment.
use ssl.create_default_context.
Sorry, something went wrong.
There was a problem hiding this comment.
The default SSL context requires a TLS 1.3 certificate so it doesn't work with ssl_cert.pem:
ssl.SSLError: [SSL: TLSV13_ALERT_CERTIFICATE_REQUIRED] tlsv13 alert certificate required
Is this something that we want to force for a development server?
Sorry, something went wrong.
There was a problem hiding this comment.
There is no such thing as a TLS 1.3 certificate. This is a TLS alert with message certificate required. Looks like the certificate does not have correct extensions to handle TLS 1.3.
You cannot use any file from test directory any way. The directory is often not installed or shipped to reduce disk space usage in containers or on small systems.
Sorry, something went wrong.
| def __init__(self, server_address, RequestHandlerClass, | ||
| bind_and_activate=True, *, tls=None): | ||
| if tls is None: | ||
| self.tls_cert = self.tls_key = None |
There was a problem hiding this comment.
It's not a cert file, it's a cert chain file.
Sorry, something went wrong.
| parser.add_argument('--tls-cert', | ||
| help='Specify the path to a TLS certificate') |
There was a problem hiding this comment.
cert chain
Sorry, something went wrong.
| elif not args.tls_cert or not args.tls_key: | ||
| parser.error('Both --tls-cert and --tls-key must be provided to enable TLS') | ||
| else: | ||
| tls = (args.tls_cert, args.tls_key) |
There was a problem hiding this comment.
It's common to have the private key and the cert chain in the same file. The key argument should be optional.
Sorry, something went wrong.
| import html | ||
| import http.client | ||
| import urllib.parse | ||
| import ssl |
There was a problem hiding this comment.
try/except ImportError
Sorry, something went wrong.
| # BaseHTTPServerTestCase. | ||
|
|
||
| # We have to use the correct path from the folder created by regtest | ||
| tls = ('../../Lib/test/ssl_cert.pem', '../../Lib/test/ssl_key.pem') |
There was a problem hiding this comment.
os.path.join(os.path.dirname(__file__), 'ssl_cert.pem')
Sorry, something went wrong.
| self.assertEqual(b'', data) | ||
|
|
||
|
|
||
| class BaseHTTPSServerTestCase(BaseTestCase): |
There was a problem hiding this comment.
Skip the test if ssl module is not supported
Sorry, something went wrong.
|
A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated. Once you have made the requested changes, please leave a comment on this pull request containing the phrase I have made the requested changes; please review again. I will then notify any core developers who have left a review that you're ready for them to take another look at this pull request. And if you don't make the requested changes, you will be put in the comfy chair! |
Sorry, something went wrong.
|
@remilapeyre I'm happy to continue this PR if you are not able to continue it |
Sorry, something went wrong.
Hi @jaswdr, I've been quite busy but should be able to finish it this week :) |
Sorry, something went wrong.
|
|
||
| .. warning:: | ||
|
|
||
| The HTTPS support is for development and test puposes and must not be used |
There was a problem hiding this comment.
spelling: purposes
Sorry, something went wrong.
|
closing this PR as abandoned as there's a new one up. |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
https://bugs.python.org/issue40990