Class: HTTPAccess2::SSLSocketWrap

Inherits:
Object
  • Object
show all
Defined in:
lib/rss-client/http-access2.rb

Overview

HTTPAccess2::SSLSocketWrap

Instance Method Summary collapse

Constructor Details

#initialize(socket, context, debug_dev = nil) ⇒ SSLSocketWrap

Returns a new instance of SSLSocketWrap.



1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
# File 'lib/rss-client/http-access2.rb', line 1421

def initialize(socket, context, debug_dev = nil)
  unless SSLEnabled
    raise RuntimeError.new(
      "Ruby/OpenSSL module is required for https access.")
  end
  @context = context
  @socket = socket
  @ssl_socket = create_ssl_socket(@socket)
  @debug_dev = debug_dev
end

Instance Method Details

#<<(str) ⇒ Object



1485
1486
1487
1488
1489
# File 'lib/rss-client/http-access2.rb', line 1485

def <<(str)
  rv = @ssl_socket.write(str)
  @debug_dev << str if @debug_dev
  rv
end

#addrObject



1456
1457
1458
# File 'lib/rss-client/http-access2.rb', line 1456

def addr
  @socket.addr
end

#closeObject



1460
1461
1462
1463
# File 'lib/rss-client/http-access2.rb', line 1460

def close
  @ssl_socket.close
  @socket.close
end

#closed?Boolean

Returns:

  • (Boolean)


1465
1466
1467
# File 'lib/rss-client/http-access2.rb', line 1465

def closed?
  @socket.closed?
end

#eof?Boolean

Returns:

  • (Boolean)


1469
1470
1471
# File 'lib/rss-client/http-access2.rb', line 1469

def eof?
  @ssl_socket.eof?
end

#flushObject



1491
1492
1493
# File 'lib/rss-client/http-access2.rb', line 1491

def flush
  @ssl_socket.flush
end

#gets(*args) ⇒ Object



1473
1474
1475
1476
1477
# File 'lib/rss-client/http-access2.rb', line 1473

def gets(*args)
  str = @ssl_socket.gets(*args)
  @debug_dev << str if @debug_dev
  str
end

#peer_certObject



1452
1453
1454
# File 'lib/rss-client/http-access2.rb', line 1452

def peer_cert
  @ssl_socket.peer_cert
end

#post_connection_check(host) ⇒ Object



1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
# File 'lib/rss-client/http-access2.rb', line 1436

def post_connection_check(host)
  verify_mode = @context.verify_mode || OpenSSL::SSL::VERIFY_NONE
  if verify_mode == OpenSSL::SSL::VERIFY_NONE
    return
  elsif @ssl_socket.peer_cert.nil? and
      check_mask(verify_mode, OpenSSL::SSL::VERIFY_FAIL_IF_NO_PEER_CERT)
    raise OpenSSL::SSL::SSLError, "no peer cert"
  end
  hostname = host.host
  if @ssl_socket.respond_to?(:post_connection_check)
    @ssl_socket.post_connection_check(hostname)
  else
    @context.post_connection_check(@ssl_socket.peer_cert, hostname)
  end
end

#read(*args) ⇒ Object



1479
1480
1481
1482
1483
# File 'lib/rss-client/http-access2.rb', line 1479

def read(*args)
  str = @ssl_socket.read(*args)
  @debug_dev << str if @debug_dev
  str
end

#ssl_connectObject



1432
1433
1434
# File 'lib/rss-client/http-access2.rb', line 1432

def ssl_connect
  @ssl_socket.connect
end

#syncObject



1495
1496
1497
# File 'lib/rss-client/http-access2.rb', line 1495

def sync
  @ssl_socket.sync
end

#sync=(sync) ⇒ Object



1499
1500
1501
# File 'lib/rss-client/http-access2.rb', line 1499

def sync=(sync)
  @ssl_socket.sync = sync
end