#include <openssl/evp.h>
#include <openssl/pkcs12.h>
-#include "apps.h"
#define PROG pkcs8_main
int MAIN(int, char **);
int nocrypt = 0;
X509_SIG *p8;
PKCS8_PRIV_KEY_INFO *p8inf;
- EVP_PKEY *pkey;
+ EVP_PKEY *pkey=NULL;
char pass[50], *passin = NULL, *passout = NULL, *p8pass = NULL;
int badarg = 0;
char *engine=NULL;
if (bio_err == NULL) bio_err = BIO_new_fp (stderr, BIO_NOCLOSE);
+ if (!load_config(bio_err, NULL))
+ goto end;
+
informat=FORMAT_PEM;
outformat=FORMAT_PEM;
if (topk8)
{
BIO_free(in); /* Not needed in this section */
- pkey = load_key(bio_err, infile, informat, passin, e, "key");
+ pkey = load_key(bio_err, infile, informat, 1,
+ passin, e, "key");
if (!pkey) {
return (1);
}
if(passout) p8pass = passout;
else {
p8pass = pass;
- EVP_read_pw_string(pass, 50, "Enter Encryption Password:", 1);
+ if (EVP_read_pw_string(pass, 50, "Enter Encryption Password:", 1))
+ return (1);
}
app_RAND_load_file(NULL, bio_err, 0);
if (!(p8 = PKCS8_encrypt(pbe_nid, cipher,
return (1);
}
+ end:
EVP_PKEY_free(pkey);
BIO_free_all(out);
BIO_free(in);