用PEM_read_bio_RSAPublicKey读取公钥失败
先用openssl genrsa -out rsakey0.pem 1024
生成了私钥文件,然后在用openssl rsa -in rsakey0.pem -pubout -out rsakey0-pub.pem生成公钥文件
用VC开发加解密的程序:
私钥部分:
BIO *key=NULL;
RSA *r=NULL;
ERR_load_crypto_strings();
key=BIO_new(BIO_s_file());
BIO_read_filename(key,"rsakey0.pem");
r = PEM_read_bio_RSAPrivateKey(key,NULL,NULL,NULL);
正常!!
公钥部分:
BIO *key=NULL;
RSA *r=NULL;
ERR_load_crypto_strings();
key=BIO_new(BIO_s_file());
BIO_read_filename(key,"rsakey0-pub.pem");
r = PEM_read_bio_RSAPublicKey(key,NULL,NULL,NULL);
r返回为NULL.
百思不得其解,望高手指教!!!!!