Esempio n. 1
0
void tls_client(tcp_ctx *tcp, tls_ctx *ctx) {
    tls_session *tls = tls_new_session(ctx);
    FD_SET      fds;
    int         r;
    
    if (tls != NULL) {
      // open connection to remote host
      if (connect(
        tcp->s, tcp->ai_addr, 
        tcp->ai_addrlen)!=SOCKET_ERROR)
      {
        // set socket descriptor
        tls->sck = tcp->s;
        if (tls_handshake(ctx, tls)) {
          DEBUG_PRINT ("  [ connected.\n");
          
          #if defined(DEBUG) && DEBUG > 0 
            tls_info(ctx, tls, TLS_CONNECTION_INFO); 
            tls_info(ctx, tls, TLS_STREAM_SIZE);  
          #endif
          
          tls_cmd(ctx, tls);
        } else {
          DEBUG_PRINT("  [ handshake failed.\n"); 
        }
        shutdown(tcp->s, SD_BOTH);
        closesocket(tcp->s);
      } else {
        DEBUG_PRINT("  [ connect failed.\n");
      }
      tls_free_session(ctx, tls);    
    }
}
Esempio n. 2
0
void SockBuffer::log_stats() const
{
  LOG(INFO) << "read_limit_==" << (read_limit_ ? "true" : "false");
  LOG(INFO) << "octets_read_==" << octets_read_;
  LOG(INFO) << "octets_written_==" << octets_written_;
  log_totals();
  if (tls()) {
    LOG(INFO) << tls_info();
  }
}