Method: EventMachine::Connection#start_tls
- Defined in:
- lib/em/connection.rb
#start_tls(args = {}) ⇒ Object
TODO:
support passing an encryption parameter, which can be string or Proc, to get a passphrase
TODO:
support passing key material via raw strings or Procs that return strings instead of
Call #start_tls at any point to initiate TLS encryption on connected streams. The method is smart enough to know whether it should perform a server-side or a client-side handshake. An appropriate place to call #start_tls is in your redefined #post_init method, or in the #connection_completed handler for an outbound connection.
for encrypted private keys. just filenames.
417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 |
# File 'lib/em/connection.rb', line 417 def start_tls args={} priv_key = args[:private_key_file] cert_chain = args[:cert_chain_file] verify_peer = args[:verify_peer] sni_hostname = args[:sni_hostname] cipher_list = args[:cipher_list] ssl_version = args[:ssl_version] ecdh_curve = args[:ecdh_curve] dhparam = args[:dhparam] fail_if_no_peer_cert = args[:fail_if_no_peer_cert] [priv_key, cert_chain].each do |file| next if file.nil? or file.empty? raise FileNotFoundException, "Could not find #{file} for start_tls" unless File.exist? file end protocols_bitmask = 0 if ssl_version.nil? protocols_bitmask |= EventMachine::EM_PROTO_TLSv1 protocols_bitmask |= EventMachine::EM_PROTO_TLSv1_1 protocols_bitmask |= EventMachine::EM_PROTO_TLSv1_2 else [ssl_version].flatten.each do |p| case p.to_s.downcase when 'sslv2' protocols_bitmask |= EventMachine::EM_PROTO_SSLv2 when 'sslv3' protocols_bitmask |= EventMachine::EM_PROTO_SSLv3 when 'tlsv1' protocols_bitmask |= EventMachine::EM_PROTO_TLSv1 when 'tlsv1_1' protocols_bitmask |= EventMachine::EM_PROTO_TLSv1_1 when 'tlsv1_2' protocols_bitmask |= EventMachine::EM_PROTO_TLSv1_2 else raise("Unrecognized SSL/TLS Protocol: #{p}") end end end EventMachine::set_tls_parms(@signature, priv_key || '', cert_chain || '', verify_peer, fail_if_no_peer_cert, sni_hostname || '', cipher_list || '', ecdh_curve || '', dhparam || '', protocols_bitmask) EventMachine::start_tls @signature end |