Sha256: 4a9d87ebce5aa926e35c8fd642ffdd594f7a8d4d9f6fea2ba1653bdbf77af39a
Contents?: true
Size: 1.45 KB
Versions: 24
Compression:
Stored size: 1.45 KB
Contents
# encoding: utf-8 # frozen_string_literal: true require 'fileutils' module Billy # This class is dedicated to the generation of a certificate chain in the # PEM format. Fortunately we just have to concatenate the given certificates # in the given order and write them to temporary file which will last until # the current process terminates. # # We do not have to generate a certificate chain to make puffing billy work # on modern browser like Chrome 59+ or Firefox 55+, but its good to ship it # anyways. This mimics the behaviour of the mighty mitmproxy. class CertificateChain include Billy::CertificateHelpers attr_reader :certificates, :domain # Just pass all certificates into the new instance. We use the variadic # argument feature here to ease the usage and improve the readability. # # Example: # # certs_chain_file = Billy::CertificateChain.new('localhost', # cert1, # cert2, ..).file def initialize(domain, *certs) @domain = domain @certificates = [certs].flatten end # Write out the certificates chain file and pass the path back. This will # produce a temporary file which will be remove after the current process # terminates. def file contents = certificates.map { |cert| cert.to_pem }.join write_file("chain-#{domain}.pem", contents) end end end
Version data entries
24 entries across 24 versions & 1 rubygems