src/server/daemon/httplistener.c

changeset 385
a1f4cb076d2f
parent 256
19259b6c5cf7
child 396
77d81f2bb9f7
--- a/src/server/daemon/httplistener.c	Tue Aug 13 22:14:32 2019 +0200
+++ b/src/server/daemon/httplistener.c	Sat Sep 24 16:26:10 2022 +0200
@@ -237,23 +237,18 @@
         }
         // TODO: cleanup on error
         
-        sstr_t file;
         int ret;
         char errbuf[512];
         
         if(!conf->chainfile.ptr) {
-            file = sstrdup(conf->certfile);
-            ret = SSL_CTX_use_certificate_file(ctx, file.ptr, SSL_FILETYPE_PEM);
-            free(file.ptr);
+            ret = SSL_CTX_use_certificate_file(ctx, conf->certfile.ptr, SSL_FILETYPE_PEM);
             if(!ret) {
                 ERR_error_string(ERR_get_error(), errbuf);
                 log_ereport(LOG_MISCONFIG, "Cannot load ssl chain file: %s", errbuf);
                 return NULL;
             }
         } else {
-            file = sstrdup(conf->chainfile);
-            ret = SSL_CTX_use_certificate_chain_file(ctx, file.ptr);
-            free(file.ptr);
+            ret = SSL_CTX_use_certificate_chain_file(ctx, conf->chainfile.ptr);
             if(!ret) { 
                 ERR_error_string(ERR_get_error(), errbuf);
                 log_ereport(LOG_MISCONFIG, "Cannot load ssl cert file: %s", errbuf);
@@ -261,9 +256,7 @@
             }
         }
         
-        file = sstrdup(conf->privkeyfile);
-        ret = SSL_CTX_use_PrivateKey_file(ctx, file.ptr, SSL_FILETYPE_PEM);
-        free(file.ptr);
+        ret = SSL_CTX_use_PrivateKey_file(ctx, conf->privkeyfile.ptr, SSL_FILETYPE_PEM);
         if(!ret) { 
             ERR_error_string(ERR_get_error(), errbuf);
             log_ereport(LOG_MISCONFIG, "Cannot load ssl key file: %s", errbuf);

mercurial