[code] Added checking on existence of certificate files;

master
leonid-ed 8 years ago
parent a2ea484beb
commit da10663592

@ -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;

Loading…
Cancel
Save