redbean: add tls socket lua binding
Add TLS module for Lua using mbedTLS
- Implements TLS socket creation and management
- Supports connection, read, write, and close ops
- Handles memory safely with proper cleanup
- Provides error handling and status reporting
- Configurable SSL verification and timeouts
I add a reference to this fullmoon request - https://github.com/pkulchenko/fullmoon/issues/29#issuecomment-1826528990 that seems related to the exposure of more mbedtls endpoints (I don't know if this should belong to the tls module or somewhere else)
@pkulchenko listed the openssl APIs that we are currently missing in order to add automatic letsencrypt DNS-01 challenge like the one existing in the caddy web server.
it would be a great new redbean feature if the exposure of more mbedtls endpoints could make it possible to have automatic ssl certification embedded.
I copy them here for reference
capturex('openssl', ('genrsa', '-out', $_, KEY_SIZE)); capturex('openssl', ('rsa', '-text', '-in', $self->{domain}{account}, '-noout', '-modulus')); capturex('openssl', ('rsa', '-in', $self->{domain}{account}, '-pubout'))); capturex('openssl', ('dgst', '-sha256', '-binary', '-sign', $self->{domain}{account}, $stf->filename)) capturex('openssl', ('req', '-new', '-outform', 'DER', '-key', $self->{domain}{key}, '-config', $oct->filename, '-out', $self->{req}{csr}));