- if(keyfile) {
- BIO *keybio;
- keybio = BIO_new_file(keyfile, "r");
- if(!keybio) {
- BIO_printf(bio_err, "Error opening key file %s\n",
- keyfile);
- ERR_print_errors(bio_err);
- goto end;
- }
-
- if(want_pub)
- sigkey = PEM_read_bio_PUBKEY(keybio, NULL, NULL, NULL);
- else sigkey = PEM_read_bio_PrivateKey(keybio, NULL, NULL, NULL);
- BIO_free(keybio);
- if(!sigkey) {
- BIO_printf(bio_err, "Error reading key file %s\n",
- keyfile);
- ERR_print_errors(bio_err);
+ if(keyfile)
+ {
+ if (want_pub)
+ sigkey = load_pubkey(bio_err, keyfile, keyform, NULL,
+ e, "key file");
+ else
+ sigkey = load_key(bio_err, keyfile, keyform, NULL,
+ e, "key file");
+ if (!sigkey)
+ {
+ /* load_[pub]key() has already printed an appropriate
+ message */