How to avoid SSL issues when using proxpy?

I am trying to use proxpy to monitor any requests made during the python-selenium test. The Python code I use is as follows:

from selenium import webdriver
PROXY = "0.0.0.0:9999"
webdriver.DesiredCapabilities.FIREFOX['proxy'] = {
    "httpProxy":PROXY,
    "ftpProxy":PROXY,
    "sslProxy":PROXY,
    "proxyType":"MANUAL"
}
driver = webdriver.Firefox()
driver.get("http://www.google.co.in")
driver.quit()

and I start the proxy as follows:

python proxpy/proxpy/proxpy.py -p 9999

When I run the python script test, I get the following error:

Exception happened during processing of request from ('127.0.0.1', 64667)
Traceback (most recent call last):
  File "/Users/adietz/anaconda/lib/python2.7/SocketServer.py", line 596, in process_request_thread
    self.finish_request(request, client_address)
  File "/Users/adietz/anaconda/lib/python2.7/SocketServer.py", line 331, in finish_request
    self.RequestHandlerClass(request, client_address, self)
  File "/Users/adietz/Projects/Invest/browsermob/proxpy/proxpy/core.py", line 56, in __init__
    SocketServer.StreamRequestHandler.__init__(self, request, client_address, server)
  File "/Users/adietz/anaconda/lib/python2.7/SocketServer.py", line 652, in __init__
    self.handle()
  File "/Users/adietz/Projects/Invest/browsermob/proxpy/proxpy/core.py", line 137, in handle
    res = self.doCONNECT(host, port, req)
  File "/Users/adietz/Projects/Invest/browsermob/proxpy/proxpy/core.py", line 188, in doCONNECT
    ssl_version = ssl.PROTOCOL_SSLv23, do_handshake_on_connect = False)
  File "/Users/adietz/anaconda/lib/python2.7/ssl.py", line 933, in wrap_socket
    ciphers=ciphers)
  File "/Users/adietz/anaconda/lib/python2.7/ssl.py", line 544, in __init__
    self._context.load_cert_chain(certfile, keyfile)
IOError: [Errno 2] No such file or directory

How can i fix this? How can I avoid this error? How can I just keep track of requests and responses ...?

On a Linux machine, the error is equivalent to:

Exception happened during processing of request from ('127.0.0.1', 35348)
Traceback (most recent call last):
  File "/usr/lib/python2.7/SocketServer.py", line 596, in process_request_thread
    self.finish_request(request, client_address)
  File "/usr/lib/python2.7/SocketServer.py", line 331, in finish_request
    self.RequestHandlerClass(request, client_address, self)
  File "/home/adietz/Projects/Invest/browsermob-proxy/proxpy/proxpy/core.py", line 56, in __init__
    SocketServer.StreamRequestHandler.__init__(self, request, client_address, server)
  File "/usr/lib/python2.7/SocketServer.py", line 652, in __init__
    self.handle()
  File "/home/adietz/Projects/Invest/browsermob-proxy/proxpy/proxpy/core.py", line 137, in handle
    res = self.doCONNECT(host, port, req)
  File "/home/adietz/Projects/Invest/browsermob-proxy/proxpy/proxpy/core.py", line 188, in doCONNECT
    ssl_version = ssl.PROTOCOL_SSLv23, do_handshake_on_connect = False)
  File "/usr/lib/python2.7/ssl.py", line 933, in wrap_socket
    ciphers=ciphers)
  File "/usr/lib/python2.7/ssl.py", line 544, in __init__
    self._context.load_cert_chain(certfile, keyfile)
IOError: [Errno 2] No such file or directory
+6
source share
4 answers

proxpy. Github, . , Browsermob, . python, Selenium: https://github.com/AutomatedTester/browsermob-proxy-py

+1

proxpy, , https-.

- HTTP-, mitmproxy - .

+1

pproxy .

@Alex . , .

, .

core.py init ProxyHandler

self.peer = False

self.peer = True

, , pem . certs. {{ , .}}. @Homewrecker.

:

peer false. , httpConnection , .

This screenshot may help you get to the code.

0

http proxy packages Cheese Shop. - , .

Python, pyproxy, :

$ pyproxy --port=8888 --log-to-stderr
[I 180124 13:28:59 pyproxy:242] http server started on 127.0.0.1:8888
[I 180124 13:28:59 pyproxy:242] http server started on 127.0.0.1:8888
[I 180124 13:30:11 web:2064] 200 CONNECT www.google.co.in:443 (127.0.0.1) 223.28ms
[I 180124 13:30:11 web:2064] 200 CONNECT www.google.co.in:443 (127.0.0.1) 223.28ms

:

curl -v --proxy http://localhost:8888 https://www.google.co.in/

Also as mentioned in @georgexsh, you can use mitmproxy . Note that it has a web interface, mitmweb , which looks like this:

mitmweb

0
source

All Articles