From aa62df3885f59f937d49fbf5d71a397e4bf52582 Mon Sep 17 00:00:00 2001 From: Alexander Vdolainen Date: Thu, 23 Jul 2015 14:57:30 +0300 Subject: [PATCH] forgotten function added; --- include/sntl/sntllv2.h | 3 +++ lib/connex.c | 21 +++++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/include/sntl/sntllv2.h b/include/sntl/sntllv2.h index cf5ec77..38a6fd3 100644 --- a/include/sntl/sntllv2.h +++ b/include/sntl/sntllv2.h @@ -202,6 +202,9 @@ int connections_destroy(conn_sys_t *ssys); int connections_free(conn_sys_t *ssys); +int connections_setsslserts(conn_sys_t *ssys, const char *rootca, + const char *certpem, const char *certkey); + /* create links */ conn_t *connection_master_link(conn_sys_t *ssys, int sck, struct in_addr *addr); conn_t *connection_link(conn_sys_t *ssys, const char *host, diff --git a/lib/connex.c b/lib/connex.c index 4b52a10..20ce312 100644 --- a/lib/connex.c +++ b/lib/connex.c @@ -268,3 +268,24 @@ conn_sys_t *connections_create(void) return nsys; } + +int connections_setsslserts(conn_sys_t *ssys, const char *rootca, + const char *certpem, const char *certkey) +{ + int r = ENOMEM; + + if(!ssys) return EINVAL; + /* simply copying */ + if(!(ssys->rootca = strdup(rootca))) return ENOMEM; + if(!(ssys->certkey = strdup(certkey))) goto __fail; + if(!(ssys->certpem = strdup(certpem))) goto __fail; + + r = 0; + return 0; + __fail: + if(ssys->rootca) free(ssys->rootca); + if(ssys->certkey) free(ssys->certkey); + if(ssys->certpem) free(ssys->certpem); + + return r; +}