Sha256: 6bff3ab22acfab7a1e29cd9460bca194f343d9c08c2f6884466013eeaafd512c

Contents?: true

Size: 768 Bytes

Versions: 2

Compression:

Stored size: 768 Bytes

Contents

module Rails
  module Auth
    module X509
      module Filter
        # Extract OpenSSL::X509::Certificates from Privacy Enhanced Mail (PEM) certificates
        class Pem
          def call(pem)
            # Normalize the whitespace in the certificate to the exact format
            # certificates are normally formatted in otherwise parsing with fail
            # with a 'nested asn1 error'. split(" ") handles sequential whitespace
            # characters like \t, \n, and space.
            OpenSSL::X509::Certificate.new(pem.split(" ").instance_eval do
              [[self[0], self[1]].join(" "), self[2...-2], [self[-2], self[-1]].join(" ")]
                .flatten.join("\n")
            end).freeze
          end
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rails-auth-2.1.4 lib/rails/auth/x509/filter/pem.rb
rails-auth-2.1.3 lib/rails/auth/x509/filter/pem.rb