Hello,
I am working on a weather app for the Wio Terminal and I would like to get data from NOAA using the domain api.weather.gov, and Open Weather Map using the domain api.openweathermap.org. Both sites require SSL connections. However, while I am able to get this to work with api.openweathermap.org, it is not working for api.weather.gov. While the connect() call returns successfully, any further IO fails. It appears the socket closes prematurely.
While trying to track down this problem, I wrote a simple test program that connects to www.example.com 1, api.openweathermap.org, api.weather.gov, and www.howsmyssl.com, using WiFiClientSecure and performs a simple GET after connected. The first two work fine. The third (api.weather.gov) fails as mentioned above where the connect succeeds but further I/O fails. The fourth (www.howsmyssl.com) never connects at all and times out. So only two out of four sites work.
Note you will need to change the SSID and Wifi Password to run it.
Below is a sample run. Note the first two sites work, the third “connects” but has a file descriptor of -1, so nothing else works after that, and the third simply times out.
Attempting to connect to SSID: <omitted>
Connected to <omitted>
Starting connection to www.example.com
Connected to server!
File descriptor: 0
Sending GET request
Wrote request, wn=60
Reading response...
Headers received
Read 1256 bytes.
Stopping WiFiClientSecure connection...
Starting connection to api.openweathermap.org
Connected to server!
File descriptor: 0
Sending GET request
Wrote request, wn=72
Reading response...
Headers received
Read 107 bytes.
Stopping WiFiClientSecure connection...
Starting connection to api.weather.gov
Connected to server!
File descriptor: -1
Sending GET request
Wrote request, wn=0
fd=-1, errno=88
Stopping WiFiClientSecure connection...
Starting connection to www.howsmyssl.com
LastError: SSL - The connection indicated an EOF
Connection failed!
All sites processed.
I am running 2.1.1 firmware, and downloaded fresh copies of rpcWifi (master), rpcUnified (master), and mbedtls (dev) on 2/14/2021 (yesterday). Any help would be appreciated.
Thank you for looking into this. I was able to replicate your results and connect to api.weather.gov!
I guess I botched the certificate. Instead of using openssl, I used the Chrome menus to save it. One area of confusion for me is that Chrome shows two parent certificates, the intermediate and the CA root. So I guess you’re using the intermediate…
Regarding www.howsmyssl.com, I wonder if it’s using something other than RSA for such a short key?
Hello,
I tested your code and cannot confirm your bad observations.
With the three working urls your sketch is now running for a some minutes flawlessly.
For www.howsmyssl.com wireshark reveals an ssl handshake failure, see picture.
It’s strange, that on wireshark I cannot even see a DNS request for this url.
Are you sure, that you have the latest firmware for the Wio Terminal installed?
There are some posts in the forum how to install the actual firmware in the Arduino IDE.
framework-arduino-samd-seeed@https://github.com/Seeed-Studio/ArduinoCore-samd.git#v1.8.1
However, I also saw occasional hangs and stopping of performing http post requests.
I would be happy if the cause of this were in my App, but I suspect that the reason lies in the Seeed libraries.
Yes, you’re right, with the updated certificate for api.weather.gov, three out of four sites in my test program are working. So my weather project I’m in good shape, I think.
Nevertheless it is a mystery as to why www.howsmyssl.com is not working. And I’m fairly confident I’m running the latest code. I went through the procedure to update on 2/14, with 2.1.1, and I made sure I had the latest on the other libraries as well the same day. Given your message it seems you were able to reproduce the problem with www.howsmyssl.com, so I doubt the problem is with my firmware. Is there a way to ask the firmware/library what version it is? That would be nice so we could verify at runtime the version.
Your wireshark log is revealing. While there was no DNS lookup, the right IP address is being used. Also, it seems the site disconnects as soon as the Wio Terminal sends the first “Client Hello” message. Perhaps this indicates the server does not like the TLS version and/or cipher suites advertised by the Wio Terminal? Just a theory.