summaryrefslogtreecommitdiff
path: root/plugins/websocket/ws_tls.h
blob: 2615fab5f08a35e1927d9f624e07e5b472e73766 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#ifndef HYBBX_WS_TLS_H
#define HYBBX_WS_TLS_H

#include "hybbx/types.h"

#include <stddef.h>
#include <sys/types.h>

#ifdef __cplusplus
extern "C" {
#endif

/** Return 1 when this build links OpenSSL for WebSocket TLS. */
int hybbx_ws_tls_compiled(void);

/**
 * Create @p cert_dir if needed and generate a self-signed certificate on first
 * start when files are missing. No-op when OpenSSL is not compiled in.
 */
hybbx_result_t hybbx_ws_tls_ensure_certs(const char *cert_dir);

/** Load server TLS context after @p cert_dir is ready. */
hybbx_result_t hybbx_ws_tls_server_start(const char *cert_dir);

void hybbx_ws_tls_server_stop(void);

/** Return 1 when the server accepts TLS (OpenSSL + certs loaded). */
int hybbx_ws_tls_server_enabled(void);

/** Perform TLS server handshake on @p fd; returns opaque SSL* or NULL. */
void *hybbx_ws_tls_accept(int fd);

ssize_t hybbx_ws_tls_recv(void *tls, void *buf, size_t len);
ssize_t hybbx_ws_tls_send(void *tls, const void *buf, size_t len);

void hybbx_ws_tls_shutdown(void *tls);
void hybbx_ws_tls_free(void *tls);

#ifdef __cplusplus
}
#endif

#endif /* HYBBX_WS_TLS_H */
git clone -b <branch> https://cgit.mode42.com/<repo>.git
git clone -b <branch> git://cgit.mode42.com/<repo>.git

info@mode42.com