Certificate exchange procedure with SSL/HTTPS

Does anyone know how to do this at a low level, not through one of the WiFi or Ethernet libraries.

ESP32 core has a secure client but not a secure server.

And I wan to create my own library to provide this for ESP32.

But I have no clue where to begin with it.