about summary refs log tree commit homepage
diff options
context:
space:
mode:
-rw-r--r--lib/yahns/server.rb7
1 files changed, 7 insertions, 0 deletions
diff --git a/lib/yahns/server.rb b/lib/yahns/server.rb
index d6a03f3..ba2066b 100644
--- a/lib/yahns/server.rb
+++ b/lib/yahns/server.rb
@@ -386,6 +386,13 @@ class Yahns::Server # :nodoc:
         env['HTTPS'] = 'on' # undocumented, but Rack::Request uses this
         env['rack.url_scheme'] = 'https'
 
+        # avoid "session id context uninitialized" errors when a client
+        # attempts to reuse a cached SSL session.  Server admins may
+        # configure their own cache and session_id_context if desired.
+        # 32 bytes is SSL_MAX_SSL_SESSION_ID_LENGTH and has been since
+        # the SSLeay days
+        ssl_ctx.session_id_context ||= OpenSSL::Random.random_bytes(32)
+
         # call OpenSSL::SSL::SSLContext#setup explicitly here to detect
         # errors and avoid race conditions.  We avoid calling this in the
         # parent process since