0

My use case is to login to webapp and then hit internal network call and parse response to validate using Python 3.9

Sudo code : login to web app. : Used selenium webdriver to login. hit internal endpt using urllib, this needs login credential hence I have used

    password_mgr = urllib.request.HTTPPasswordMgrWithDefaultRealm()

    # Add the username and password.
    # If we knew the realm, we could use it instead of None.
    top_level_url = url
    password_mgr.add_password(None, top_level_url, username, password)

    handler = urllib.request.HTTPBasicAuthHandler(password_mgr)

    # create "opener" (OpenerDirector instance)
    opener = urllib.request.build_opener(handler)

    # use the opener to fetch a URL
    opener.open(api_endpt)

    # Install the opener.
    # Now all calls to urllib.request.urlopen use our opener.
    response = urllib.request.install_opener(opener)
    print(response)```


***but call fails at opener.open(api_endpt) step with :*** 
** @_sslcopydoc
    def do_handshake(self, block=False):
        self._check_connected()
        timeout = self.gettimeout()
        try:
            if timeout == 0.0 and block:
                self.settimeout(None)
>           self._sslobj.do_handshake()
E           ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate in certificate chain (_ssl.c:1129)

/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/ssl.py:1309: SSLCertVerificationError

During handling of the above exception, another exception occurred:**


Any further direction to parse response would be appreciated. 
Janny
  • 21
  • 4

0 Answers0