I'm seeing the simulator return responseCode=0 for SSL requests that involve a Let's Encrypt SSL Certificate.
Comodo certs (which I used to use) seem to work fine as does a 'naked', non-SSL request.
This is occurring on a Mac / Mojave running CIQ 3.0.11.
The following test case demonstrates the issue:
using Toybox.Application;
using Toybox.Communications as Comm;
using Toybox.System;
class LetsEncryptSSLTestApp extends Application.AppBase {
function initialize() {
AppBase.initialize();
}
private function showResult(testName, responseCode) {
//System.println("responseCode=" + responseCode);
var status = (responseCode == 200) ? "OK" : "FAIL";
System.println("[ " + status + " ] " + testName);
}
private function makeTestJSONRequest(url, callback) {
//System.println("Making request to url=" + url);
Comm.makeWebRequest(url, {}, {
:method => Comm.HTTP_REQUEST_METHOD_GET,
:headers => { "Content-Type" => Comm.REQUEST_CONTENT_TYPE_JSON },
:responseType => Comm.HTTP_RESPONSE_CONTENT_TYPE_JSON
},
callback);
}
// TEST 1: Test w/ Comodo SSL Cert
// Success
function onTestComodoSSLCertResponse(responseCode, data) {
self.showResult("testComodoSSLCert", responseCode);
self.testLetsEncryptSSLCert();
}
function testComodoSSLCert() {
self.makeTestJSONRequest("https://reqres.in/api/users/2",
self.method(:onTestComodoSSLCertResponse));
}
// TEST 2: Test using Let's Encrypt SSL Cert
//
// Fails in simulator
// Succeeds in curl
function onTestLetsEncryptSSLCertResponse(responseCode, data) {
self.showResult("testLetsEncryptSSLCert", responseCode);
self.testWithoutLetsEncryptSSLCert();
}
function testLetsEncryptSSLCert() {
self.makeTestJSONRequest("https://www.mocky.io/v2/5cf44057330000585d75865a",
self.method(:onTestLetsEncryptSSLCertResponse));
}
// TEST 3: Same endpoint as TEST 2 but w/o SSL
//
// Succeeds in simulator
function onTestWithoutLetsEncryptSSLCertResponse(responseCode, data) {
self.showResult("testWithoutLetsEncryptSSLCert", responseCode);
}
function testWithoutLetsEncryptSSLCert() {
self.makeTestJSONRequest("http://www.mocky.io/v2/5cf44057330000585d75865a",
self.method(:onTestWithoutLetsEncryptSSLCertResponse));
}
// onStart() is called on application start up
function onStart(state) {
self.testComodoSSLCert();
}
// onStop() is called when your application is exiting
function onStop(state) {
}
// Return the initial view of your application here
function getInitialView() {
return [ new LetsEncryptSSLTestView() ];
}
}