Class: Stomp::SSLParams

Inherits:
Object
  • Object
show all
Defined in:
lib/stomp/sslparams.rb

Overview

Purpose

Parameters for STOMP ssl connections.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(opts = {}) ⇒ SSLParams

initialize returns a valid instance of SSLParams or raises an error.



54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
# File 'lib/stomp/sslparams.rb', line 54

def initialize(opts={})

 # Server authentication parameters
 @ts_files = opts[:ts_files]   # A trust store file, normally a CA's cert
 # or a CSV list of cert file names

 # Client authentication parameters
 @cert_file = opts[:cert_file]         # Client cert file
 @key_file = opts[:key_file]           # Client key file
 @cert_text = opts[:cert_text]         # Client cert text
 @key_text = opts[:key_text]           # Client key text
 @key_password = opts[:key_password]   # Client key password
 #
 raise Stomp::Error::SSLClientParamsError if !@cert_file.nil? && @key_file.nil? && @key_text.nil?
 raise Stomp::Error::SSLClientParamsError if !@cert_text.nil? && @key_file.nil? && @key_text.nil?
 raise Stomp::Error::SSLClientParamsError if !@cert_text.nil? && !@cert_file.nil?

 raise Stomp::Error::SSLClientParamsError if !@key_file.nil? && @cert_file.nil? && @cert_text.nil?
 raise Stomp::Error::SSLClientParamsError if !@key_text.nil? && @cert_file.nil? && @cert_text.nil?
 raise Stomp::Error::SSLClientParamsError if !@key_text.nil? && !@key_file.nil?

 #
 @ciphers = opts[:ciphers]
 @use_ruby_ciphers = opts[:use_ruby_ciphers] ? opts[:use_ruby_ciphers] : false
 #
 if opts[:fsck]
  if @cert_file
   raise Stomp::Error::SSLNoCertFileError if !File::exist?(@cert_file)
   raise Stomp::Error::SSLUnreadableCertFileError if !File::readable?(@cert_file)
  end
  if @key_file
   raise Stomp::Error::SSLNoKeyFileError if !File::exist?(@key_file)
   raise Stomp::Error::SSLUnreadableKeyFileError if !File::readable?(@key_file)
  end
  if @ts_files
   tsa = @ts_files.split(",")
   tsa.each do |fn|
    raise Stomp::Error::SSLNoTruststoreFileError if !File::exist?(fn)
    raise Stomp::Error::SSLUnreadableTruststoreFileError if !File::readable?(fn)
   end
  end
 end
 # SSLContext options.  See example:  ssl_ctxoptions.rb.
 @ssl_ctxopts = opts[:ssl_ctxopts]  # nil or options to set
end

Instance Attribute Details

#cert_fileObject

The client certificate file.



16
17
18
# File 'lib/stomp/sslparams.rb', line 16

def cert_file
  @cert_file
end

#cert_textObject

The client certificate text.



22
23
24
# File 'lib/stomp/sslparams.rb', line 22

def cert_text
  @cert_text
end

#ciphersObject

Optional list of SSL ciphers to be used. In the format documented for Ruby's OpenSSL.



39
40
41
# File 'lib/stomp/sslparams.rb', line 39

def ciphers
  @ciphers
end

#ctxObject

Back reference to the OpenSSL::SSL::SSLContext instance, gem sets before connect.



45
46
47
# File 'lib/stomp/sslparams.rb', line 45

def ctx
  @ctx
end

#fsckObject (readonly)

Client wants file existance check on initialize. true/value or false/nil.



48
49
50
# File 'lib/stomp/sslparams.rb', line 48

def fsck
  @fsck
end

#key_fileObject

The client private key file.



19
20
21
# File 'lib/stomp/sslparams.rb', line 19

def key_file
  @key_file
end

#key_passwordObject

The client private key password.



28
29
30
# File 'lib/stomp/sslparams.rb', line 28

def key_password
  @key_password
end

#key_textObject

The client private key text.



25
26
27
# File 'lib/stomp/sslparams.rb', line 25

def key_text
  @key_text
end

#peer_certObject

The certificate of the connection peer (the server), received during the handshake.



35
36
37
# File 'lib/stomp/sslparams.rb', line 35

def peer_cert
  @peer_cert
end

#ssl_ctxoptsObject (readonly)

SSLContext options.



51
52
53
# File 'lib/stomp/sslparams.rb', line 51

def ssl_ctxopts
  @ssl_ctxopts
end

#ts_filesObject

The trust store files. Normally the certificate of the CA that signed the server's certificate. One file name, or a CSV list of file names.



13
14
15
# File 'lib/stomp/sslparams.rb', line 13

def ts_files
  @ts_files
end

#use_ruby_ciphersObject (readonly)

Absolute command to use Ruby default ciphers.



42
43
44
# File 'lib/stomp/sslparams.rb', line 42

def use_ruby_ciphers
  @use_ruby_ciphers
end

#verify_resultObject

SSL Connect Verify Result. The result of the handshake.



31
32
33
# File 'lib/stomp/sslparams.rb', line 31

def verify_result
  @verify_result
end