diff --git a/sxmp/hub.c b/sxmp/hub.c index 362aafe..f8e2cb1 100644 --- a/sxmp/hub.c +++ b/sxmp/hub.c @@ -651,10 +651,28 @@ sxhub_t *sxhub_create(void) int sxhub_setsslserts(sxhub_t *ssys, const char *rootca, const char *certpem, const char *certkey) { - int r = ENOMEM; + if (!ssys || !rootca || !certpem || !certkey) + return EINVAL; + + /* check on existence of certificate files */ + if (access(rootca, R_OK) == -1) { + fprintf(stderr, "Unable to access rootca file ('%s'): ", rootca); + perror(""); + return ENOENT; + } + if (access(certpem, R_OK) == -1) { + fprintf(stderr, "Unable to access certpem file ('%s'): ", certpem); + perror(""); + return ENOENT; + } + if (access(certkey, R_OK) == -1) { + fprintf(stderr, "Unable to access certkey file ('%s'): ", certkey); + perror(""); + return ENOENT; + } - if(!ssys) return EINVAL; /* simply copying */ + int r = ENOMEM; if(!(ssys->rootca = strdup(rootca))) return ENOMEM; if(!(ssys->certkey = strdup(certkey))) goto __fail; if(!(ssys->certpem = strdup(certpem))) goto __fail;