Skip to content

Commit 1c153b7

Browse files
committed
MHD_start_daemon doesn't like NULL options
1 parent 7c3e849 commit 1c153b7

File tree

1 file changed

+20
-9
lines changed

1 file changed

+20
-9
lines changed

src/http_api.c

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -451,17 +451,28 @@ int http_api__start(struct mosquitto__listener *listener)
451451
if(rp->ai_family == AF_INET6){
452452
flags |= MHD_USE_IPv6;
453453
}
454-
listener->mhd = MHD_start_daemon(flags, port, NULL, NULL, &http_api_handler, listener,
455-
MHD_OPTION_SOCK_ADDR, rp->ai_addr,
456-
MHD_OPTION_HTTPS_MEM_CERT, x509_cert,
457-
MHD_OPTION_HTTPS_MEM_KEY, x509_key,
458-
MHD_OPTION_END);
454+
if(x509_cert && x509_key){
455+
listener->mhd = MHD_start_daemon(flags, port, NULL, NULL, &http_api_handler, listener,
456+
MHD_OPTION_SOCK_ADDR, rp->ai_addr,
457+
MHD_OPTION_HTTPS_MEM_CERT, x509_cert,
458+
MHD_OPTION_HTTPS_MEM_KEY, x509_key,
459+
MHD_OPTION_END);
460+
}else{
461+
listener->mhd = MHD_start_daemon(flags, port, NULL, NULL, &http_api_handler, listener,
462+
MHD_OPTION_SOCK_ADDR, rp->ai_addr,
463+
MHD_OPTION_END);
464+
}
459465
freeaddrinfo(ainfo);
460466
}else{
461-
listener->mhd = MHD_start_daemon(flags | MHD_USE_DUAL_STACK, port, NULL, NULL, &http_api_handler, listener,
462-
MHD_OPTION_HTTPS_MEM_CERT, x509_cert,
463-
MHD_OPTION_HTTPS_MEM_KEY, x509_key,
464-
MHD_OPTION_END);
467+
if(x509_cert && x509_key){
468+
listener->mhd = MHD_start_daemon(flags | MHD_USE_DUAL_STACK, port, NULL, NULL, &http_api_handler, listener,
469+
MHD_OPTION_HTTPS_MEM_CERT, x509_cert,
470+
MHD_OPTION_HTTPS_MEM_KEY, x509_key,
471+
MHD_OPTION_END);
472+
}else{
473+
listener->mhd = MHD_start_daemon(flags | MHD_USE_DUAL_STACK, port, NULL, NULL, &http_api_handler, listener,
474+
MHD_OPTION_END);
475+
}
465476
}
466477

467478
mosquitto_FREE(x509_cert);

0 commit comments

Comments
 (0)