WiFi TinyShield SSL/HTTPS - Unable to get response from HTTPS request

s0meguy

  • Newbie
  • *
    • Posts: 2
    • View Profile
HI, I am trying to create a HTTPS POST request to make an API call to the Sensibo API.

I can't seem to get any response from the server.
I tried changing the code to client.connectSSL(server, 443), but did not get any response.

I tried to use the default and the modified Firmware Updater tool from http://forum.tinycircuits.com/index.php?topic=1969.msg4061#msg4061, to update the SSL root certificates for connectSSL() but both tools did not work.
Both Firmware Updater showed the "Programmer not responding" error.

Help is much appreciated.

connect() function:
Code: [Select]
char server[] = "home.sensibo.com";

SerialUSB.println("\nStarting connection to server...");
  // if you get a connection, report back via SerialUSB:
  if (client.connect(server, 80)) {
    SerialUSB.println("connected to server");
    // Make a HTTP request:
    client.println("POST /api/v2/pods HTTP/1.1");
    client.println("Host: home.sensibo.com");
    client.println("Connection: close");
    client.println();
  }

The connect() function returns this response this:
Code: [Select]
HTTP/1.1 301 Moved Permanently
Content-Type: text/html
Date: Fri, 12 Nov 2021 16:49:22 GMT
Location: https://home.sensibo.com/api/v2/pods
Server: nginx
Strict-Transport-Security: max-age=63072000
Content-Length: 162
Connection: Close

<html>
<head><title>301 Moved Permanently</title></head>
<body>
<center><h1>301 Moved Permanently</h1></center>
<hr><center>nginx</center>
</body>
</html>


lennevia

  • Administrator
  • Hero Member
  • *****
    • Posts: 437
    • View Profile
Hello,

Did you set the wifi pins in the sensibo example? This line should always be in your setup loop when using our Wifi TinyShield:
WiFi.setPins(8,2,A3,-1);


It may help to go back to basics and get a simple WiFi connection working before adding the Sensibo API into the program. Try our getting-started example here: https://learn.tinycircuits.com/Communication/WiFi_TinyShield_Tutorial/

Let me know how that goes!

Best,
RĂ©na


s0meguy

  • Newbie
  • *
    • Posts: 2
    • View Profile
I have set the WiFi pins accordingly.

The API calls are for IoT devices in my network.
So far, I am able to make API calls using the connect() function with HTTP (not HTTPS) requests, to a Philips Hue Bridge and a WeMo smart switch, with the difference of both being accessed via a local IP address and the Sensibo API being accessed via a public IP address, hence HTTPS.

I am able to get HTTP responses using the WiFiWebClient.ino example, albeit getting the HTTP response status code 301 Moved Permanently.

For the 301 code, I believe I require SSL for the connection.
However in the WiFiSSLClient.ino example or using the connectSSL() function, even with the default "www.google.com" , there is no HTTP response output in the SerialMonitor.

All of which outputs:
Code: [Select]
Starting connection to server...

disconnecting from server.

Is it due to the SSL certificates not uploaded?
And if so, is it possible to assist me by providing a step-by-step method to perform the Firmware Update to upload to SSL certificates?


Edit: I managed to upload the SSL certs to my TinyZero, however, there is still no output.

Edit: I have resolved my issue, the issue was that in the FirmwareUpdater.ino, SerialUSB is required instead of Serial.  Then uploading the SSL certs went without a problem.

Thank you! :D
« Last Edit: November 13, 2021, 12:11:53 AM by s0meguy »


 

SMF spam blocked by CleanTalk