| 121 | | @client.proxy = @options["proxy"] |
|---|
| 122 | | @options.add_hook("proxy") do |key, value| |
|---|
| 123 | | @client.proxy = value |
|---|
| 124 | | end |
|---|
| 125 | | @client.no_proxy = @options["no_proxy"] |
|---|
| 126 | | @options.add_hook("no_proxy") do |key, value| |
|---|
| 127 | | @client.no_proxy = value |
|---|
| 128 | | end |
|---|
| 129 | | if @client.respond_to?(:protocol_version=) |
|---|
| 130 | | @client.protocol_version = @options["protocol_version"] |
|---|
| 131 | | @options.add_hook("protocol_version") do |key, value| |
|---|
| 132 | | @client.protocol_version = value |
|---|
| 133 | | end |
|---|
| 134 | | end |
|---|
| 135 | | set_cookie_store_file(@options["cookie_store_file"]) |
|---|
| 136 | | @options.add_hook("cookie_store_file") do |key, value| |
|---|
| 137 | | set_cookie_store_file(value) |
|---|
| 138 | | end |
|---|
| | 121 | HTTPConfigLoader.set_options(@client, @options) |
|---|
| 148 | | ssl_config = @options["ssl_config"] ||= ::SOAP::Property.new |
|---|
| 149 | | set_ssl_config(ssl_config) |
|---|
| 150 | | ssl_config.add_hook(true) do |key, value| |
|---|
| 151 | | set_ssl_config(ssl_config) |
|---|
| 152 | | end |
|---|
| 153 | | basic_auth = @options["basic_auth"] ||= ::SOAP::Property.new |
|---|
| 154 | | set_basic_auth(basic_auth) |
|---|
| 155 | | basic_auth.add_hook do |key, value| |
|---|
| 156 | | set_basic_auth(basic_auth) |
|---|
| 157 | | end |
|---|
| 158 | | @options.add_hook("connect_timeout") do |key, value| |
|---|
| 159 | | @client.connect_timeout = value |
|---|
| 160 | | end |
|---|
| 161 | | @options.add_hook("send_timeout") do |key, value| |
|---|
| 162 | | @client.send_timeout = value |
|---|
| 163 | | end |
|---|
| 164 | | @options.add_hook("receive_timeout") do |key, value| |
|---|
| 165 | | @client.receive_timeout = value |
|---|
| 166 | | end |
|---|
| | 131 | set_cookie_store_file(@options["cookie_store_file"]) |
|---|
| | 132 | @options.add_hook("cookie_store_file") do |key, value| |
|---|
| | 133 | set_cookie_store_file(value) |
|---|
| | 134 | end |
|---|
| | 135 | ssl_config = @options["ssl_config"] |
|---|
| | 136 | basic_auth = @options["basic_auth"] |
|---|
| 181 | | end |
|---|
| 182 | | |
|---|
| 183 | | def set_ssl_config(ssl_config) |
|---|
| 184 | | ssl_config.each do |key, value| |
|---|
| 185 | | cfg = @client.ssl_config |
|---|
| 186 | | case key |
|---|
| 187 | | when 'client_cert' |
|---|
| 188 | | cfg.client_cert = cert_from_file(value) |
|---|
| 189 | | when 'client_key' |
|---|
| 190 | | cfg.client_key = key_from_file(value) |
|---|
| 191 | | when 'client_ca' |
|---|
| 192 | | cfg.client_ca = value |
|---|
| 193 | | when 'ca_path' |
|---|
| 194 | | cfg.set_trust_ca(value) |
|---|
| 195 | | when 'ca_file' |
|---|
| 196 | | cfg.set_trust_ca(value) |
|---|
| 197 | | when 'crl' |
|---|
| 198 | | cfg.set_crl(value) |
|---|
| 199 | | when 'verify_mode' |
|---|
| 200 | | cfg.verify_mode = ssl_config_int(value) |
|---|
| 201 | | when 'verify_depth' |
|---|
| 202 | | cfg.verify_depth = ssl_config_int(value) |
|---|
| 203 | | when 'options' |
|---|
| 204 | | cfg.options = value |
|---|
| 205 | | when 'ciphers' |
|---|
| 206 | | cfg.ciphers = value |
|---|
| 207 | | when 'verify_callback' |
|---|
| 208 | | cfg.verify_callback = value |
|---|
| 209 | | when 'cert_store' |
|---|
| 210 | | cfg.cert_store = value |
|---|
| 211 | | else |
|---|
| 212 | | raise ArgumentError.new("unknown ssl_config property #{key}") |
|---|
| 213 | | end |
|---|
| 214 | | end |
|---|
| 215 | | end |
|---|
| 216 | | |
|---|
| 217 | | def ssl_config_int(value) |
|---|
| 218 | | if value.nil? or value.empty? |
|---|
| 219 | | nil |
|---|
| 220 | | else |
|---|
| 221 | | begin |
|---|
| 222 | | Integer(value) |
|---|
| 223 | | rescue ArgumentError |
|---|
| 224 | | ::SOAP::Property::Util.const_from_name(value) |
|---|
| 225 | | end |
|---|
| 226 | | end |
|---|
| 227 | | end |
|---|
| 228 | | |
|---|
| 229 | | def cert_from_file(filename) |
|---|
| 230 | | OpenSSL::X509::Certificate.new(File.open(filename) { |f| f.read }) |
|---|
| 231 | | end |
|---|
| 232 | | |
|---|
| 233 | | def key_from_file(filename) |
|---|
| 234 | | OpenSSL::PKey::RSA.new(File.open(filename) { |f| f.read }) |
|---|