[core] Added obtaining of full paths of certificate files;

master
leonid-ed 8 years ago
parent da10663592
commit 88f7f478a9

@ -656,29 +656,44 @@ int sxhub_setsslserts(sxhub_t *ssys, const char *rootca,
/* check on existence of certificate files */
if (access(rootca, R_OK) == -1) {
fprintf(stderr, "Unable to access rootca file ('%s'): ", rootca);
perror("");
ssys->log(SXERROR_LOG, "Unable to read rootca file '%s': %s\n",
rootca, sys_errlist[errno]);
return ENOENT;
}
if (access(certpem, R_OK) == -1) {
fprintf(stderr, "Unable to access certpem file ('%s'): ", certpem);
perror("");
ssys->log(SXERROR_LOG, "Unable to read certpem file '%s': %s\n",
certpem, sys_errlist[errno]);
return ENOENT;
}
if (access(certkey, R_OK) == -1) {
fprintf(stderr, "Unable to access certkey file ('%s'): ", certkey);
perror("");
ssys->log(SXERROR_LOG, "Unable to read certkey file '%s': %s\n",
certkey, sys_errlist[errno]);
return ENOENT;
}
/* 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;
/* obtain full paths of certificate files */
int r;
if (NULL == (ssys->rootca = realpath(rootca, NULL))) {
ssys->log(SXERROR_LOG, "Unable to obtain the full path of '%s': %s\n",
rootca, sys_errlist[errno]);
if (errno == ENOMEM) r = errno;
goto __fail;
}
if (NULL == (ssys->certpem = realpath(certpem, NULL))) {
ssys->log(SXERROR_LOG, "Unable to obtain the full path of '%s': %s\n",
certpem, sys_errlist[errno]);
if (errno == ENOMEM) r = errno;
goto __fail;
}
if (NULL == (ssys->certkey = realpath(certkey, NULL))) {
ssys->log(SXERROR_LOG, "Unable to obtain the full path of '%s': %s\n",
certkey, sys_errlist[errno]);
if (errno == ENOMEM) r = errno;
goto __fail;
}
r = 0;
return 0;
__fail:
if(ssys->rootca) free(ssys->rootca);
if(ssys->certkey) free(ssys->certkey);

Loading…
Cancel
Save