version 1.3, 2015/08/22 16:36:05 |
version 1.4, 2015/09/11 14:30:23 |
|
|
int |
int |
pkcs12_main(int argc, char **argv) |
pkcs12_main(int argc, char **argv) |
{ |
{ |
ENGINE *e = NULL; |
|
char *infile = NULL, *outfile = NULL, *keyname = NULL; |
char *infile = NULL, *outfile = NULL, *keyname = NULL; |
char *certfile = NULL; |
char *certfile = NULL; |
BIO *in = NULL, *out = NULL; |
BIO *in = NULL, *out = NULL; |
|
|
char *passin = NULL, *passout = NULL; |
char *passin = NULL, *passout = NULL; |
char *macalg = NULL; |
char *macalg = NULL; |
char *CApath = NULL, *CAfile = NULL; |
char *CApath = NULL, *CAfile = NULL; |
#ifndef OPENSSL_NO_ENGINE |
|
char *engine = NULL; |
|
#endif |
|
|
|
cert_pbe = NID_pbe_WithSHA1And40BitRC2_CBC; |
cert_pbe = NID_pbe_WithSHA1And40BitRC2_CBC; |
|
|
|
|
CAfile = *args; |
CAfile = *args; |
} else |
} else |
badarg = 1; |
badarg = 1; |
#ifndef OPENSSL_NO_ENGINE |
|
} else if (!strcmp(*args, "-engine")) { |
|
if (args[1]) { |
|
args++; |
|
engine = *args; |
|
} else |
|
badarg = 1; |
|
#endif |
|
} else |
} else |
badarg = 1; |
badarg = 1; |
|
|
|
|
BIO_printf(bio_err, "-password p set import/export password source\n"); |
BIO_printf(bio_err, "-password p set import/export password source\n"); |
BIO_printf(bio_err, "-passin p input file pass phrase source\n"); |
BIO_printf(bio_err, "-passin p input file pass phrase source\n"); |
BIO_printf(bio_err, "-passout p output file pass phrase source\n"); |
BIO_printf(bio_err, "-passout p output file pass phrase source\n"); |
#ifndef OPENSSL_NO_ENGINE |
|
BIO_printf(bio_err, "-engine e use engine e, possibly a hardware device.\n"); |
|
#endif |
|
BIO_printf(bio_err, "-CSP name Microsoft CSP name\n"); |
BIO_printf(bio_err, "-CSP name Microsoft CSP name\n"); |
BIO_printf(bio_err, "-LMK Add local machine keyset attribute to private key\n"); |
BIO_printf(bio_err, "-LMK Add local machine keyset attribute to private key\n"); |
goto end; |
goto end; |
} |
} |
#ifndef OPENSSL_NO_ENGINE |
|
e = setup_engine(bio_err, engine, 0); |
|
#endif |
|
|
|
if (passarg) { |
if (passarg) { |
if (export_cert) |
if (export_cert) |
|
|
|
|
if (!(options & NOKEYS)) { |
if (!(options & NOKEYS)) { |
key = load_key(bio_err, keyname ? keyname : infile, |
key = load_key(bio_err, keyname ? keyname : infile, |
FORMAT_PEM, 1, passin, e, "private key"); |
FORMAT_PEM, 1, passin, "private key"); |
if (!key) |
if (!key) |
goto export_end; |
goto export_end; |
} |
} |
|
|
/* Load in all certs in input file */ |
/* Load in all certs in input file */ |
if (!(options & NOCERTS)) { |
if (!(options & NOCERTS)) { |
certs = load_certs(bio_err, infile, FORMAT_PEM, NULL, e, |
certs = load_certs(bio_err, infile, FORMAT_PEM, NULL, |
"certificates"); |
"certificates"); |
if (!certs) |
if (!certs) |
goto export_end; |
goto export_end; |
|
|
if (certfile) { |
if (certfile) { |
STACK_OF(X509) * morecerts = NULL; |
STACK_OF(X509) * morecerts = NULL; |
if (!(morecerts = load_certs(bio_err, certfile, FORMAT_PEM, |
if (!(morecerts = load_certs(bio_err, certfile, FORMAT_PEM, |
NULL, e, |
NULL, "certificates from certfile"))) |
"certificates from certfile"))) |
|
goto export_end; |
goto export_end; |
while (sk_X509_num(morecerts) > 0) |
while (sk_X509_num(morecerts) > 0) |
sk_X509_push(certs, sk_X509_shift(morecerts)); |
sk_X509_push(certs, sk_X509_shift(morecerts)); |