electronicsguy / ESP8266

ESP8266 Projects
242 stars 183 forks source link

HTTPSRedirect: Unable to retrieve Google App Scripts / invalid SSL record after redirect #62

Closed botboe closed 6 years ago

botboe commented 6 years ago

I'm trying to access a Google Apps Script via the HTTPSRedirect-functions from an ESP32-devboard. I use the functions shown in the example file, so there shouldn't be the problem.

The first step works well:

WiFi connected
IP address: 
192.168.xyz.103
Connecting to script.google.com
[V][ssl_client.cpp:52] start_ssl_client(): Free heap before TLS 152552
[V][ssl_client.cpp:54] start_ssl_client(): Starting socket
[V][ssl_client.cpp:90] start_ssl_client(): Seeding the random number generator
[V][ssl_client.cpp:99] start_ssl_client(): Setting up the SSL/TLS structure...
[I][ssl_client.cpp:123] start_ssl_client(): WARNING: Use certificates for a more secure communication!
[V][ssl_client.cpp:147] start_ssl_client(): Setting hostname for TLS session...
[V][ssl_client.cpp:162] start_ssl_client(): Performing the SSL/TLS handshake...
[V][ssl_client.cpp:181] start_ssl_client(): Verifying peer X.509 certificate...
[V][ssl_client.cpp:190] start_ssl_client(): Certificate verified.
[V][ssl_client.cpp:205] start_ssl_client(): Free heap after TLS 109444
Connected!
GET /macros/s/JKaksz762j[...]/exec HTTP/1.1
Host: script.google.com
User-Agent: ESP8266

[V][ssl_client.cpp:244] send_ssl_data(): Writing HTTP request...
Status code: 302
Reason phrase: Moved Temporarily
_redirHost: script.googleusercontent.com
_redirUrl: /macros/echo?user_content_key=4ahZa[...]&lib=MqdDz[...]

But the connection to the redirected target fails and the whole application hangs:

[V][ssl_client.cpp:52] start_ssl_client(): Free heap before TLS 105140
[V][ssl_client.cpp:54] start_ssl_client(): Starting socket
[V][ssl_client.cpp:90] start_ssl_client(): Seeding the random number generator
[V][ssl_client.cpp:99] start_ssl_client(): Setting up the SSL/TLS structure...
[I][ssl_client.cpp:123] start_ssl_client(): WARNING: Use certificates for a more secure communication!
[V][ssl_client.cpp:147] start_ssl_client(): Setting hostname for TLS session...
[V][ssl_client.cpp:162] start_ssl_client(): Performing the SSL/TLS handshake...
[V][ssl_client.cpp:181] start_ssl_client(): Verifying peer X.509 certificate...
[V][ssl_client.cpp:190] start_ssl_client(): Certificate verified.
[V][ssl_client.cpp:205] start_ssl_client(): Free heap after TLS 68504
GET /macros/echo?user_content_key=4ahZa[...]&lib=MqdDz[...] HTTP/1.1
Host: script.googleusercontent.com
User-Agent: ESP8266

[V][ssl_client.cpp:244] send_ssl_data(): Writing HTTP request...
[E][ssl_client.cpp:32] handle_error(): SSL - An invalid SSL record was received
[E][ssl_client.cpp:34] handle_error(): MbedTLS message code: -29184
[V][ssl_client.cpp:213] stop_ssl_socket(): Cleaning SSL connection.
[V][ssl_client.cpp:213] stop_ssl_socket(): Cleaning SSL connection.

Is this a general problem, or am I the only one with this behavior?

electronicsguy commented 6 years ago

ESP32 still has problems with the SSL side of things. Work in progress...