NEWS: Welcome to my new homepage! <3

fix: Fixed TLS certificate bug - libhttp - A basic HTTP Framework

libhttp

A basic HTTP Framework
git clone git://192.168.2.2/libhttp
Log | Files | Refs | README

commit ab7b16f87f6a682c367aaf377aa4265bf7434145
parent 8ecc334becef5d55c2e804e830902fe7eb02613e
Author: typable <contact@typable.dev>
Date:   Fri, 20 Sep 2024 12:12:33 +0200

fix: Fixed TLS certificate bug

Diffstat:
Mlibhttp.c | 3++-
Mlibhttp.h | 1+
2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/libhttp.c b/libhttp.c @@ -531,6 +531,7 @@ void http_bind(char *hostname, int port, http_host_t *hosts, int hosts_len) { http_binds = realloc(http_binds, sizeof(http_bind_t) * (http_binds_len + 1)); http_bind_t *http_bind = &http_binds[http_binds_len]; http_bind->sockfd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); + http_bind->port = port; if (http_bind->sockfd <= 0) { perror("cannot create socket"); errno = HTTP_ERR_NO_SOCKET; @@ -578,7 +579,7 @@ void http_bind(char *hostname, int port, http_host_t *hosts, int hosts_len) { http_error = true; return; } - if (SSL_CTX_use_certificate_file(http_host->ssl_ctx, http_host->certificate, SSL_FILETYPE_PEM) <= 0) { + if (SSL_CTX_use_certificate_chain_file(http_host->ssl_ctx, http_host->certificate) <= 0) { perror("cannot use certificate file"); errno = HTTP_ERR_INVALID_CERTIFICATE; http_error = true; diff --git a/libhttp.h b/libhttp.h @@ -89,6 +89,7 @@ typedef struct { int sockfd; http_host_t *hosts; int hosts_len; + int port; } http_bind_t; typedef struct {