Skip to content
This repository has been archived by the owner on May 10, 2024. It is now read-only.

Fixes #3561 - Python 3 proxy ssl connection issue #3699

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from

Conversation

colin-nolan
Copy link

Pull request to finally get the changes in #2718 merged into boto.

Alternative to pull requests #2718, #3695.

Fixes #3561; closes #3695.

@utilitynerd
Copy link

Having this PR merged would be very helpful for me and anyone else trying to run boto on python 3 with an http(s) proxy.

xiaket and others added 2 commits May 19, 2017 09:06
@chris-goffinet-ck
Copy link

I'm blocked on this, can someone please merge this change?

@ps-jay
Copy link
Contributor

ps-jay commented Oct 8, 2018

Hi @jamesls, @dstufft, (you two look most active of the boto project team members ...)

I understand boto is no longer the recommended way forward, but it is still used by projects such as Ansible.

Could you have a look at this PR, and see if it could be merged. boto isn't yet 'dead' according to the README.

This PR addresses an issue using proxies (as usual in enterprise customers) with boto in Python3. In particular, effecting s3 and route53.

Thanks and regards,
Phil

@JGalego
Copy link

JGalego commented Jul 4, 2019

When will this fix be merged?

@codingkrabbe
Copy link

When will this fix be merged?

Yes, merge would be really nice, as ec2.py is only working on my end with this fix with python 3.7

@piyushwadhwani
Copy link

please merge this , this is pending from couple of years now.

@derekmccallum
Copy link

+1 - yes, please merge

@scottgarcia11
Copy link

+1, please merge

@JGalego
Copy link

JGalego commented Nov 8, 2019

All checks have passed and this fix works locally. Why is this still open?

elad4251 added a commit to elad4251/boto that referenced this pull request Jan 13, 2020
@blogumi
Copy link

blogumi commented Jan 13, 2020

Please merge!

rgayon added a commit to google/GiftStick that referenced this pull request Jan 20, 2020
* fix some string conversion errors in the python script
* force installation of python3 packages
* Apply boto/boto#3699 manually to make the boto lib work with Py3 version of http lib
@varun1231
Copy link

When will this be merged??

@colin-nolan
Copy link
Author

@varun1231 given that it's been nearly 3 years since I made this PR, it seems unlikely that it will happen any time soon! Also, as there's been no activity on this repository for almost a year, I think it's fair to say this is abandonware and should be avoided.

@Venky7869
Copy link

When will this be merged ?
@colin-nolan Is there any other way we can fix this issue ?

@rohanpower
Copy link

rohanpower commented Feb 12, 2020

When will this be merged ?
@colin-nolan Is there any other way we can fix this issue ?

Not ideal, but I'm working around the issue until it's merged:
pip3 install git+https://github.com/boto/boto.git@refs/pull/3699/merge

@rob-weiss
Copy link

When will this be merged ?
@colin-nolan Is there any other way we can fix this issue ?

Not ideal, but I'm working around the issue until it's merged:
pip3 install git+https://github.com/boto/boto.git@refs/pull/3699/merge

This doesn't seem to work for me. I get the following warning, while the error persists:

 Running command git clone -q https://github.com/boto/boto.git 'C:\Users\WRI2lR\AppData\Local\Temp\pip-req-build-6zyamwf5'
  WARNING: Did not find branch or tag 'refs/pull/3699/merge', assuming revision or ref.
  Running command git fetch -q https://github.com/boto/boto.git refs/pull/3699/merge
  Running command git checkout -q 93ca4aaba3c9032cd582a6407ade7d92961e499b
Requirement already satisfied (use --upgrade to upgrade): boto==2.49.0 from git+https://github.com/boto/boto.git@refs/pull/3699/merge in c:\users\wri2lr\.conda\envs\cactus\lib\site-packages
Building wheels for collected packages: boto
  Building wheel for boto (setup.py) ... done
  Created wheel for boto: filename=boto-2.49.0-py2.py3-none-any.whl size=1371394 sha256=7dcb8d5d86e21290e1496a10aae88aa7205873855796d8c97599e8ea562ef25a
  Stored in directory: C:\Users\WRI2lR\AppData\Local\Temp\pip-ephem-wheel-cache-3a_q7i5z\wheels\6a\cb\75\f72788dfcfe9c516cd9c43dfe04b3b0a9541317b4a449105de
Successfully built boto

# See discussion about this config option at
# https://groups.google.com/forum/?fromgroups#!topic/boto-dev/teenFvOq2Cc
if config.getbool('Boto', 'send_crlf_after_proxy_auth_headers', False):
sock.sendall("\r\n")
sock.sendall(("\r\n").encode())
Copy link

Choose a reason for hiding this comment

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

no need for .encode() ... just use b'\r\n' directly

else:
sock.sendall("\r\n")
resp = http_client.HTTPResponse(sock, strict=True, debuglevel=self.debug)
sock.sendall(("\r\n").encode())
Copy link

Choose a reason for hiding this comment

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

same here -- use b'\r\n' instead

sock.sendall("\r\n")
resp = http_client.HTTPResponse(sock, strict=True, debuglevel=self.debug)
sock.sendall(("\r\n").encode())
kwargs = {'sock': sock, 'debuglevel': self.debug}
Copy link

@vapier vapier May 4, 2020

Choose a reason for hiding this comment

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

sock is not a kwarg (i know Python treats it as one, but imo it's bad form to do so for required params), and debuglevel is in both versions. so seems like it'd be more straightforward to only make the backwards compat logic optional.

kwargs = {}
if six.PY2:
  kwargs['strict'] = True
resp = http_client.HTTPResponse(sock, debuglevel=self.debug, **kwargs)

@taylor-nguyen
Copy link

@colin-nolan when is this being merged? We have a similar issue

@colin-nolan
Copy link
Author

@taylor-nguyen I am not a maintainer of this project so I can't tell you. However, given that this PR hasn't been merged in over 3 years, I doubt that it's ever going to be!

@vapier
Copy link

vapier commented Aug 9, 2020

you probably want to look at https://github.com/boto/boto3 instead for Python 3 support

@johnboy2
Copy link

When will this be merged ?
@colin-nolan Is there any other way we can fix this issue ?

Not ideal, but I'm working around the issue until it's merged:
pip3 install git+https://github.com/boto/boto.git@refs/pull/3699/merge

This doesn't seem to work for me. I get the following warning, while the error persists:
...

This worked for me (i.e. referencing the PR source branch directly, rather then the PR itself):

pip3 install git+https://github.com/wtsi-hgi/boto@fix/3561-py3-proxy-ssl-connection

@taylor-nguyen
Copy link

The problem is we use Ansible and it still relies on boto. @colin-nolan are you able to address review comments to get it merged? Having these changes in would greatly benefit anyone instead of applying this branch directly

@@ -793,18 +793,21 @@ def proxy_ssl(self, host=None, port=None):
else:
sock = socket.create_connection((self.proxy, int(self.proxy_port)))
boto.log.debug("Proxy connection: CONNECT %s HTTP/1.0\r\n", host)
sock.sendall("CONNECT %s HTTP/1.0\r\n" % host)
sock.sendall("User-Agent: %s\r\n" % UserAgent)
sock.sendall(("CONNECT %s HTTP/1.0\r\n" % host).encode())
Copy link

@seanpd seanpd Sep 10, 2020

Choose a reason for hiding this comment

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

You might want to explicitly say encode("UTF-8")
That's the default under py3, but py2 it depends on sys.getdefaultencoding().
It's likely ok the way it is, but it provides consistency.
Ditto for the other places encode() is used.

Choose a reason for hiding this comment

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

Strictly speaking, non-ASCII hostnames should be "idna"-encoded, rather than UTF-8 or a system's default, as IDNA is the standard for internationalized domain names.

@devimk
Copy link

devimk commented Nov 25, 2020

We still use boto and I believe its on the latest , how do we patch it with this ?

@t-readyroc
Copy link

Please merge this branch. The community.aws.route53 module is unusable on python 3.6.8 without the patch included in this branch. I was originally using boto 2.49.0, but found this thread from here. I used the following to install this branch:

pip install git+https://github.com/wtsi-hgi/boto@fix/3561-py3-proxy-ssl-connection

I'm now on boto 2.46.1, and the community.aws.route53 module works, but obviously, this should only be a temporary workaround.

@seanpd
Copy link

seanpd commented Dec 2, 2020

Seconding other comments here. I think we should merge. There has been good discussion and some code changes aren't "perfect" but right now it's broken on py3. Some people are still on boto2. I've had to monkeypatch this issue for production code.

@jralmaraz
Copy link

It would be great to get this merged, it causes so much trouble for us atm :(

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Boto S3 throws type error in production environment