From 622e71b515e34393dc8be072f464bbe75cea9566 Mon Sep 17 00:00:00 2001 From: Kazuki Yamaguchi Date: Sun, 8 May 2016 16:14:50 +0900 Subject: examples/static_server: call ctx.tmp_ecdh_callback only when needed Same as the previous commit. --- examples/static_server.rb | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/examples/static_server.rb b/examples/static_server.rb index e468b7e..a56cffa 100644 --- a/examples/static_server.rb +++ b/examples/static_server.rb @@ -26,9 +26,11 @@ ctx.alpn_select_cb = -> protocols { raise "Client does not support HTTP/2: #{protocols}" unless protocols.include?("h2") "h2" } -ctx.tmp_ecdh_callback = -> (sock, ise, keyl) { - OpenSSL::PKey::EC.new("prime256v1") -} +if ctx.respond_to?(:tmp_ecdh_callback) && !ctx.respond_to?(:set_ecdh_curves) + ctx.tmp_ecdh_callback = -> (sock, ise, keyl) { + OpenSSL::PKey::EC.new("prime256v1") + } +end ctx.cert = OpenSSL::X509::Certificate.new File.read(".crt.local") ctx.key = OpenSSL::PKey::RSA.new File.read(".key.local") tcp_server = TCPServer.new("0.0.0.0", 40443) -- cgit v1.2.3