Class: Occi::Api::Client::Http::AuthnPlugins::X509
- Defined in:
- lib/occi/api/client/http/authn_plugins/x509.rb
Instance Attribute Summary
Attributes inherited from Base
#env_ref, #fallbacks, #options
Instance Method Summary collapse
-
#initialize(env_ref, options = {}) ⇒ X509
constructor
A new instance of X509.
- #setup(options = {}) ⇒ Object
Methods inherited from Base
Constructor Details
#initialize(env_ref, options = {}) ⇒ X509
Returns a new instance of X509.
7 8 9 10 |
# File 'lib/occi/api/client/http/authn_plugins/x509.rb', line 7 def initialize(env_ref, = {}) super env_ref, @fallbacks = %w(keystone) end |
Instance Method Details
#setup(options = {}) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/occi/api/client/http/authn_plugins/x509.rb', line 12 def setup( = {}) # set up pem and optionally pem_password and ssl_ca_path raise ArgumentError, "Missing required option 'user_cert' for x509 auth!" unless [:user_cert] raise ArgumentError, "The file specified in 'user_cert' does not exist!" unless File.exists? [:user_cert] # handle credentials, separate PKCS12 from PEM cert_content = File.open([:user_cert], 'rb').read if /\A(.)+\.p12\z/ =~ [:user_cert] @env_ref.class.pkcs12 cert_content, [:user_cert_password] else @env_ref.class.pem cert_content, [:user_cert_password] end @env_ref.class.ssl_ca_path [:ca_path] if [:ca_path] @env_ref.class.ssl_ca_file [:ca_file] if [:ca_file] if [:voms] cert_ary = ::Occi::Api::Client::AuthnUtils.certs_to_file_ary [:user_cert] # remove the first cert since it was already used as pem_cert # use the rest to establish the chain of trust cert_ary.shift @env_ref.class.ssl_extra_chain_cert cert_ary unless cert_ary.empty? end end |