jwk.rb 573 Bytes
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
module Acme::Client::JWK
  # Make a JWK from a private key.
  #
  # private_key - An OpenSSL::PKey::EC or OpenSSL::PKey::RSA instance.
  #
  # Returns a JWK::Base subclass instance.
  def self.from_private_key(private_key)
    case private_key
    when OpenSSL::PKey::RSA
      Acme::Client::JWK::RSA.new(private_key)
    when OpenSSL::PKey::EC
      Acme::Client::JWK::ECDSA.new(private_key)
    else
      raise ArgumentError, 'private_key must be EC or RSA'
    end
  end
end

require 'acme/client/jwk/base'
require 'acme/client/jwk/rsa'
require 'acme/client/jwk/ecdsa'