Class: Paypal::Webhooks::X509Certificate

Inherits:
Object
  • Object
show all
Defined in:
lib/paypal/webhooks/x509_certificate.rb

Instance Method Summary collapse

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_nameObject



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

Returns:

  • (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