openssl中使用PEM_read_bio_RSAPrivateKey读取私钥,获取的结构体RSA为NULL,请问是什么情况?
path = [[NSBundle mainBundle] pathForResource:@"private_key" ofType:@"pem"];
//path = [[NSBundle mainBundle] pathForResource:@"client" ofType:@"key"];
char *p_de;
RSA *p_rsa;
FILE *file;
int rsa_len;
if ((file = fopen([path UTF8String], "r")) == NULL) {
perror("\nopen key file error");
}
//RSA_read_bio_RSAPrivateKey 使用bio读取密钥
BIO *key = NULL;
p_rsa = NULL;
//新建一个文件结构体
key = BIO_new(BIO_s_file());
BIO_read_filename(key, [path UTF8String]);
//读取key文件中的私钥保存在RSA结构体中
p_rsa = PEM_read_bio_RSAPrivateKey(key, NULL, nil, nil);
if(!p_rsa){
ERR_print_errors_fp(stdout);
return nil;
}