HTTPS
Reference sheet for the HTTPS service
The HTTPS service simulates a basic web server. It extends the functionality of the HTTP service by adding TLS support. It has two modes of operation:
In “Fake” mode, requests to any URL will return a generic response with a configurable status code, headers and body.
In “Real” mode, a directory can be specified and the server will serve static files from that directory. If a requested file is not found, a 404 response will be returned.
Configuration
Section titled “Configuration”| Option | Type | Default | Description |
|---|---|---|---|
enabled |
bool | true |
Whether the HTTPS service is enabled |
listen |
string | :443 |
The address and port to listen on (e.g. :443) |
status |
int | 200 |
The status code to return in “Fake” mode |
mode |
string | fake |
Which mode to use when serving files |
root_dir |
string | ./ |
Which directory to serve files from in “Real” mode |
cert |
string | "" |
The path to the TLS certificate file (PEM format). If empty, a self-signed certificate will be generated |
key |
string | "" |
The path to the TLS key file (PEM format). If empty, a self-signed key will be generated |
To see instructions on how to configure these options, see the configuration guide.
Command
Section titled “Command”The HTTPS service can be run on its own by passing it as a target to run:
gonetsim run httpsgonetsim.exe run httpsThis starts the HTTPS service with the current configuration, without starting any other services (Including the HTTP service; the HTTP service is not started with this command).
Testing
Section titled “Testing”You can test the HTTPS service using curl.
-
Start the HTTPS service
Terminal window gonetsim run https -
In a separate terminal, make a request to the service using
curlTerminal window curl -k https://localhost -
Return to the GoNetSim instance and you should see a log of the request in the output
Further reading
Section titled “Further reading”- See the basic configuration guide for a walkthrough on configuration
- See the HTTPS reference sheet for information on the HTTP service, which this service extends
