Skip to content

Feature #5019 - allow context configuration changes in tls_* hooks - #5027

Closed
jsmucr wants to merge 3 commits into
mitmproxy:mainfrom
jsmucr:feat/ssl-insecure-override
Closed

jsmucr wants to merge 3 commits into
mitmproxy:mainfrom
jsmucr:feat/ssl-insecure-override

Conversation

@jsmucr

@jsmucr jsmucr commented Dec 31, 2021 •

Copy link
Copy Markdown

Description

Creating a new Context now clones the Options passed to it so that these options can be changed later in the process without changing anything globally.

This makes it possible to set for example ssl_insecure for each request individually from within the tls_start_server hook.

from mitmproxy import ctx

def tls_start_server(data: any):
    address = data.context.server.address[0] + ":" + str(data.context.server.address[1])
    if address == 'as2.pipechain.com:10443':
        data.context.options.ssl_insecure = True
    ctx.log.info("ssl_insecure[" + address + "] => " + str(data.context.options.ssl_insecure))

Checklist

  • I have updated tests where applicable.
  • I have added an entry to the CHANGELOG.

@jsmucr jsmucr changed the title Fix #5019 - enable Feature #5019 - allow context configuration changes in tls_* hooks Dec 31, 2021
@mhils

mhils commented Jan 3, 2022

Copy link
Copy Markdown
Member

Thanks for the PR! The changes look good and you put in effort to update the changelog and tests, which is great. I really do appreciate it. Unfortunately I'm strongly -1 on the architectural changes here. mitmproxy has one global options object shared by all addons and the core. Introducing multiple option states makes it harder to reason about the code and will lead to unpredictable side effects long term. So this is a hard pass - sorry. I'm more than happy to discuss other ways how we can implement certificate verification overrides, let's continue the discussion in #5019.

@mhils mhils closed this Jan 3, 2022
@jsmucr

jsmucr commented Jan 3, 2022

Copy link
Copy Markdown
Author

No problem @mhils. :-) Thank you for reviewing the PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants