xbps-rindex/sign: simplify.

This commit is contained in:
Juan RP 2016-05-01 07:17:47 +02:00
parent 8030f47626
commit 0cff982e7b

View File

@ -88,7 +88,6 @@ pubkey_from_privkey(RSA *rsa)
assert(buf); assert(buf);
len = BIO_read(bp, buf, 8191); len = BIO_read(bp, buf, 8191);
BIO_free(bp); BIO_free(bp);
ERR_free_strings();
buf[len] = '\0'; buf[len] = '\0';
return buf; return buf;
@ -130,11 +129,6 @@ load_rsa_key(const char *privkey)
else else
defprivkey = strdup(privkey); 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) { if ((rsa = load_rsa_privkey(defprivkey)) == NULL) {
fprintf(stderr, "%s: failed to read the RSA privkey\n", _XBPS_RINDEX); fprintf(stderr, "%s: failed to read the RSA privkey\n", _XBPS_RINDEX);
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
@ -145,6 +139,13 @@ load_rsa_key(const char *privkey)
return rsa; return rsa;
} }
static void
ssl_init(void)
{
SSL_load_error_strings();
SSL_library_init();
}
int int
sign_repo(struct xbps_handle *xhp, const char *repodir, sign_repo(struct xbps_handle *xhp, const char *repodir,
const char *privkey, const char *signedby) const char *privkey, const char *signedby)
@ -180,6 +181,8 @@ sign_repo(struct xbps_handle *xhp, const char *repodir,
goto out; goto out;
} }
ssl_init();
rsa = load_rsa_key(privkey); rsa = load_rsa_key(privkey);
/* /*
* Check if repository index-meta contains changes compared to its * 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, sign_pkgs(struct xbps_handle *xhp, int args, int argmax, char **argv,
const char *privkey, bool force) const char *privkey, bool force)
{ {
ssl_init();
/* /*
* Process all packages specified in argv. * Process all packages specified in argv.
*/ */