class HTTPClient::JRubySSLSocket::KeyStoreLoader

Constants

PASSWORD

Public Class Methods

new() click to toggle source
# File lib/httpclient/jruby_ssl_socket.rb, line 287
def initialize
  @keystore = KeyStore.getInstance('JKS')
  @keystore.load(nil)
end

Public Instance Methods

add(cert_file, key_file, password) click to toggle source
# File lib/httpclient/jruby_ssl_socket.rb, line 292
def add(cert_file, key_file, password)
  cert_str = cert_file.respond_to?(:to_pem) ? cert_file.to_pem : File.read(cert_file.to_s)
  cert = PEMUtils.read_certificate(cert_str)
  @keystore.setCertificateEntry('client_cert', cert)
  key_str = key_file.respond_to?(:to_pem) ? key_file.to_pem : File.read(key_file.to_s)
  key_pair = PEMUtils.read_private_key(key_str, password)
  @keystore.setKeyEntry('client_key', key_pair.getPrivate, PASSWORD, [cert].to_java(Certificate))
end
keystore() click to toggle source
# File lib/httpclient/jruby_ssl_socket.rb, line 301
def keystore
  @keystore
end