lib/app_info/certificate.rb in app-info-3.0.0.beta2 vs lib/app_info/certificate.rb in app-info-3.0.0.beta3

- old
+ new

@@ -4,10 +4,11 @@ # Certificate wrapper for # {https://docs.ruby-lang.org/en/3.0/OpenSSL/X509/Certificate.html OpenSSL::X509::Certifiate}. class Certificate # Parse Raw data into X509 cerificate wrapper # @param [String] certificate raw data + # @return [AppInfo::Certificate] def self.parse(data) cert = OpenSSL::X509::Certificate.new(data) new(cert) end @@ -115,22 +116,24 @@ when OpenSSL::PKey::DH then :dh when OpenSSL::PKey::EC then :ec end end - # return size of public key + # return length of public key # @return [Integer] - def size + # @raise NotImplementedError + def length case public_key when OpenSSL::PKey::RSA public_key.n.num_bits when OpenSSL::PKey::DSA, OpenSSL::PKey::DH public_key.p.num_bits when OpenSSL::PKey::EC - raise NotImplementedError, "key size for #{public_key.inspect} not implemented" + raise NotImplementedError, "key length for #{public_key.inspect} not implemented" end end + alias size length # return fingerprint of certificate # @return [String] def fingerprint(name = :sha256, transform: :lower, delimiter: nil) digest = OpenSSL::Digest.new(name.to_s.upcase) @@ -164,12 +167,10 @@ def method_missing(method, *args, &block) @cert.send(method.to_sym, *args, &block) || super end - def respond_to_missing?(method_name, *args) - @cert.key?(method_name.to_sym) || - @cert.respond_to?(method_name) || - super + def respond_to_missing?(method, *args) + @cert.respond_to?(method.to_sym) || super end end end