Trying to update esp32 firmware for self signed ssl

the code itself uploads as it should, but I am not getting the desired results. Here is the code

#include <Arduino.h>
 
#include <WiFi.h>
#include <WiFiMulti.h>
#include <WiFiClientSecure.h>
 
#include <HTTPClient.h>
#include <HTTPUpdate.h>
 
#include <time.h>
#include <NTPClient.h>
 
//#ifndef APSSID
//#define APSSID "<esp>"
//#define APPSK  "<esp@12345>"
//#endif
 
const char* ssid = "esp";
const char* password = "esp@12345";
//WiFiMulti WiFiMulti;
 
#define FIRMWARE_VERSION "0.3"
 
// Set time via NTP, as required for x.509 validation
void setClock() {
  configTime(0, 0, "pool.ntp.org", "time.nist.gov");  // UTC
 
  Serial.print(F("Waiting for NTP time sync: "));
  time_t now = time(nullptr);
  while (now < 8 * 3600 * 2) {
    yield();
    delay(500);
    Serial.print(F("."));
    now = time(nullptr);
  }
 
  Serial.println(F(""));
  struct tm timeinfo;
  gmtime_r(&now, &timeinfo);
  Serial.print(F("Current time: "));
  Serial.print(asctime(&timeinfo));
}
 
static const char serverCACert[] PROGMEM = R"EOF(
-----BEGIN CERTIFICATE-----
MIIDvTCCAqWgAwIBAgIURNVpkhYNC4vb9zo9vY4cf4LyIcEwDQYJKoZIhvcNAQEL
BQAwbjELMAkGA1UEBhMCU0ExDzANBgNVBAgMBkplZGRhaDEPMA0GA1UEBwwGSmVk
ZGFoMRUwEwYDVQQKDAxWaWdpbGFudCBleWUxFjAUBgNVBAsMDWN5YmVyc2VjdXJp
dHkxDjAMBgNVBAMMBWxhbWFyMB4XDTI0MDQyNTE3NDAzOFoXDTI0MDUyNTE3NDAz
OFowbjELMAkGA1UEBhMCU0ExDzANBgNVBAgMBkplZGRhaDEPMA0GA1UEBwwGSmVk
ZGFoMRUwEwYDVQQKDAxWaWdpbGFudCBleWUxFjAUBgNVBAsMDWN5YmVyc2VjdXJp
dHkxDjAMBgNVBAMMBWxhbWFyMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKC
AQEAv5h1B5O60lBCxJfzmJwmrNkSL3qIwpj/oKes04GAtIbVpuPifj4denlbMHye
mGN8SuGW7qRH+M6ZKi/GpNSDcDjCrRed1LFBiXh56E0mWmp1sWvPtq3h9LZGSNHF
xkfGFcFSm77Vxw7BTSAEksPNrHgSinmvDmG32B5KapZl4W5Yu2OgABAJe6CKOTOh
x0ZRzNGFBhsXrrD6YAJsWsecvX0vkBNW7bR6ksn5+PYy4+adfP+e55DXlZQTdFDd
yxi1Aa0G3c/okb47Xy5bOClLa5kiU2RaUZ1Grjj4ZipESp8DkeIK/JKig3BnVSEq
0xIafDI3bJdvvUmHnrsBzODVISO6IfW0OyckFte448WfWTSrlAaS1TVTJDPoyHRQ
NnK+B74/VNW9gDSCcvHHMeUhWGwlYIb6RkdGv4GAOynnVF07p24a2K+qpM4tv1Jb
I07IuaaStrqZXV08UQMhmcxa+6N1qzvNR1Ij9H2tyMwevZJDazH9rj5GVPmVjTdy
Gg==
-----END CERTIFICATE-----
)EOF";
 
 
const char* updateServer = "192.168.8.102";
const int updateServerPort = 443;
 
void setup() {
 
  Serial.begin(115200);
  // Serial.setDebugOutput(true);
 
  Serial.println();
  Serial.println();
  Serial.println();
 
  for (uint8_t t = 4; t > 0; t--) {
    Serial.printf("[SETUP] WAIT %d...\n", t);
    Serial.flush();
    delay(1000);
  }
 
  //WiFi.mode(WIFI_STA);
 
  //WiFiMulti.addAP(APSSID, APPSK);

   WiFi.begin(ssid, password);

  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }
  Serial.println("");
  Serial.println("WiFi connected");
 
  Serial.print(F("Firmware version "));
  Serial.println(FIRMWARE_VERSION);
 
 
//  WiFi.setDNS(dns1, dns2);
 
  delay(2000);
 
}
 
void loop() {
  // wait for WiFi connection
  if ((WiFi.status() == WL_CONNECTED)) {
        setClock();
 
        WiFiClientSecure client;
//      client.setInsecure();
 
        client.setCACert(serverCACert);
 
        // Reading data over SSL may be slow, use an adequate timeout
        client.setTimeout(12000 / 1000); // timeout argument is defined in seconds for setTimeout
 
        // httpUpdate.setLedPin(LED_BUILTIN, LOW);
     
        httpUpdate.rebootOnUpdate(false); // remove automatic update
     
        Serial.println(F("Update start now!"));
     
        t_httpUpdate_return ret = httpUpdate.update(client, "https://"+String(updateServer)+":"+String(updateServerPort)+"/update", FIRMWARE_VERSION);
     
        switch (ret) {
          case HTTP_UPDATE_FAILED:
            Serial.printf("HTTP_UPDATE_FAILD Error (%d): %s\n", httpUpdate.getLastError(), httpUpdate.getLastErrorString().c_str());
            Serial.println(F("Retry in 10secs!"));
            delay(10000); // Wait 10secs
            break;
     
          case HTTP_UPDATE_NO_UPDATES:
            Serial.println("HTTP_UPDATE_NO_UPDATES");
            break;
     
          case HTTP_UPDATE_OK:
            Serial.println("HTTP_UPDATE_OK");
            delay(1000); // Wait a second and restart
            ESP.restart();
            break;
        }
            delay(10000);
      }
}

In this code I added my self signed certificate and linked it to my local server that also has the same certificate. the server is waiting on port 443, same as the code.
but the esp32 is not updating

this is my output on serial monitor:
[SETUP] WAIT 4...

[SETUP] WAIT 3...

[SETUP] WAIT 2...

[SETUP] WAIT 1...

......

WiFi connected

Firmware version 0.3

Waiting for NTP time sync: .

Current time: Sat Apr 27 13:00:42 2024

Update start now!

HTTP_UPDATE_FAILD Error (-1): HTTP error: connection refused

Retry in 10secs!

Waiting for NTP time sync:

Current time: Sat Apr 27 13:01:04 2024

Update start now!

HTTP_UPDATE_FAILD Error (-1): HTTP error: connection refused

Retry in 10secs

it just keeps looping every 10 seconds, as expected.
I am currently using an arduino as a serial converter (middle man between esp32 and laptop), this arduino is connected to my laptop through a usb cable and has reset and gnd plugged into itself.
I have the appropriate board downloaded and selected in board manager.