Ruby 1.9.2 リファレンスマニュアル > ライブラリ一覧 > opensslライブラリ > OpenSSL::SSL::SSLSocketクラス

class OpenSSL::SSL::SSLSocket

クラスの継承リスト: OpenSSL::SSL::SSLSocket < Enumerable < OpenSSL::SSL::SocketForwarder < OpenSSL::Buffering < Object < Kernel < BasicObject

要約

ソケットをラップして SSL での認証と暗号通信を実現するためのクラスです。

SSL/TLS サーバに接続して write します。

require 'socket'
require 'openssl'
include OpenSSL

soc = TCPSocket.new('www.example.com', 443)
ssl = SSL::SSLSocket.new(soc)
ssl.connect
ssl.post_connection_check('www.example.com')
raise "verification error" if ssl.verify_result != OpenSSL::X509::V_OK
ssl.write('hoge')
print ssl.peer_cert.to_text
ssl.close
soc.close

特異メソッド

定義 説明
new(socket) -> OpenSSL::SSL::SSLSocket
new(socket, context) -> OpenSSL::SSL::SSLSocket

socket をラップして SSLSocket オブジェクトを生成します。

インスタンスメソッド

定義 説明
accept -> self

TLS/SSL 通信をサーバモードとして開始し、クライアントからの ハンドシェイク開始を待ち、クライアントとのハンドシェイクを実行します。

accept_nonblock -> self

ノンブロッキング方式で TLS/SSL 通信をサーバモードとして開始し、 クライアントとのハンドシェイクを実行します。

cert -> OpenSSL::X509::Certificate | nil

自分自身を証明する証明書を返します。

cipher -> [String, String, Integer, Integer]

現在実際に使われている暗号の情報を配列で返します。

connect -> self

TLS/SSl 通信をクライアントモードとして開始し、 サーバとのハンドシェイクを実行します。

connect_nonblock -> self

ノンブロッキング方式で TLS/SSL 通信をクライアントモードとして開始し、 サーバとのハンドシェイクを実行します。

context -> OpenSSL::SSL::SSLContext

SSLSocket オブジェクトを生成する時に渡されたコンテクストを返します。

hostname -> String | nil

TLS の Server Name Indication 拡張で利用するサーバのホスト名を返します。

hostname=(hostname)

TLS の Server Name Indication(SNI) 拡張で利用するサーバのホスト名を設定します。

io -> IO
to_io -> IO

SSLSocket オブジェクトを生成する時に渡されたソケットを返します。

peer_cert -> OpenSSL::X509::Certificate | nil

接続相手の証明書オブジェクトを返します。

peer_cert_chain -> [OpenSSL::X509::Certificate] | nil

接続相手の証明書チェインを OpenSSL::X509::Certificate オブジェクト の配列で返します。

pending -> Integer | nil

OpenSSL内部のバッファが保持している、直ちに読み取り可能な データのバイト数を返します。

post_connection_check(hostname) -> true

接続後検証を行います。

session -> OpenSSL::SSL::Session

利用している SSL セッションを OpenSSL::SSL::Session オブジェクトで返します。

session=(sess)

ハンドシェイクで再利用する SSL セッションを 設定します。

session_reused? -> bool

利用している SSL セッションが再利用されたものである 場合に真を返します。

state -> String

現在の状態をアルファベット 6 文字の文字列で返します。

sync_close -> bool

SSLSocket を close するときにラップしているソケットも close するかどうかを 返します。

sync_close=(bool)

SSLSocket を close するときにラップしているソケットも close するかどうかを 設定します。

sysclose -> nil

接続を閉じます。相手に'close notify'を送ります。

sysread(length, buf=nil) -> String

データをバッファを経由せずに暗号化通信路から読み込み、 読み込んだデータを文字列で返します。

syswrite(string) -> Integer

データをバッファを経由せずに暗号化通信路に書き込みます。

verify_result -> Integer

検証結果のエラーコードを整数値で返します。

継承したメソッド

! != all? any? chunk collect collect_concat count cycle detect drop drop_while each_cons each_entry each_slice each_with_index each_with_object entries find_all find_index first grep group_by include? inject max max_by min min_by minmax minmax_by none? one? partition reject reverse_each slice_before sort sort_by take take_while to_set zip == === =~ __id__ __send__ _dump class clone dclone display enum_for eql? equal? extend freeze frozen? hash initialize initialize_copy inspect instance_eval instance_exec instance_of? instance_variable_defined? instance_variable_get instance_variable_set instance_variables is_a? marshal_dump marshal_load method method_missing methods must_be must_be_close_to must_be_empty must_be_instance_of must_be_kind_of must_be_nil must_be_same_as must_be_within_epsilon must_equal must_include must_match must_raise must_respond_to must_send must_throw nil? pretty_inspect pretty_print pretty_print_cycle pretty_print_inspect pretty_print_instance_variables private_methods protected_methods public_methods remove_instance_variable respond_to? respond_to_missing? singleton_class singleton_method_added singleton_method_removed singleton_method_undefined singleton_methods taint tainted? tap to_ary to_hash to_int to_proc to_regexp to_s to_str to_yaml to_yaml_properties to_yaml_style trust untaint untrust untrusted? wont_be wont_be_close_to wont_be_empty wont_be_instance_of wont_be_kind_of wont_be_nil wont_be_same_as wont_be_within_epsilon wont_equal wont_include wont_match wont_respond_to << close each each_byte eof flush getc gets print printf puts read read_nonblock readchar readline readlines readpartial sync sync= ungetc write write_nonblock ::BLOCK_SIZE addr closed? do_not_reverse_lookup= fcntl getsockopt peeraddr setsockopt