0

From the command line, I am able to successfully execute a command as follows:

curl --cacert <cacert> --cert <cert> --connect-to ::1.2.3.4: https://some-identity.com:443/endpoint

I am doing this so the request ends up going to the 1.2.3.4 address (from the routing perspective), but all of the SSL handshake occurs using the some-identity.com address. I have to do this because unfortunately, the SSL certificates in use are being signed using the some-identity.com address, but the private IP of the server is 1.2.3.4.

I am trying to use either aiohttp (preferably), or requests, but I cannot find the respective utilities to do this.

In aiohttp, I see that I can pass in an SSLContext (in the ssl package) object, but unfortunately, I can't seem to find any property within an SSLContext object that can be set dynamically.

For the requests library, it doesn't seem to have an option for me to override/change the host as I did using curl.

Is there another way to go about this through Python libraries? The last ditch option would be to simply use the curl command itself through Python, but that is not preferred.

stoneman_41
  • 370
  • 2
  • 12
  • 1
    portal https://curl.trillworks.com/ can convert `curl` to (more or less correct) `requests`. Maybe it can convert your `curl` too. – furas Sep 18 '19 at 22:34
  • 2
    Possible duplicate of [Python 'requests' library - define specific DNS?](https://stackoverflow.com/questions/22609385/python-requests-library-define-specific-dns) – Anon Coward Sep 18 '19 at 22:35

0 Answers0