summaryrefslogtreecommitdiff
path: root/ext/openssl/sample
diff options
context:
space:
mode:
Diffstat (limited to 'ext/openssl/sample')
-rw-r--r--ext/openssl/sample/echo_cli.rb5
-rw-r--r--ext/openssl/sample/echo_svr.rb12
2 files changed, 8 insertions, 9 deletions
diff --git a/ext/openssl/sample/echo_cli.rb b/ext/openssl/sample/echo_cli.rb
index 87dacaf545c..29b356a7ad4 100644
--- a/ext/openssl/sample/echo_cli.rb
+++ b/ext/openssl/sample/echo_cli.rb
@@ -26,11 +26,12 @@ end
s = TCPSocket.new(host, port)
ssl = OpenSSL::SSL::SSLSocket.new(s, ctx)
-ssl.connect
+ssl.connect # start SSL session
+ssl.sync_close = true # if true the underlying socket will be
+ # closed in SSLSocket#close. (default: false)
while line = $stdin.gets
ssl.write line
print ssl.gets
end
ssl.close
-s.close
diff --git a/ext/openssl/sample/echo_svr.rb b/ext/openssl/sample/echo_svr.rb
index e35ad12a19a..be8e10fa26c 100644
--- a/ext/openssl/sample/echo_svr.rb
+++ b/ext/openssl/sample/echo_svr.rb
@@ -51,14 +51,12 @@ else
$stderr.puts "!!! WARNING: PEER CERTIFICATE WON'T BE VERIFIED !!!"
end
-svr = TCPServer.new(port)
+tcps = TCPServer.new(port)
+ssls = OpenSSL::SSL::SSLServer.new(tcps, ctx)
loop do
- ns = svr.accept
- ssl = OpenSSL::SSL::SSLSocket.new(ns, ctx)
- ssl.accept
- while line = ssl.gets
- ssl.write line
+ ns = ssls.accept
+ while line = ns.gets
+ ns.write line
end
- ssl.close
ns.close
end