1
0
Fork 0
mirror of https://github.com/kakwa/uts-server synced 2025-07-04 20:47:09 +02:00

adding creation for the ts context

This commit is contained in:
kakwa 2016-08-26 01:28:34 +02:00
parent a420c0dd5c
commit 8ebbc08c88
7 changed files with 64 additions and 13 deletions

View file

@ -107,7 +107,8 @@ int http_server_start(char *conffile, bool stdout_dbg) {
rfc3161_context *ct = (rfc3161_context *)calloc(1, sizeof(rfc3161_context));
ct->stdout_dbg = stdout_dbg;
ct->loglevel = 8;
set_params(ct, conffile);
if (!set_params(ct, conffile))
return 1;
// Prepare callbacks structure. We have only one callback, the rest are
// NULL.

View file

@ -12,7 +12,6 @@
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#include "utils.h"
#include <sys/syslog.h>
#include <openssl/bio.h>
#include <openssl/err.h>
@ -20,6 +19,7 @@
#include <openssl/rand.h>
#include <openssl/ts.h>
#include <openssl/bn.h>
#include "rfc3161.h"
/* Name of config entry that defines the OID file. */
#define ENV_OID_FILE "oid_file"
@ -198,6 +198,53 @@ end:
return resp;
}
TS_RESP_CTX *create_tsctx(CONF *conf, const char *section, const char *policy) {
int ret = 0;
TS_RESP_CTX *resp_ctx = NULL;
if ((section = TS_CONF_get_tsa_section(conf, section)) == NULL)
goto end;
if ((resp_ctx = TS_RESP_CTX_new()) == NULL)
goto end;
if (!TS_CONF_set_serial(conf, section, NULL, resp_ctx))
goto end;
if (!TS_CONF_set_crypto_device(conf, section, NULL))
goto end;
if (!TS_CONF_set_signer_cert(conf, section, NULL, resp_ctx))
goto end;
if (!TS_CONF_set_certs(conf, section, NULL, resp_ctx))
goto end;
if (!TS_CONF_set_signer_key(conf, section, NULL, NULL, resp_ctx))
goto end;
// if (md) {
// if (!TS_RESP_CTX_set_signer_digest(resp_ctx, md))
// goto end;
// } else if (!TS_CONF_set_signer_digest(conf, section, NULL, resp_ctx)) {
// goto end;
// }
if (!TS_CONF_set_def_policy(conf, section, policy, resp_ctx))
goto end;
if (!TS_CONF_set_policies(conf, section, resp_ctx))
goto end;
if (!TS_CONF_set_digests(conf, section, resp_ctx))
goto end;
if (!TS_CONF_set_accuracy(conf, section, resp_ctx))
goto end;
if (!TS_CONF_set_clock_precision_digits(conf, section, resp_ctx))
goto end;
if (!TS_CONF_set_ordering(conf, section, resp_ctx))
goto end;
if (!TS_CONF_set_tsa_name(conf, section, resp_ctx))
goto end;
if (!TS_CONF_set_ess_cert_id_chain(conf, section, resp_ctx))
goto end;
ret = 1;
end:
return resp_ctx;
}
static TS_RESP *create_response(CONF *conf, const char *section, char *engine,
char *query, char *passin, char *inkey,
const EVP_MD *md, char *signer, char *chain,

View file

@ -9,10 +9,8 @@
#include <openssl/bio.h>
#include <errno.h>
#include <string.h>
#include "context.h"
#include <syslog.h>
#define FORMAT_TEXT 1
#include "utils.h"
typedef struct _code {
char *c_name;
@ -239,7 +237,10 @@ int set_params(rfc3161_context *ct, char *conf_file) {
}
ct->http_options[http_counter] = NULL;
}
// device = NCONF_get_string(conf, section, ENV_CRYPTO_DEVICE);
ct->ts_ctx = create_tsctx(conf, "tsa", NULL);
if (ct->ts_ctx == NULL)
ret = 0;
return ret;
end: