使用boost :: asio设置SSL套接字而无需身份验证

时间:2012-02-09 12:31:52

标签: c++ boost ssl boost-asio

我认为这段代码正常,但我想要连接的服务器没有正常运行的身份验证。我想禁用身份验证检查,但仍然使用SSL连接?这是代码:

    // Create a context that uses the default paths for
    // finding CA certificates.
    ssl::context ctx(ssl::context::sslv23);
    ctx.set_default_verify_paths();

    // Open a socket and connect it to the remote host.
    ssl_socket sock(io_service, ctx);
    tcp::resolver::query query(host_name_, "https");
    boost::asio::connect(sock.lowest_layer(), resolver_.resolve(query));
    sock.lowest_layer().set_option(tcp::no_delay(true));

    // Perform SSL handshake and verify the remote host's
    // certificate.
    sock.set_verify_mode(boost::asio::ssl::context::verify_none);

    //sock.set_verify_callback();
    //sock.set_verify_callback(ssl::rfc2818_verification(host_name_));
    sock.handshake(ssl_socket::client);

如何删除身份验证检查?

0 个答案:

没有答案