class HTTPClient::JRubySSLSocket::TrustStoreLoader
Attributes
size[R]
Public Class Methods
new()
click to toggle source
# File lib/httpclient/jruby_ssl_socket.rb, line 326 def initialize @trust_store = KeyStore.getInstance('JKS') @trust_store.load(nil) @size = 0 end
Public Instance Methods
add(cert_source)
click to toggle source
# File lib/httpclient/jruby_ssl_socket.rb, line 332 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
trust_store()
click to toggle source
# File lib/httpclient/jruby_ssl_socket.rb, line 358 def trust_store if @size == 0 nil else @trust_store end end
Private Instance Methods
load_pem(pem)
click to toggle source
# File lib/httpclient/jruby_ssl_socket.rb, line 368 def load_pem(pem) cert = PEMUtils.read_certificate(pem) @size += 1 @trust_store.setCertificateEntry("cert_#{@size}", cert) end