diff --git a/tutorials/http/http-server/Makefile b/tutorials/http/http-server/Makefile index cd80e97b..60801a25 100644 --- a/tutorials/http/http-server/Makefile +++ b/tutorials/http/http-server/Makefile @@ -24,8 +24,10 @@ all: $(PROG) # Default target. Build and run program $(PROG): $(SOURCES) # Build program from sources $(CC) $(SOURCES) $(CFLAGS) $(CFLAGS_MONGOOSE) $(CFLAGS_EXTRA) $(OUT) -vc98: - cl $(SOURCES) -DMG_ENABLE_SSI=1 -DMG_TLS=MG_TLS_BUILTIN - clean: # Cleanup. Delete built program and all build artifacts $(DELETE) $(PROG) *.o *.obj *.exe *.dSYM + + +vc98: CC = cl +vc98: + $(CC) $(SOURCES) $(CFLAGS_MONGOOSE) -DMG_ENABLE_IPV6=0 $(CFLAGS_EXTRA) /MD /Feserver.exe diff --git a/tutorials/http/http-server/ca.pem b/tutorials/http/http-server/ca.pem deleted file mode 100644 index f9529ab2..00000000 --- a/tutorials/http/http-server/ca.pem +++ /dev/null @@ -1,8 +0,0 @@ ------BEGIN CERTIFICATE----- -MIIBFTCBvAIJAMNTFtpfcq8NMAoGCCqGSM49BAMCMBMxETAPBgNVBAMMCE1vbmdv -b3NlMB4XDTI0MDUwNzE0MzczNloXDTM0MDUwNTE0MzczNlowEzERMA8GA1UEAwwI -TW9uZ29vc2UwWTATBgcqhkjOPQIBBggqhkjOPQMBBwNCAASuP+86T/rOWnGpEVhl -fxYZ+pjMbCmDZ+vdnP0rjoxudwRMRQCv5slRlDK7Lxue761sdvqxWr0Ma6TFGTNg -epsRMAoGCCqGSM49BAMCA0gAMEUCIQCwb2CxuAKm51s81S6BIoy1IcandXSohnqs -us64BAA7QgIgGGtUrpkgFSS0oPBlCUG6YPHFVw42vTfpTC0ySwAS0M4= ------END CERTIFICATE----- diff --git a/tutorials/http/http-server/certs b/tutorials/http/http-server/certs new file mode 120000 index 00000000..6417c1fe --- /dev/null +++ b/tutorials/http/http-server/certs @@ -0,0 +1 @@ +../../../test/certs \ No newline at end of file diff --git a/tutorials/http/http-server/crt.pem b/tutorials/http/http-server/crt.pem deleted file mode 100644 index d4518e8c..00000000 --- a/tutorials/http/http-server/crt.pem +++ /dev/null @@ -1,9 +0,0 @@ ------BEGIN CERTIFICATE----- -MIIBMTCB2aADAgECAgkAluqkgeuV/zUwCgYIKoZIzj0EAwIwEzERMA8GA1UEAwwI -TW9uZ29vc2UwHhcNMjQwNTA3MTQzNzM2WhcNMzQwNTA1MTQzNzM2WjARMQ8wDQYD -VQQDDAZzZXJ2ZXIwWTATBgcqhkjOPQIBBggqhkjOPQMBBwNCAASo3oEiG+BuTt5y -ZRyfwNr0C+SP+4M0RG2pYkb2v+ivbpfi72NHkmXiF/kbHXtgmSrn/PeTqiA8M+mg -BhYjDX+zoxgwFjAUBgNVHREEDTALgglsb2NhbGhvc3QwCgYIKoZIzj0EAwIDRwAw -RAIgTXW9MITQSwzqbNTxUUdt9DcB+8pPUTbWZpiXcA26GMYCIBiYw+DSFMLHmkHF -+5U3NXW3gVCLN9ntD5DAx8LTG8sB ------END CERTIFICATE----- diff --git a/tutorials/http/http-server/key.pem b/tutorials/http/http-server/key.pem deleted file mode 100644 index b146ec2f..00000000 --- a/tutorials/http/http-server/key.pem +++ /dev/null @@ -1,5 +0,0 @@ ------BEGIN EC PRIVATE KEY----- -MHcCAQEEIAVdo8UAScxG7jiuNY2UZESNX/KPH8qJ0u0gOMMsAzYWoAoGCCqGSM49 -AwEHoUQDQgAEqN6BIhvgbk7ecmUcn8Da9Avkj/uDNERtqWJG9r/or26X4u9jR5Jl -4hf5Gx17YJkq5/z3k6ogPDPpoAYWIw1/sw== ------END EC PRIVATE KEY----- diff --git a/tutorials/http/http-server/main.c b/tutorials/http/http-server/main.c index a757ce9b..8598e63e 100644 --- a/tutorials/http/http-server/main.c +++ b/tutorials/http/http-server/main.c @@ -9,14 +9,14 @@ static const char *s_root_dir = "."; static const char *s_listening_addr = "http://0.0.0.0:8000"; static const char *s_enable_hexdump = "no"; static const char *s_ssi_pattern = "#.html"; -static const char *s_upload_dir = NULL; // File uploads disabled by default -static const char *s_ca_path = NULL; // TLS CA file. Enables mutual TLS -static const char *s_crt_path = "crt.pem"; // TLS cert file -static const char *s_key_path = "key.pem"; // TLS key file +static const char *s_upload_dir = NULL; // File uploads disabled by default -// For self signed certificates, see +// TLS certificates. For self signed certificates, see // https://github.com/cesanta/mongoose/blob/master/test/certs/generate.sh -static struct mg_str s_ca, s_crt, s_key; // Initialised in main +static const char *s_ca_path = NULL; // TLS CA file. Enables mutual TLS +static const char *s_crt_path = "certs/server.crt"; // TLS cert file +static const char *s_key_path = "certs/server.key"; // TLS key file +static struct mg_str s_ca, s_crt, s_key; // Initialised in main // Handle interrupts, like Ctrl-C static int s_signo; @@ -122,6 +122,7 @@ int main(int argc, char *argv[]) { s_ca = mg_file_read(&mg_fs_posix, s_ca_path); s_crt = mg_file_read(&mg_fs_posix, s_crt_path); s_key = mg_file_read(&mg_fs_posix, s_key_path); + if (s_crt.len == 0 || s_key.len == 0) MG_ERROR(("TLS cert+key not loaded")); // Root directory must not contain double dots. Make it absolute // Do the conversion only if the root dir spec does not contain overrides