diff options
author | Rich Salz <rsalz@akamai.com> | 2015-06-04 10:14:28 -0400 |
---|---|---|
committer | Rich Salz <rsalz@openssl.org> | 2015-06-04 18:03:33 -0400 |
commit | c0cf5b84dd32480965da7ff1e11d11a1ec9c4662 (patch) | |
tree | 3e6a89a88ad5d757c83684f99ad233b705ae86a6 /crypto/ts | |
parent | 6c40d469b7eb49f17af24d5ec7cee28f2310c26f (diff) |
Set error code, no fprintf stderr, on errors.
Reviewed-by: Richard Levitte <levitte@openssl.org>
Diffstat (limited to 'crypto/ts')
-rw-r--r-- | crypto/ts/ts_conf.c | 12 | ||||
-rw-r--r-- | crypto/ts/ts_err.c | 11 |
2 files changed, 17 insertions, 6 deletions
diff --git a/crypto/ts/ts_conf.c b/crypto/ts/ts_conf.c index 4d303f7b0b..27b3df2609 100644 --- a/crypto/ts/ts_conf.c +++ b/crypto/ts/ts_conf.c @@ -102,7 +102,7 @@ X509 *TS_CONF_load_cert(const char *file) x = PEM_read_bio_X509_AUX(cert, NULL, NULL, NULL); end: if (x == NULL) - fprintf(stderr, "unable to load certificate: %s\n", file); + TSerr(TS_F_TS_CONF_LOAD_CERT, TS_R_CANNOT_LOAD_CERT); BIO_free(cert); return x; } @@ -129,7 +129,7 @@ STACK_OF(X509) *TS_CONF_load_certs(const char *file) } end: if (othercerts == NULL) - fprintf(stderr, "unable to load certificates: %s\n", file); + TSerr(TS_F_TS_CONF_LOAD_CERTS, TS_R_CANNOT_LOAD_CERT); sk_X509_INFO_pop_free(allcerts, X509_INFO_free); BIO_free(certs); return othercerts; @@ -145,7 +145,7 @@ EVP_PKEY *TS_CONF_load_key(const char *file, const char *pass) pkey = PEM_read_bio_PrivateKey(key, NULL, NULL, (char *)pass); end: if (pkey == NULL) - fprintf(stderr, "unable to load private key: %s\n", file); + TSerr(TS_F_TS_CONF_LOAD_KEY, TS_R_CANNOT_LOAD_KEY); BIO_free(key); return pkey; } @@ -154,12 +154,14 @@ EVP_PKEY *TS_CONF_load_key(const char *file, const char *pass) static void ts_CONF_lookup_fail(const char *name, const char *tag) { - fprintf(stderr, "variable lookup failed for %s::%s\n", name, tag); + TSerr(TS_F_TS_CONF_LOOKUP_FAIL, TS_R_VAR_LOOKUP_FAILURE); + ERR_add_error_data(3, name, "::", tag); } static void ts_CONF_invalid(const char *name, const char *tag) { - fprintf(stderr, "invalid variable value for %s::%s\n", name, tag); + TSerr(TS_F_TS_CONF_INVALID, TS_R_VAR_BAD_VALUE); + ERR_add_error_data(3, name, "::", tag); } const char *TS_CONF_get_tsa_section(CONF *conf, const char *section) diff --git a/crypto/ts/ts_err.c b/crypto/ts/ts_err.c index ff1abf4533..3f5b78f9ee 100644 --- a/crypto/ts/ts_err.c +++ b/crypto/ts/ts_err.c @@ -1,6 +1,6 @@ /* crypto/ts/ts_err.c */ /* ==================================================================== - * Copyright (c) 1999-2007 The OpenSSL Project. All rights reserved. + * Copyright (c) 1999-2015 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -87,6 +87,11 @@ static ERR_STRING_DATA TS_str_functs[] = { {ERR_FUNC(TS_F_TS_CHECK_SIGNING_CERTS), "TS_CHECK_SIGNING_CERTS"}, {ERR_FUNC(TS_F_TS_CHECK_STATUS_INFO), "TS_CHECK_STATUS_INFO"}, {ERR_FUNC(TS_F_TS_COMPUTE_IMPRINT), "TS_COMPUTE_IMPRINT"}, + {ERR_FUNC(TS_F_TS_CONF_INVALID), "ts_CONF_invalid"}, + {ERR_FUNC(TS_F_TS_CONF_LOAD_CERT), "TS_CONF_load_cert"}, + {ERR_FUNC(TS_F_TS_CONF_LOAD_CERTS), "TS_CONF_load_certs"}, + {ERR_FUNC(TS_F_TS_CONF_LOAD_KEY), "TS_CONF_load_key"}, + {ERR_FUNC(TS_F_TS_CONF_LOOKUP_FAIL), "ts_CONF_lookup_fail"}, {ERR_FUNC(TS_F_TS_CONF_SET_DEFAULT_ENGINE), "TS_CONF_set_default_engine"}, {ERR_FUNC(TS_F_TS_GET_STATUS_TEXT), "TS_GET_STATUS_TEXT"}, {ERR_FUNC(TS_F_TS_MSG_IMPRINT_SET_ALGO), "TS_MSG_IMPRINT_set_algo"}, @@ -132,6 +137,8 @@ static ERR_STRING_DATA TS_str_functs[] = { static ERR_STRING_DATA TS_str_reasons[] = { {ERR_REASON(TS_R_BAD_PKCS7_TYPE), "bad pkcs7 type"}, {ERR_REASON(TS_R_BAD_TYPE), "bad type"}, + {ERR_REASON(TS_R_CANNOT_LOAD_CERT), "cannot load certificate"}, + {ERR_REASON(TS_R_CANNOT_LOAD_KEY), "cannot load private key"}, {ERR_REASON(TS_R_CERTIFICATE_VERIFY_ERROR), "certificate verify error"}, {ERR_REASON(TS_R_COULD_NOT_SET_ENGINE), "could not set engine"}, {ERR_REASON(TS_R_COULD_NOT_SET_TIME), "could not set time"}, @@ -170,6 +177,8 @@ static ERR_STRING_DATA TS_str_reasons[] = { {ERR_REASON(TS_R_UNACCEPTABLE_POLICY), "unacceptable policy"}, {ERR_REASON(TS_R_UNSUPPORTED_MD_ALGORITHM), "unsupported md algorithm"}, {ERR_REASON(TS_R_UNSUPPORTED_VERSION), "unsupported version"}, + {ERR_REASON(TS_R_VAR_BAD_VALUE), "var bad value"}, + {ERR_REASON(TS_R_VAR_LOOKUP_FAILURE), "cannot find config variable"}, {ERR_REASON(TS_R_WRONG_CONTENT_TYPE), "wrong content type"}, {0, NULL} }; |