使用Botan访问违规阅读位置

时间:2017-10-24 06:07:03

标签: c++ botan

我已经集成了用于TLS安全性的botan库。 我得到以下错误:

jsonrpctest.exe中0x6DBFD1CE(vcruntime140.dll)的第一次机会异常:0xC0000005:访问冲突读取位置0x00962000。 如果存在此异常的处理程序,则可以安全地继续该程序

以下是我打电话的代码

int main(int argc, char *argv[])
{
// prepare all the parameters
Callbacks callbacks;
Botan::AutoSeeded_RNG rng;
Botan::TLS::Session_Manager_In_Memory session_mgr(rng);
Client_Credentials creds;
Botan::TLS::Strict_Policy policy;

// open the tls connection : Error comes here
Botan::TLS::Client client(callbacks,
    session_mgr,
    creds,
    policy,
    rng,
    Botan::TLS::Server_Information("10.193.252.14", 43733),
    Botan::TLS::Protocol_Version::TLS_V12);

while (!client.is_closed())
{
    //cout << client.is_active;
    // read data received from the tls server, e.g., using BSD sockets or 
 boost asio
    // ...

    // send data to the tls server using client.send_data()
} }

1 个答案:

答案 0 :(得分:1)

此错误的确切原因未知。我认为这是一些构建标志可能是视觉工作室。我在发布版本中遇到了类似的错误,但它在调试版本中运行良好。然后我建立它作为库(DLL)而不是应用程序(.exe),我没有看到任何问题。我认为使用Botan的最佳方法是进行合并构建(即不使用Botan DLL库,而是将Botan代码导入您的应用程序然后使用它)。这是对我有用的构建命令(从Botan源文件夹运行它):

configure.py --cpu=i386 --amalgamation --single-amalgamation-file --minimized-build --enable-modules=tls,x509,seed,rdseed,rdrand,rdrand_rng,auto_rng --disable-shared

在运行上述命令之前,您需要安装Python并在路径中。 上面的命令将在Botan源代码目录中生成以下文件(即运行上述命令的相同路径):

botan_all.h,botan_all_internal.h和botan_all.cpp

您需要将这些文件包含在应用程序代码中,使用它并构建它。

有关Botan合并版本的更多信息:https://botan.randombit.net/manual/building.html#amalgamation

相关问题