From 0cff982e7b4765b7627198b321548c6811cb630d Mon Sep 17 00:00:00 2001 From: Juan RP Date: Sun, 1 May 2016 07:17:47 +0200 Subject: [PATCH] xbps-rindex/sign: simplify. --- bin/xbps-rindex/sign.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/bin/xbps-rindex/sign.c b/bin/xbps-rindex/sign.c index 06f869a8..0c73c189 100644 --- a/bin/xbps-rindex/sign.c +++ b/bin/xbps-rindex/sign.c @@ -88,7 +88,6 @@ pubkey_from_privkey(RSA *rsa) assert(buf); len = BIO_read(bp, buf, 8191); BIO_free(bp); - ERR_free_strings(); buf[len] = '\0'; return buf; @@ -130,11 +129,6 @@ load_rsa_key(const char *privkey) else defprivkey = strdup(privkey); - ERR_load_crypto_strings(); - OpenSSL_add_all_algorithms(); - OpenSSL_add_all_ciphers(); - OpenSSL_add_all_digests(); - if ((rsa = load_rsa_privkey(defprivkey)) == NULL) { fprintf(stderr, "%s: failed to read the RSA privkey\n", _XBPS_RINDEX); exit(EXIT_FAILURE); @@ -145,6 +139,13 @@ load_rsa_key(const char *privkey) return rsa; } +static void +ssl_init(void) +{ + SSL_load_error_strings(); + SSL_library_init(); +} + int sign_repo(struct xbps_handle *xhp, const char *repodir, const char *privkey, const char *signedby) @@ -180,6 +181,8 @@ sign_repo(struct xbps_handle *xhp, const char *repodir, goto out; } + ssl_init(); + rsa = load_rsa_key(privkey); /* * Check if repository index-meta contains changes compared to its @@ -337,6 +340,7 @@ int sign_pkgs(struct xbps_handle *xhp, int args, int argmax, char **argv, const char *privkey, bool force) { + ssl_init(); /* * Process all packages specified in argv. */