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