-
-
Notifications
You must be signed in to change notification settings - Fork 9.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
With SSL connection: TypeError: data must be a memoryview, buffer or byte string #3824
Comments
Yes, almost certainly you're sending a unicode string in your |
What the app is sending as a Unless the "data" in the context of SSL.py also includes the HTTP headers I'm providing to "requests". So I checked all my headers value and name with the following code:
And running this code seems to prove that everything is properly ASCII encoded. The point is, the exact same app worked fine just a few days before, I made stricly no changes to my code but in the meantime I installed Impacket which probably comes with a bunch of python libs install/update which I'm suspecting causes the issue since this is the only thing I can see may have changed... |
@Arno0x To be clear, the appearance of the problem was caused by you installing PyOpenSSL. This is because we preferentially use PyOpenSSL if it's available, but PyOpenSSL is very strict about the data that is handed to it. The fact that you can safely call |
@Lukasa thank you so much for helping me on this issue. If I get it right (provided I'm using Python2): all strings in my code are of type 'str' by default and I guess that's what you call native string (is it?). So it looks like all my headers (name or value) are already native python string. Still, just in case, I tried to change my code to add So I've reduced my testing scenario down to the basic following test in python command line:
So it turns out not to be a header issue, but rather the data itself returned from my
I hope you'll get to see what's wrong in this piece of code that PyOpenSSL doesn't like... thanks again for your help. |
So it looks like PyOpenSSL doesn't accept bytearrays: only buffers or bytes. You can work around this in the short term by calling However, I'd call this a PyOpenSSL bug: there's no reason not to accept bytearrays here. So I recommend opening a bug report on the PyOpenSSL repository as well. =) |
SPOTTED ! :-) Thank you so much for your help. I'll certainly open an issue on the PyOpenSSL as well. Cheers. |
No problem. =) |
Hi,
I'm having an exception with my program, probably because of an update in one of the python libs recently, but I don't know how to figure this out.
OS: Linux kali 4.6.0-kali1-amd64 #1 SMP Debian 4.6.4-1kali1 (2016-07-21) x86_64 GNU/Linux
Python: 2.7.13
Requests version:
Traceback:
Other info: The same exact version of my program (pulled from my git repo) works on MacOSX and on Alpine Linux (Docker image).
Any idea what the issue is ?
Thanks,
Arno
The exact
The text was updated successfully, but these errors were encountered: