From f40732e857686e3fe0bd60b7571ba49ebc8a82df Mon Sep 17 00:00:00 2001 From: kakwa Date: Sat, 27 Aug 2016 11:39:53 +0200 Subject: [PATCH] implementing loading of the OIDs --- inc/rfc3161.h | 1 + src/lib/rfc3161.c | 28 ++++++++++++++++++++++++---- src/lib/utils.c | 2 ++ tests/cfg/uts-server.cnf | 2 +- 4 files changed, 28 insertions(+), 5 deletions(-) diff --git a/inc/rfc3161.h b/inc/rfc3161.h index bf64565..8bd4a9b 100644 --- a/inc/rfc3161.h +++ b/inc/rfc3161.h @@ -38,3 +38,4 @@ static ASN1_INTEGER *next_serial(const char *serialfile); static int save_ts_serial(const char *serialfile, ASN1_INTEGER *serial); TS_RESP_CTX *create_tsctx(rfc3161_context *ct, CONF *conf, const char *section, const char *policy); +int add_oid_section(rfc3161_context *ct, CONF *conf); diff --git a/src/lib/rfc3161.c b/src/lib/rfc3161.c index f061945..fb71052 100644 --- a/src/lib/rfc3161.c +++ b/src/lib/rfc3161.c @@ -22,8 +22,7 @@ #include #include "utils.h" -/* Name of config entry that defines the OID file. */ -#define ENV_OID_FILE "oid_file" +#define OID_SECTION "oids" /* Reply related functions. */ static int reply_command(CONF *conf, char *section, char *engine, char *query, @@ -71,6 +70,28 @@ static int save_ts_serial(const char *serialfile, ASN1_INTEGER *serial); * Reply-related method definitions. */ +int add_oid_section(rfc3161_context *ct, CONF *conf) +{ + char *p; + STACK_OF(CONF_VALUE) *sktmp; + CONF_VALUE *cnf; + int i; + + if ((sktmp = NCONF_get_section(conf, OID_SECTION)) == NULL) { + uts_logger(ct, LOG_ERR, "problem loading oid section %s\n", p); + return 0; + } + for (i = 0; i < sk_CONF_VALUE_num(sktmp); i++) { + cnf = sk_CONF_VALUE_value(sktmp, i); + if (OBJ_create(cnf->value, cnf->name, cnf->name) == NID_undef) { + uts_logger(ct, LOG_ERR, "problem creating object %s=%s\n", + cnf->name, cnf->value); + return 0; + } + } + return 1; +} + static int reply_command(CONF *conf, char *section, char *engine, char *query, char *passin, char *inkey, const EVP_MD *md, char *signer, char *chain, const char *policy, @@ -282,10 +303,9 @@ end: ERR_load_TS_strings(); uts_logger(ct, LOG_DEBUG, "OpenSSL exception: '%s'", ERR_error_string(err_code, NULL)); - uts_logger(ct, LOG_ERR, "error '%s' in component '%s'", + uts_logger(ct, LOG_ERR, "error '%s' in OpenSSL component '%s'", ERR_reason_error_string(err_code), ERR_lib_error_string(err_code)); - // printf("%lu\n", err_code, NULL); // printf("%s\n", ERR_reason_error_string(err_code)); // printf("%s\n", ERR_func_error_string(err_code)); diff --git a/src/lib/utils.c b/src/lib/utils.c index 105c058..6965581 100644 --- a/src/lib/utils.c +++ b/src/lib/utils.c @@ -240,6 +240,8 @@ int set_params(rfc3161_context *ct, char *conf_file) { ct->http_options[http_counter] = NULL; } + if(! add_oid_section(ct, conf)) + ret = 0; ct->ts_ctx = create_tsctx(ct, conf, NULL, NULL); if (ct->ts_ctx == NULL) ret = 0; diff --git a/tests/cfg/uts-server.cnf b/tests/cfg/uts-server.cnf index 70d628e..d296573 100644 --- a/tests/cfg/uts-server.cnf +++ b/tests/cfg/uts-server.cnf @@ -1,4 +1,4 @@ -[ new_oids ] +[ oids ] # Policies used by the TSA examples. tsa_policy1 = 1.2.3.4.1