/* * fetch_tls.h - minimal TLS stream over an already-connected socket. * * POSIX: vendored mbedTLS (verify peer + hostname against a CA bundle). * _WIN32: this layer is not used (WinHTTP does TLS itself), so the module is * an empty translation unit there and fx_tls_supported() reports 0. */ #ifndef SX_FETCH_TLS_H #define SX_FETCH_TLS_H #include #if !defined(_WIN32) typedef struct fx_tls fx_tls; /* Takes ownership of `fd` on success (closed by fx_tls_close). hostname is * used for SNI and certificate verification. Returns NULL + err on failure * (fd closed). */ fx_tls *fx_tls_connect_fd(int fd, const char *hostname, char *err, size_t errsz); /* Returns bytes read, 0 at EOF, -1 on error. */ int fx_tls_read(fx_tls *t, char *buf, size_t n); /* Returns bytes written or -1. */ int fx_tls_write(fx_tls *t, const char *buf, size_t n); void fx_tls_close(fx_tls *t); /* 1 when the binary was built with the TLS stack (POSIX), 0 otherwise. */ int fx_tls_supported(void); #endif /* !_WIN32 */ #endif /* SX_FETCH_TLS_H */