void AsyncSecureStream::_handleHandshake(std::error_code ec, const std::string& hostName) {
    auto certStatus =
        getSSLManager()->parseAndValidatePeerCertificate(_stream.native_handle(), hostName);
    if (!certStatus.isOK()) {
        warning() << certStatus.getStatus();
        return _userHandler(
            // TODO: fix handling of std::error_code w.r.t. codes used by Status
            std::error_code(certStatus.getStatus().code(), std::generic_category()));
    }
    _userHandler(std::error_code());
}
Ejemplo n.º 2
0
void AsyncSecureStream::_handleHandshake(std::error_code ec, const std::string& hostName) {
    auto certStatus =
        getSSLManager()->parseAndValidatePeerCertificate(_stream.native_handle(), hostName);
    if (!certStatus.isOK()) {
        warning() << certStatus.getStatus();
    }
    _userHandler(make_error_code(certStatus.getStatus().code()));
}
void AsyncSecureStream::_handleConnect(std::error_code ec, asio::ip::tcp::resolver::iterator iter) {
    _stream.async_handshake(decltype(_stream)::client,
                            [this, iter](std::error_code ec) {
                                if (ec) {
                                    return _userHandler(ec);
                                }
                                return _handleHandshake(ec, iter->host_name());
                            });
}
void AsyncSecureStream::connect(const asio::ip::tcp::resolver::iterator endpoints,
                                ConnectHandler&& connectHandler) {
    // Stash the connectHandler as we won't be able to call it until we re-enter the state
    // machine.
    _userHandler = std::move(connectHandler);
    asio::async_connect(_stream.lowest_layer(),
                        std::move(endpoints),
                        [this](std::error_code ec, asio::ip::tcp::resolver::iterator iter) {
                            if (ec) {
                                return _userHandler(ec);
                            }
                            return _handleConnect(ec, std::move(iter));
                        });
}