Skip to content

Conversation

@JerryKwan
Copy link
Contributor

@JerryKwan JerryKwan commented Dec 13, 2021

Here is how to try HTTPS connection pooling. Currently only available when TLS Interception is enabled and within a single worker (no multiprocessing support yet)

You can use the following commands to do some tests:

Generate required certificates

make ca-certificates

Start proxy with TLS Interception enabled & with connection pool

python3.7 -m proxy \
--ca-key-file ca-key.pem \
--ca-cert-file ca-cert.pem \
--ca-signing-key-file ca-signing-key.pem \
--num-workers 1 \
--log-level DEBUG \
--enable-conn-pool \
--log-format "%(asctime)s - pid:%(process)d [%(levelname)-.1s] %(pathname)s.%(funcName)s:%(lineno)d - %(message)s"

Client

curl -v -x localhost:8899 --cacert ca-cert.pem https://httpbin.org/get

Copy link
Owner

@abhinavsingh abhinavsingh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for this PR and work on https connection pool. This not only help with within TLS interception mode but also at every place where proxy.py or plugins needs to establish a HTTPS connection upstream.

I'll run it locally and also try to dig into multiprocessing aspects. But we should be able to merge this in as-in (with green CI :)) and need not wait for multiprocessing support to land within this PR.

I'll update back with my findings. Meanwhile try to address these lint warnings. I know they might seem annoying but are necessary and sometimes might even help you find bugs in the code. PTAL at https://github.com/abhinavsingh/proxy.py/runs/4504222230?check_suite_focus=true

@abhinavsingh abhinavsingh changed the title Solve the problem of https requests work with connection pool [ConnectionPool] Add support for HTTPS request pooling Dec 13, 2021
@abhinavsingh

This comment has been minimized.

@abhinavsingh
Copy link
Owner

@JerryKwan Can you check in the tls_server_hello.data file too. Thank you

Copy link
Owner

@abhinavsingh abhinavsingh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PTAL. Also add the missing tls_server_hello.data file. Thank you

@abhinavsingh
Copy link
Owner

I made several changes related to list here JerryKwan#4. Please take a look and merge into your merge, which in-turn will update this PR.

You will have to additionally address the comments I left before PR will become merge ready (green CI). Let me know if you run into any issues. Thank you.

@codecov
Copy link

codecov bot commented Dec 18, 2021

Codecov Report

Merging #865 (fe8fec6) into develop (32fb729) will increase coverage by 0.05%.
The diff coverage is n/a.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop     #865      +/-   ##
===========================================
+ Coverage    86.90%   86.96%   +0.05%     
===========================================
  Files          130      130              
  Lines         5843     5845       +2     
  Branches       586      586              
===========================================
+ Hits          5078     5083       +5     
+ Misses         656      652       -4     
- Partials       109      110       +1     
Flag Coverage Δ
pytest 86.80% <ø> (+0.05%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
proxy/core/connection/pool.py 96.77% <ø> (ø)
proxy/http/handler.py 71.49% <0.00%> (-0.91%) ⬇️
proxy/plugin/proxy_pool.py 32.60% <0.00%> (+0.69%) ⬆️
proxy/http/exception/proxy_conn_failed.py 88.23% <0.00%> (+0.73%) ⬆️
proxy/http/server/web.py 64.15% <0.00%> (+0.79%) ⬆️
proxy/plugin/reverse_proxy.py 46.66% <0.00%> (+1.01%) ⬆️
proxy/http/exception/http_request_rejected.py 88.88% <0.00%> (+1.38%) ⬆️
proxy/http/exception/proxy_auth_failed.py 85.71% <0.00%> (+2.38%) ⬆️
proxy/http/exception/base.py 75.00% <0.00%> (+8.33%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 32fb729...fe8fec6. Read the comment docs.

@abhinavsingh abhinavsingh added the bot:chronographer:skip PR using this label is exempted from CHANGELOG management label Dec 18, 2021
@abhinavsingh

This comment has been minimized.

@JerryKwan

This comment has been minimized.

@abhinavsingh

This comment has been minimized.

@JerryKwan

This comment has been minimized.

@abhinavsingh

This comment has been minimized.

remove unnecessary tls parser and related tests
fix spell check warnings
@abhinavsingh
Copy link
Owner

@JerryKwan Awesome looks like all has been resolved. Docker problems are due to permission issues. I'll take another look later today and merge if all looks good. Thank you!!!

@JerryKwan
Copy link
Contributor Author

JerryKwan commented Dec 22, 2021 via email

@abhinavsingh abhinavsingh linked an issue Dec 29, 2021 that may be closed by this pull request
@abhinavsingh
Copy link
Owner

Closing this for now as we separately merged only the base TlsParser skeleton in #922 . Next we still need to cache the SSL session to successfully implement HTTPS connection resumptions. See discussion in #748 for more details.

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

Labels

bot:chronographer:skip PR using this label is exempted from CHANGELOG management

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[ConnectionPool] Add support for https session cache

2 participants