1/* see license file for copyright and license details */
2#ifndef TLS_H_
3#define TLS_H_
4
5#include <sys/types.h>
6
7struct TlsSocket;
8
9/* tls_connect takes an already connected socket fd and upgrades it to tls
10 if check_cert is 0 certificate validation is bypassed
11 returns a new tls socket or null on error */
12struct TlsSocket *tls_connect(int fd, const char *host, int check_cert, int is_tls);
13
14/* standard read and write wrapping either libressl bearssl or plain fallback */
15ssize_t tls_read(struct TlsSocket *s, void *buf, size_t len);
16ssize_t tls_write(struct TlsSocket *s, const void *buf, size_t len);
17
18/* closes the tls connection and optionally closes the socket fd */
19void tls_close(struct TlsSocket *s, int close_fd);
20
21#endif /* tls_h_ */