summaryrefslogtreecommitdiffstats
path: root/src/tls.c
diff options
context:
space:
mode:
authorDrew DeVault <sir@cmpwn.com>2020-09-26 16:10:10 -0400
committerDrew DeVault <sir@cmpwn.com>2020-09-26 16:10:10 -0400
commit50d21c03f5b02254d8eb0953bd5e635813cfe1c1 (patch)
tree9a6ca3851fdf22c68a5e14eecb0052c83409ff1a /src/tls.c
parente9641dbf1ec871d8ab367b4f4655278caeecf621 (diff)
downloadgmnisrv-50d21c03f5b02254d8eb0953bd5e635813cfe1c1.tar.gz
gmnisrv-50d21c03f5b02254d8eb0953bd5e635813cfe1c1.tar.xz
gmnisrv-50d21c03f5b02254d8eb0953bd5e635813cfe1c1.zip
Free up resources throughout
Diffstat (limited to 'src/tls.c')
-rw-r--r--src/tls.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/src/tls.c b/src/tls.c
index 7d748d7..cde4b25 100644
--- a/src/tls.c
+++ b/src/tls.c
@@ -156,7 +156,7 @@ generate:
}
int
-gmnisrv_tls_init(struct gmnisrv_config *conf)
+tls_init(struct gmnisrv_config *conf)
{
SSL_load_error_strings();
ERR_load_crypto_strings();
@@ -177,8 +177,18 @@ gmnisrv_tls_init(struct gmnisrv_config *conf)
return 0;
}
+void
+tls_finish(struct gmnisrv_config *conf)
+{
+ SSL_CTX_free(conf->tls.ssl_ctx);
+ for (struct gmnisrv_host *host = conf->hosts; host; host = host->next) {
+ X509_free(host->x509);
+ EVP_PKEY_free(host->pkey);
+ }
+}
+
SSL *
-gmnisrv_tls_get_ssl(struct gmnisrv_config *conf, int fd)
+tls_get_ssl(struct gmnisrv_config *conf, int fd)
{
SSL *ssl = SSL_new(conf->tls.ssl_ctx);
if (!ssl) {
@@ -190,7 +200,7 @@ gmnisrv_tls_get_ssl(struct gmnisrv_config *conf, int fd)
}
void
-gmnisrv_tls_set_host(SSL *ssl, struct gmnisrv_host *host)
+tls_set_host(SSL *ssl, struct gmnisrv_host *host)
{
SSL_use_certificate(ssl, host->x509);
SSL_use_PrivateKey(ssl, host->pkey);