| #include <openssl/pkcs12.h> |
| /* Simple PKCS#12 file creator */ |
| int main(int argc, char **argv) |
| fprintf(stderr, "Usage: pkwrite infile password name p12file\n"); |
| SSLeay_add_all_algorithms(); |
| ERR_load_crypto_strings(); |
| if (!(fp = fopen(argv[1], "r"))) { |
| fprintf(stderr, "Error opening file %s\n", argv[1]); |
| cert = PEM_read_X509(fp, NULL, NULL, NULL); |
| pkey = PEM_read_PrivateKey(fp, NULL, NULL, NULL); |
| p12 = PKCS12_create(argv[2], argv[3], pkey, cert, NULL, 0,0,0,0,0); |
| fprintf(stderr, "Error creating PKCS#12 structure\n"); |
| ERR_print_errors_fp(stderr); |
| if (!(fp = fopen(argv[4], "wb"))) { |
| fprintf(stderr, "Error opening file %s\n", argv[1]); |
| ERR_print_errors_fp(stderr); |