Class: RubyTls::SSL::Context
- Inherits:
-
Object
- Object
- RubyTls::SSL::Context
- Defined in:
- lib/ruby-tls/ssl.rb
Constant Summary collapse
- CIPHERS =
'ECDHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-RC4-SHA:ECDHE-RSA-AES128-SHA:AES128-GCM-SHA256:RC4:HIGH:!MD5:!aNULL:!EDH:!CAMELLIA:@STRENGTH'.freeze
- SESSION =
'ruby-tls'.freeze
Instance Attribute Summary collapse
-
#is_server ⇒ Object
readonly
Returns the value of attribute is_server.
-
#ssl_ctx ⇒ Object
readonly
Returns the value of attribute ssl_ctx.
Instance Method Summary collapse
- #cleanup ⇒ Object
-
#initialize(server, options = {}) ⇒ Context
constructor
A new instance of Context.
Constructor Details
#initialize(server, options = {}) ⇒ Context
Returns a new instance of Context.
265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 |
# File 'lib/ruby-tls/ssl.rb', line 265 def initialize(server, = {}) @is_server = server @ssl_ctx = SSL.SSL_CTX_new(server ? SSL.SSLv23_server_method : SSL.SSLv23_client_method) SSL.SSL_CTX_set_options(@ssl_ctx, SSL::SSL_OP_ALL) SSL.SSL_CTX_set_mode(@ssl_ctx, SSL::SSL_MODE_RELEASE_BUFFERS) if @is_server set_private_key([:private_key] || SSL::DEFAULT_PRIVATE) set_certificate([:cert_chain] || SSL::DEFAULT_CERT) end SSL.SSL_CTX_set_cipher_list(@ssl_ctx, [:ciphers] || CIPHERS) if @is_server SSL.SSL_CTX_sess_set_cache_size(@ssl_ctx, 128) SSL.SSL_CTX_set_session_id_context(@ssl_ctx, SESSION, 8) else set_private_key([:private_key]) set_certificate([:cert_chain]) end # TODO:: Check for ALPN support end |
Instance Attribute Details
#is_server ⇒ Object (readonly)
Returns the value of attribute is_server.
296 297 298 |
# File 'lib/ruby-tls/ssl.rb', line 296 def is_server @is_server end |
#ssl_ctx ⇒ Object (readonly)
Returns the value of attribute ssl_ctx.
297 298 299 |
# File 'lib/ruby-tls/ssl.rb', line 297 def ssl_ctx @ssl_ctx end |
Instance Method Details
#cleanup ⇒ Object
289 290 291 292 293 294 |
# File 'lib/ruby-tls/ssl.rb', line 289 def cleanup if @ssl_ctx SSL.SSL_CTX_free(@ssl_ctx) @ssl_ctx = nil end end |