4

The client makes a GET request on some websites, like https://www.youtube.com. This request is redirected to my proxy server, which gets all of the data. Then i try to decode('UTF-8') it, but i get error

UnicodeDecodeError: 'utf-8' codec can't decode byte 0xfc in position 8: invalid start byte

I suppose this is because of SSL/TLS encryption? But then there is a question ---> How do I catch an SSL/TLS key using python sockets?

Vicks Loma
  • 28
  • 6

1 Answers1

1

This error is because there are non-ASCII characters and that can't be encoded or decoded. There is one way to avoid this is to use the encode() function. Let your string is x

x.encode('utf-8').strip()
Anandesh Sharma
  • 436
  • 6
  • 22
Vicks Loma
  • 28
  • 6
  • I suppose this is an answer to error that i got, but still not clear on - how do i make this "non-ASCII" into a real request string that was sent from client? I need to catch SSL/TLS key to decrypt what i got ---- and so, here is the question, how do i catch ssl/tls keys to decrypt what client sends me? – BaronRandom May 16 '21 at 13:10
  • @BaronRandom You are better off wrapping the socket, and allowing the built-in Python functions to take care of SSL/TLS for you. See [here](https://docs.python.org/3/library/ssl.html#ssl.SSLContext.wrap_socket). – felipe May 30 '21 at 22:15