cesanta / mongoose

Embedded Web Server
https://mongoose.ws
Other
11.16k stars 2.73k forks source link

TLS build options outdated #2363

Closed Keith-amateur closed 1 year ago

Keith-amateur commented 1 year ago

TLS-Build

I believe the contents of https://mongoose.ws/documentation/tutorials/tls/#how-to-build are outdated. MG_ENABLE_MBEDTLS or MG_ENABLE_OPENSSL doesn't exist in mongoose.h any more.

Now it should be using MG_TLS_MBED and MG_TLS_OPENSSL.
Example: -DMG_TLS=MG_TLS_MBED -Imbedtls/include -lmbedtls -lmbedx509 -lmbedcrypto -Lmbedtls/library

PROG ?= tls-server
OUT ?= -o $(PROG)
SRCS = main.c mongoose.c daemonize.c
OBJS = $(SRCS:.c=.o)
CFLAGS = -W -Wall -Wextra -g -I.
CFLAGS_EXTRA = -DMG_TLS=MG_TLS_MBED -Imbedtls/include
LDFLAGS = -lmbedtls -lmbedx509 -lmbedcrypto -Lmbedtls/library
# LDFLAGS += -static

all: mbedtls $(PROG)

$(PROG): $(OBJS)
    $(CC) $(OBJS) $(LDFLAGS) $(OUT)

%.o: %.c
    $(CC) $(SRCS) $(CFLAGS) $(CFLAGS_EXTRA) -c $<

clean:
    rm -f $(PROG) *.o

mbedtls:                  # Pull and build mbedTLS library
    proxychains git clone --depth 1 -b v2.28.2 https://github.com/mbed-tls/mbedtls $@
    CC=$(CC) $(MAKE) -C mbedtls/library

.PHONY: clean all mbedtls $(PROG)

TLS-TCP example

I used the above method to complie the tcp example. It seemed that TLS is not working. plain_tcp Need to replace the tcp:// of s_lsn and s_conn with https:// for TLS connection taking effect. TLS doesn't always carry http traffic, so it seems a little wired to me.


BTW, love the Project. It helped me a lot.

scaprile commented 1 year ago

2341 #2356 |

Already answered, thanks. Use release instead of HEAD