Skip to content

Instantly share code, notes, and snippets.

@elricstorm
Created June 20, 2011 03:40
Show Gist options
  • Save elricstorm/1035083 to your computer and use it in GitHub Desktop.
Save elricstorm/1035083 to your computer and use it in GitHub Desktop.
def verify_pem(cert_file, data, signature)
public_key = OpenSSL::PKey::RSA.new(cert_file)
return public_key.verify(OpenSSL::Digest::SHA1.new, Base64.decode64(signature), data)
end
def verify_pem_public(cert_file, data, signature)
public_key = OpenSSL::PKey::RSA.new(cert_file).public_key
return public_key.verify(OpenSSL::Digest::SHA1.new, Base64.decode64(signature), data)
end
def verify_x509(cert_file, data, signature)
public_key = OpenSSL::X509::Certificate.new(cert_file)
return public_key.verify(OpenSSL::Digest::SHA1.new, Base64.decode64(signature), data)
end
def verify_x509_public(cert_file, data, signature)
public_key = OpenSSL::X509::Certificate.new(cert_file).public_key
return public_key.verify(OpenSSL::Digest::SHA1.new, Base64.decode64(signature), data)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment