2020-12-05 19:26:32 +08:00
|
|
|
#pragma once
|
2021-12-14 20:42:41 +08:00
|
|
|
|
2020-12-05 19:26:32 +08:00
|
|
|
#include "net.h"
|
2021-12-14 20:42:41 +08:00
|
|
|
#include "tls_mbed.h"
|
|
|
|
#include "tls_openssl.h"
|
2020-12-05 19:26:32 +08:00
|
|
|
|
|
|
|
struct mg_tls_opts {
|
2021-01-30 21:03:11 +08:00
|
|
|
const char *ca; // CA certificate file. For both listeners and clients
|
2021-10-14 23:32:48 +08:00
|
|
|
const char *crl; // Certificate Revocation List. For clients
|
2021-01-30 21:03:11 +08:00
|
|
|
const char *cert; // Certificate
|
|
|
|
const char *certkey; // Certificate key
|
|
|
|
const char *ciphers; // Cipher list
|
|
|
|
struct mg_str srvname; // If not empty, enables server name verification
|
2022-01-19 01:11:02 +08:00
|
|
|
struct mg_fs *fs; // FS API for reading certificate files
|
2020-12-05 19:26:32 +08:00
|
|
|
};
|
|
|
|
|
2022-04-12 17:04:55 +08:00
|
|
|
void mg_tls_init(struct mg_connection *, const struct mg_tls_opts *);
|
2021-05-29 01:30:42 +08:00
|
|
|
void mg_tls_free(struct mg_connection *);
|
|
|
|
long mg_tls_send(struct mg_connection *, const void *buf, size_t len);
|
|
|
|
long mg_tls_recv(struct mg_connection *, void *buf, size_t len);
|
2022-04-12 16:38:25 +08:00
|
|
|
size_t mg_tls_pending(struct mg_connection *);
|
2021-05-29 01:30:42 +08:00
|
|
|
void mg_tls_handshake(struct mg_connection *);
|