Class: Paypal::Webhooks::X509Certificate
- Inherits:
-
Object
- Object
- Paypal::Webhooks::X509Certificate
- Defined in:
- lib/paypal/webhooks/x509_certificate.rb
Instance Method Summary collapse
- #common_name ⇒ Object
- #in_date? ⇒ Boolean
-
#initialize(data) ⇒ X509Certificate
constructor
A new instance of X509Certificate.
- #verify(algorithm:, signature:, fingerprint:) ⇒ Object
Constructor Details
#initialize(data) ⇒ X509Certificate
Returns a new instance of X509Certificate.
4 5 6 |
# File 'lib/paypal/webhooks/x509_certificate.rb', line 4 def initialize(data) @cert = OpenSSL::X509::Certificate.new(data) end |
Instance Method Details
#common_name ⇒ Object
8 9 10 |
# File 'lib/paypal/webhooks/x509_certificate.rb', line 8 def common_name @common_name ||= get_subject_entry("CN") end |
#in_date? ⇒ Boolean
12 13 14 |
# File 'lib/paypal/webhooks/x509_certificate.rb', line 12 def in_date? Util.now.between?(@cert.not_before, @cert.not_after) end |
#verify(algorithm:, signature:, fingerprint:) ⇒ Object
16 17 18 19 20 21 22 23 24 |
# File 'lib/paypal/webhooks/x509_certificate.rb', line 16 def verify(algorithm:, signature:, fingerprint:) @cert.public_key.verify_pss( algorithm, signature, fingerprint, salt_length: :auto, mgf1_hash: algorithm, ) end |