Sha256: e9e33e0a4ff889917907a26f7f8a6c6d39a8af8f0b8c16ec36805e7827746e5d

Contents?: true

Size: 730 Bytes

Versions: 5

Compression:

Stored size: 730 Bytes

Contents

#
# Extend the core String class to include `.to_cert` && `.to_cert!`
#
class String
  include CertMunger

  # Returns an X509 certificate after parsing the value of this object.
  # Returns false if an X509 certificate cannot be created
  def to_cert
    begin
      new_cert = self.class.send(:to_cert, self)
    rescue StandardError
      new_cert = false
    end

    new_cert
  end

  # Similar to {#to_cert}, but raises an error unless the string can be
  # explicitly parsed to an X509 certifcate
  def to_cert!
    begin
      new_cert = self.class.send(:to_cert, self)
    rescue StandardError
      raise UnparsableCertError,
            "Could not force conversion to X509:\n#{inspect}"
    end

    new_cert
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
cert_munger-1.0.0 lib/cert_munger/string.rb
cert_munger-0.2.2 lib/cert_munger/string.rb
cert_munger-0.2.1 lib/cert_munger/string.rb
cert_munger-0.2.0 lib/cert_munger/string.rb
cert_munger-0.1.1 lib/cert_munger/string.rb