mirror of
https://github.com/sonertari/SSLproxy
synced 2024-11-04 12:00:15 +00:00
parent
173b2435d2
commit
067521924a
23
main.c
23
main.c
@ -159,21 +159,19 @@ main_usage(void)
|
|||||||
static void
|
static void
|
||||||
main_loadtgcrt(const char *filename, void *arg)
|
main_loadtgcrt(const char *filename, void *arg)
|
||||||
{
|
{
|
||||||
void **args = arg;
|
opts_t *opts = arg;
|
||||||
const char *argv0 = args[0];
|
|
||||||
opts_t *opts = args[1];
|
|
||||||
cert_t *cert;
|
cert_t *cert;
|
||||||
char **names;
|
char **names;
|
||||||
|
|
||||||
cert = cert_new_load(filename);
|
cert = cert_new_load(filename);
|
||||||
if (!cert) {
|
if (!cert) {
|
||||||
fprintf(stderr, "%s: error loading cert and key from PEM file "
|
log_err_printf("Failed to load cert and key from PEM file "
|
||||||
"'%s'\n", argv0, filename);
|
"'%s'\n", filename);
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
if (X509_check_private_key(cert->crt, cert->key) != 1) {
|
if (X509_check_private_key(cert->crt, cert->key) != 1) {
|
||||||
fprintf(stderr, "%s: cert does not match key in PEM file "
|
log_err_printf("Cert does not match key in PEM file "
|
||||||
"'%s':\n", argv0, filename);
|
"'%s':\n", filename);
|
||||||
ERR_print_errors_fp(stderr);
|
ERR_print_errors_fp(stderr);
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
@ -584,12 +582,6 @@ main(int argc, char *argv[])
|
|||||||
fprintf(stderr, "%s: failed to preinit cachemgr.\n", argv0);
|
fprintf(stderr, "%s: failed to preinit cachemgr.\n", argv0);
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
if (opts->tgcrtdir) {
|
|
||||||
const void *arg[2];
|
|
||||||
arg[0] = argv0;
|
|
||||||
arg[1] = opts;
|
|
||||||
sys_dir_eachfile(opts->tgcrtdir, main_loadtgcrt, arg);
|
|
||||||
}
|
|
||||||
if (log_preinit(opts) == -1) {
|
if (log_preinit(opts) == -1) {
|
||||||
fprintf(stderr, "%s: failed to preinit logging.\n", argv0);
|
fprintf(stderr, "%s: failed to preinit logging.\n", argv0);
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
@ -633,11 +625,16 @@ main(int argc, char *argv[])
|
|||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (opts->tgcrtdir) {
|
||||||
|
sys_dir_eachfile(opts->tgcrtdir, main_loadtgcrt, opts);
|
||||||
|
}
|
||||||
|
|
||||||
proxy_ctx_t *proxy = proxy_new(opts);
|
proxy_ctx_t *proxy = proxy_new(opts);
|
||||||
if (!proxy) {
|
if (!proxy) {
|
||||||
log_err_printf("Failed to initialize proxy.\n");
|
log_err_printf("Failed to initialize proxy.\n");
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
proxy_run(proxy);
|
proxy_run(proxy);
|
||||||
proxy_free(proxy);
|
proxy_free(proxy);
|
||||||
cachemgr_fini();
|
cachemgr_fini();
|
||||||
|
Loading…
Reference in New Issue
Block a user