class HTTPClient::JRubySSLSocket::TrustStoreLoader
Attributes
Public Class Methods
Source
# File lib/httpclient/jruby_ssl_socket.rb, line 330 def initialize @trust_store = KeyStore.getInstance('JKS') @trust_store.load(nil) @size = 0 end
Public Instance Methods
Source
# File lib/httpclient/jruby_ssl_socket.rb, line 336 def add(cert_source) return if cert_source == :default if cert_source.respond_to?(:to_pem) pem = cert_source.to_pem load_pem(pem) elsif File.directory?(cert_source) warn("#{cert_source}: directory not yet supported") return else pem = nil File.read(cert_source).each_line do |line| case line when /-----BEGIN CERTIFICATE-----/ pem = '' when /-----END CERTIFICATE-----/ load_pem(pem) # keep parsing in case where multiple certificates in a file else if pem pem << line end end end end end
Source
# File lib/httpclient/jruby_ssl_socket.rb, line 362 def trust_store if @size == 0 nil else @trust_store end end
Private Instance Methods
Source
# File lib/httpclient/jruby_ssl_socket.rb, line 372 def load_pem(pem) cert = PEMUtils.read_certificate(pem) @size += 1 @trust_store.setCertificateEntry("cert_#{@size}", cert) end