C++ PEM_read_RSA_PUBKEY返回并中断应用程序
我正在尝试使用C++ PEM_read_RSA_PUBKEY返回并中断应用程序,c++,openssl,rsa,C++,Openssl,Rsa,我正在尝试使用RSA来使用OpenSSL加密一些东西 RSA *rsaPubKey = RSA_new(); FILE *file; file = fopen("PubKey.pem","r"); if(file){ rsaPubKey = PEM_read_RSA_PUBKEY(file, &rsaPubKey ,NULL,NULL); } .......... //some stuff return 0 执行PEM\u read\u RSA\u PUBKEY后,应用程序
RSA
来使用OpenSSL
加密一些东西
RSA *rsaPubKey = RSA_new();
FILE *file;
file = fopen("PubKey.pem","r");
if(file){
rsaPubKey = PEM_read_RSA_PUBKEY(file, &rsaPubKey ,NULL,NULL);
}
.......... //some stuff
return 0
执行
PEM\u read\u RSA\u PUBKEY
后,应用程序将在没有错误的情况下终止。我不知道怎么了 我在一个旧项目中使用了以下代码:
BIO *bioPub = BIO_new_file(pubkeyPath, "r");
RSA *pubkey = PEM_read_bio_PUBKEY(bioPub, NULL, NULL, NULL);
/* do some stuff */
RSA_free(pubkey);
BIO_free(bioPub);
你试过以下方法吗
FILE *file = fopen("PubKey.pem","r");
RSA *rsaPubKey = PEM_read_RSA_PUBKEY(file, NULL, NULL, NULL);
尝试分配给rsaPubKey 0而不是RSA_new()。您确定应用程序在PEM_read_RSA_PUBKEY中/之后立即终止吗?当然,它已终止,这就是程序的结束!不,哈哈,后面还有一些东西!!!