Created
June 20, 2011 03:40
-
-
Save elricstorm/1035083 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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