Files
TAIXIN/sdk/include/lib/net/sslsock/ssl_sock.h

87 lines
2.6 KiB
C
Raw Permalink Normal View History

#ifndef __SSL_SOCKET_ADAPTER_H__
#define __SSL_SOCKET_ADAPTER_H__
typedef struct {
int8 is_server;
int8 verify_cert; // 是否验证客户端证书0=不验证1=验证)
int8 debug, r2;
const char *cert; // 服务器证书数据PEM/DER 自动识别)
const char *key; // 服务器私钥数据PEM/DER 自动识别)
const char *ca_cert; // CA证书数据仅verify_cert=1时需传
uint32 max_session_cache; // 会话缓存最大条目默认100
uint32 session_timeout_sec; // 会话超时时间默认30
} ssl_sock_init_param;
typedef struct {
/**
* @brief SSL全局上下文
* @param param
* @return void *
*/
void *(*global_init)(const ssl_sock_init_param *param);
/**
* @brief
* @param global_ctx
*/
void (*global_destroy)(void *global_ctx);
/**
* @brief
* @param global_ctx
* @return void *
*/
void *(*conn_create)(void *global_ctx);
/**
* @brief
* @param conn_ctx
*/
void (*conn_destroy)(void *conn_ctx);
/**
* @brief TLS握手
* @param conn_ctx
* @param sockfd
* @param step
* @return int 0-1
*/
int (*handshake)(void *conn_ctx, int sockfd, int step);
/**
* @brief
* @param conn_ctx
* @param data
* @param len
* @return int32
*/
int32(*send)(void *conn_ctx, const uint8 *data, uint32 len);
/**
* @brief
* @param conn_ctx
* @param buf
* @param buf_len
* @return int32
*/
int32(*recv)(void *conn_ctx, uint8 *buf, uint32 buf_len);
/**
* @brief
* @param conn_ctx
*/
void (*shutdown)(void *conn_ctx);
/**
* @brief
* @param conn_ctx
* @return const char*
*/
const char *(*get_error)(void *conn_ctx);
} sslsock_ops;
extern const sslsock_ops sslsock_mbedtls_ops;
#endif // __UHTTPD_SSL_ADAPTER_H__