【发布时间】:2018-03-17 03:34:34
【问题描述】:
得到这个非常烦人的错误。 error:0906D06C:PEM routines:PEM_read_bio:no start
代码:
RSA* publickey = cWrapper.getPublicKey("C:/rsa-stuff/public.pem");
QByteArray plain = "The man in the black fled into the desert and the gunslinger followed...";
QByteArray encrypted = cWrapper.encryptRSA(publickey, plain);
在 encryptRSA() 中:
const char* publicKeyStr = data.constData();
qDebug() << publicKeyStr;
BIO* bio = BIO_new_mem_buf((void*)publicKeyStr, -1);
BIO_set_flags(bio, BIO_FLAGS_BASE64_NO_NL);
RSA* rsaPubKey = PEM_read_bio_RSAPublicKey(bio, NULL, NULL, NULL);
if(!rsaPubKey) {
qDebug() << "Could not load public key, " << ERR_error_string(ERR_get_error(), NULL); // error is here
}
BIO_free(bio);
这是我读取文件的方式:
QByteArray data;
QFile file(filename);
if(!file.open(QFile::ReadOnly))
{
printf("Error reading file: %s\n", file.errorString());
return data;
}
data = file.readAll();
file.close();
return data;
当我打印出 publicKeyStr 时,看起来不错。这是启用了所有字符的记事本++ 视图:
有人知道我做错了什么吗?超级烦人的问题:(
首先,这不是this 的问题,因为我没有得到受信任的部分。无论如何,我确实尝试了所有“解决方案”,但都没有奏效,同样的错误。
【问题讨论】:
-
@S.M.不,这些解决方案都不起作用,甚至没有同样的错误......