summaryrefslogtreecommitdiff
path: root/src/net/net.c
diff options
context:
space:
mode:
authorSoikk2026-01-01 19:49:02 +0100
committerSoikk2026-01-01 20:16:58 +0100
commite88c9d1739695ed8172c0eceffdc3d2c6e656403 (patch)
tree535e60128df31b5411242d2620e728b540c508a7 /src/net/net.c
parent8cdb3ba9256bf61453c25ee728349cd18dabe236 (diff)
downloadsoikk-server-master.tar.xz
soikk-server-master.tar.zst
Fixed receive_request for HTTPS connections and enabled HTTPS through the config fileHEADmaster
Diffstat (limited to 'src/net/net.c')
-rwxr-xr-xsrc/net/net.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/net/net.c b/src/net/net.c
index 39b25e3..3d738ae 100755
--- a/src/net/net.c
+++ b/src/net/net.c
@@ -98,7 +98,6 @@ int setup_https(http_server *hs, str certfile, str keyfile){
log_error("Missing private key file");
return 1;
}
-
if(hs->ssl != NULL){
SSL_free(hs->ssl);
}
@@ -192,18 +191,20 @@ static inline int server_read(http_server *hs, str *buf){
}
int receive_request(http_server *hs, str *request){
- // SSL_has_pending can return 0 if you havent read any bytes yet (https://stackoverflow.com/questions/6616976/why-does-this-ssl-pending-call-always-return-zero)
struct pollfd pfd[1] = { {.fd = hs->csocket, .events = POLLIN } };
while(poll(pfd, 1, 100)){
if(pfd[0].revents & POLLIN){
int rb = 0;
if(hs->secure){
- if(SSL_has_pending(hs->ssl)){
+ // SSL_has_pending can return 0 if you havent read any bytes yet
+ // https://stackoverflow.com/questions/6616976/why-does-this-ssl-pending-call-always-return-zero
+ // so we must perform a read first to advance the state machine
+ do{
rb = server_read(hs, request);
if(rb == 0){
return pleasesslgivemetheerror(SSL_get_error(hs->ssl, rb));
}
- }
+ }while(SSL_has_pending(hs->ssl));
}else{
rb = server_read(hs, request);
if(rb == 0){