I'm having trouble programmatically reading a password protected
.pem file. With the same openssl library, I can read it using the
openssl command line.
Based on the below failure call stack, it seems to be failing getting the
nid for the cipher.
I suspect some compiler or linker option, but the fact that
the 'openssl' application works with the same library confuses
me.
Call stack:
PEM_read_bio_PrivateKey
PEM_bytes_read_bio
PEM_get_EVP_CIPHER_INFO
OBJ_sn2nid (AES-256-CBC)
OBJ_NAME_get
lh_retrieve
Program snip, basically the same as apps.c:load_key()
typedef struct pw_cb_data
{
const void *password;
const char *prompt_info;
} PW_CB_DATA;
int main()
{
long rc = 0; /* general return code */
PW_CB_DATA cb_data;
BIO *key = NULL;
EVP_PKEY *pkey=NULL;
cb_data.password = "kkkk";
cb_data.prompt_info = "signkey.pem";
key = BIO_new(BIO_s_file());
if (key == NULL) {
printf("Error BIO_new() failed\n");
rc = ERROR_CODE;
}
if (BIO_read_filename(key, "signkey.pem") <= 0) {
printf("Error opening %s\n", "signkey.pem");
rc = ERROR_CODE;
}
pkey = PEM_read_bio_PrivateKey(key, NULL, NULL, &cb_data);
if (pkey == NULL) {
printf("unable to load key\n");
rc = ERROR_CODE;
}
--
Ken Goldman [EMAIL PROTECTED]
914-784-7646 (863-7646)
______________________________________________________________________
OpenSSL Project http://www.openssl.org
User Support Mailing List [email protected]
Automated List Manager [EMAIL PROTECTED]