Class: Acme::Client::Crypto
- Inherits:
-
Object
- Object
- Acme::Client::Crypto
- Defined in:
- lib/acme/client/crypto.rb
Instance Attribute Summary collapse
-
#private_key ⇒ Object
readonly
Returns the value of attribute private_key.
Instance Method Summary collapse
- #digest ⇒ Object
- #generate_signed_jws(header:, payload:) ⇒ Object
-
#initialize(private_key) ⇒ Crypto
constructor
A new instance of Crypto.
- #thumbprint ⇒ Object
Constructor Details
#initialize(private_key) ⇒ Crypto
Returns a new instance of Crypto.
4 5 6 |
# File 'lib/acme/client/crypto.rb', line 4 def initialize(private_key) @private_key = private_key end |
Instance Attribute Details
#private_key ⇒ Object (readonly)
Returns the value of attribute private_key.
2 3 4 |
# File 'lib/acme/client/crypto.rb', line 2 def private_key @private_key end |
Instance Method Details
#digest ⇒ Object
20 21 22 |
# File 'lib/acme/client/crypto.rb', line 20 def digest OpenSSL::Digest::SHA256.new end |
#generate_signed_jws(header:, payload:) ⇒ Object
8 9 10 11 12 13 14 |
# File 'lib/acme/client/crypto.rb', line 8 def generate_signed_jws(header:, payload:) jwt = JSON::JWT.new(payload || {}) jwt.header.merge!(header || {}) jwt.header[:jwk] = jwk jwt.signature = jwt.sign(private_key, :RS256).signature jwt.to_json(syntax: :flattened) end |
#thumbprint ⇒ Object
16 17 18 |
# File 'lib/acme/client/crypto.rb', line 16 def thumbprint jwk.thumbprint end |