proxy.py: `FileNotFoundError` while using TLS Interception

Describe the bug Got this error when using TLS interception:

handler.handle_readables:234 - Exception when receiving from client connection#24 with reason FileNotFoundError(2, 'No such file or directory')

To Reproduce With ca files generated by make ca-certificates and signed by make sign-https-certificates, I got three files:

  • https-cert.pem
  • https-key.pem
  • https-csr.pem

then using nested python code to start proxy.py:

main(
    hostname=hostname, 
    ca_cert_file="/Users/doge/desktop/https-cert.pem", 
    ca_key_file="/Users/doge/desktop/https-key.pem", 
    ca_signing_key_file="/Users/doge/desktop/https-csr.pem",
    plugins=[ModifyLBXLocationPlugin], 
    local_executor=False,
)

I’m pretty sure these CA files are exists, but got the exception above and no connection could pass proxy. Using relative path not helps.

Version information

  • OS: macOS 12.2.1
  • proxy.py Version: 2.4.0

Additional context Thanks for your working 😃!

About this issue

  • Original URL
  • State: open
  • Created 5 years ago
  • Comments: 15 (5 by maintainers)

Most upvoted comments

Same issue here: When I do curl -v --cacert ca-cert.pem -x 127.0.0.1:8899 https://httpbin.org/get, first I see Proxy CONNECT aborted. I did pip install certifi in the container, the error changed to OpenSSL SSL_connect: SSL_ERROR_SYSCALL in connection to httpbin.org:443. In the container log there are exceptions that says FileNotFoundError: [Errno 2] No such file or directory: 'openssl'. Then I find openssl doesn’t seem to be installed at all in the container: sh: openssl: not found. According to the doc it looks like the abhinavsingh/proxy.py:latest should come with openssl… And I don’t know how to install it without apt in the container… Did I miss something?

I somehow worked around this issue by explicitly passing in --ca-file /etc/ssl/certs/ca-certificates.crt. Seems like the default path doesn’t exist and causes an error. I’m running the proxy.py on raspberry pi os (buster) btw.

On Raspberry PI, I set --ca-file /etc/ssl/certs/ca-certificates.crt to point to the exiting trusted certificate store. This seems to help with this. proxy.py’s default does not cut it it seems on this platform.

With the curl example, make sure to point to a valid certificate (or pass -k to go untrusted ok mode)

Hi @abhinavsingh, @guiqiqi

I was facing the same issues until realized from @abhinavsingh’s comment that certifi wasn’t installed in my virtualenv (I’m running Python 3.9.12). Installed with:

$ mkvirtualenv proxy.py --python python3.9

$ pip install proxy.py --pre --upgrade
Collecting proxy.py
  Using cached proxy.py-2.4.1-py3-none-any.whl (204 kB)
Installing collected packages: proxy.py
Successfully installed proxy.py-2.4.1

$ pip freeze
proxy.py==2.4.1

After installing certifi I got it working without explicitly setting --ca-file parameter.

$ pip install certifi