Enhance server ssl configuration

- Added SSL certificate and key paths to ServerConfig structure.
- Updated init_config function to initialize new SSL paths.
- Formated code for better readability.
This commit is contained in:
2025-10-05 17:35:00 +00:00
parent 46b653efe0
commit 72df6a73fc
13 changed files with 1420 additions and 1000 deletions

View File

@@ -6,7 +6,8 @@
#include <stdbool.h>
// HTTP/2 session context
typedef struct {
typedef struct
{
nghttp2_session *session;
SSL *ssl;
int client_socket;
@@ -14,11 +15,12 @@ typedef struct {
} http2_session_t;
// HTTP/2 stream data
typedef struct {
typedef struct
{
int32_t stream_id;
char request_path[256];
char *request_method;
int fd; // File descriptor for response
int fd; // File descriptor for response
size_t file_size;
char *mime_type;
char *content_length;
@@ -28,14 +30,14 @@ typedef struct {
int http2_session_init(http2_session_t *session, int client_socket, SSL *ssl);
void http2_session_cleanup(http2_session_t *session);
int http2_handle_connection(http2_session_t *session);
int http2_send_response(http2_session_t *session, int32_t stream_id,
int http2_send_response(http2_session_t *session, int32_t stream_id,
const char *data, size_t len, bool end_stream);
int http2_send_error(http2_session_t *session, int32_t stream_id,
int http2_send_error(http2_session_t *session, int32_t stream_id,
int status_code, const char *message);
// ALPN callback for protocol selection
int alpn_select_proto_cb(SSL *ssl, const unsigned char **out,
unsigned char *outlen, const unsigned char *in,
unsigned int inlen, void *arg);
unsigned char *outlen, const unsigned char *in,
unsigned int inlen, void *arg);
#endif