-
-
Notifications
You must be signed in to change notification settings - Fork 618
SAN extension required for TLS interception certificate generation #261
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,7 +9,6 @@ | |
| :license: BSD, see LICENSE for more details. | ||
| """ | ||
| import threading | ||
| import subprocess | ||
| import os | ||
| import ssl | ||
| import socket | ||
|
|
@@ -25,6 +24,7 @@ | |
| from ..parser import HttpParser, httpParserStates, httpParserTypes | ||
| from ..methods import httpMethods | ||
|
|
||
| from ...common import pki | ||
| from ...common.types import HasFileno | ||
| from ...common.constants import PROXY_AGENT_HEADER_VALUE | ||
| from ...common.utils import build_http_response, text_ | ||
|
|
@@ -278,8 +278,8 @@ def on_request_complete(self) -> Union[socket.socket, bool]: | |
| logger.error( | ||
| 'BrokenPipeError when wrapping client') | ||
| return True | ||
| except OSError: | ||
| logger.error('OSError when wrapping client') | ||
| except OSError as e: | ||
| logger.error('OSError when wrapping client:"{}"'.format(e.strerror)) | ||
| return True | ||
| # Update all plugin connection reference | ||
| for plugin in self.plugins.values(): | ||
|
|
@@ -362,18 +362,9 @@ def generate_upstream_certificate( | |
| logger.debug('Generating certificates %s', cert_file_path) | ||
| # TODO: Parse subject from certificate | ||
| # Currently we only set CN= field for generated certificates. | ||
| gen_cert = subprocess.Popen( | ||
| ['openssl', 'req', '-new', '-key', self.flags.ca_signing_key_file, '-subj', | ||
| f'/C=/ST=/L=/O=/OU=/CN={ text_(self.request.host) }'], | ||
| stdout=subprocess.PIPE, | ||
| stderr=subprocess.PIPE) | ||
| sign_cert = subprocess.Popen( | ||
| ['openssl', 'x509', '-req', '-days', '365', '-CA', self.flags.ca_cert_file, '-CAkey', | ||
| self.flags.ca_key_file, '-set_serial', str(self.uid.int), '-out', cert_file_path], | ||
| stdin=gen_cert.stdout, | ||
| stderr=subprocess.PIPE) | ||
| # TODO: Ensure sign_cert success. | ||
| sign_cert.communicate(timeout=10) | ||
| pki.gen_crt(cert_file_path, self.flags.ca_signing_key_file, self.flags.ca_key_file, | ||
| self.flags.ca_cert_file, text_(self.request.host), str(self.uid.int)) | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I kind of fail to understand the motive behind all the changes. a) I think they won't work cross platform e.g. will break on MacOS
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We need SAN and SHA 256. As your link say :
If i remember well, we must have a base cert/key/ca in sha256, to sign in sha256. It's for this reason that I ve changed a big part of the implementation. edit : Vs it only miss the -sha256, and extensions/extfile. I made some changes, hope it will be better for you. |
||
| return cert_file_path | ||
|
|
||
| def wrap_server(self) -> None: | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.