Class: Acme::Client::Problem

Inherits:
Object
  • Object
show all
Defined in:
lib/acme/client/problem.rb

Constant Summary collapse

ERROR_PREFIX =
'urn:ietf:params:acme:error:'.freeze
REGISTERED_ERROR_TYPE_DESCRIPTIONS =

Registry descriptions for problem types, not fallback values for problem details.

{
  'accountDoesNotExist' => 'The request specified an account that does not exist',
  'alreadyRevoked' => 'The request specified a certificate to be revoked that has already been revoked',
  'badCSR' => 'The CSR is unacceptable (e.g., due to a short key)',
  'badNonce' => 'The client sent an unacceptable anti-replay nonce',
  'badPublicKey' => 'The JWS was signed by a public key the server does not support',
  'badRevocationReason' => 'The revocation reason provided is not allowed by the server',
  'badSignatureAlgorithm' => 'The JWS was signed with an algorithm the server does not support',
  'caa' => 'Certification Authority Authorization (CAA) records forbid the CA from issuing a certificate',
  'compound' => 'Specific error conditions are indicated in the "subproblems" array',
  'connection' => 'The server could not connect to validation target',
  'dns' => 'There was a problem with a DNS query during identifier validation',
  'externalAccountRequired' => 'The request must include a value for the "externalAccountBinding" field',
  'incorrectResponse' => "Response received didn't match the challenge's requirements",
  'invalidContact' => 'A contact URL for an account was invalid',
  'malformed' => 'The request message was malformed',
  'orderNotReady' => 'The request attempted to finalize an order that is not ready to be finalized',
  'rateLimited' => 'The request exceeds a rate limit',
  'rejectedIdentifier' => 'The server will not issue certificates for the identifier',
  'serverInternal' => 'The server experienced an internal error',
  'tls' => 'The server received a TLS error during validation',
  'unauthorized' => 'The client lacks sufficient authorization',
  'unsupportedContact' => 'A contact URL for an account used an unsupported protocol scheme',
  'unsupportedIdentifier' => 'An identifier is of an unsupported type',
  'userActionRequired' => 'Visit the "instance" URL and take actions specified there',
  'autoRenewalCanceled' => 'The short-term certificate is no longer available because the auto-renewal Order has been explicitly canceled by the IdO',
  'autoRenewalExpired' => 'The short-term certificate is no longer available because the auto-renewal Order has expired',
  'autoRenewalCancellationInvalid' => 'A request to cancel an auto-renewal Order that is not in state "valid" has been received',
  'autoRenewalRevocationNotSupported' => 'A request to revoke an auto-renewal Order has been received',
  'unknownDelegation' => 'An unknown configuration is listed in the delegation attribute of the order request',
  'onionCAARequired' => 'The CA only supports checking the CAA for Hidden Services in-band, but the client has not provided an in-band CAA',
  'alreadyReplaced' => 'The request specified a predecessor certificate that has already been marked as replaced',
  'badAttestationStatement' => 'The attestation statement is unacceptable (e.g. not signed by an attestation authority trusted by the CA)'
}.freeze

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(raw = {}) ⇒ Problem

Returns a new instance of Problem.



58
59
60
# File 'lib/acme/client/problem.rb', line 58

def initialize(raw = {})
  @raw = raw || {}
end

Instance Attribute Details

#rawObject (readonly)

Returns the value of attribute raw.



56
57
58
# File 'lib/acme/client/problem.rb', line 56

def raw
  @raw
end

Class Method Details

.from(value) ⇒ Object



45
46
47
48
49
50
51
52
53
54
# File 'lib/acme/client/problem.rb', line 45

def self.from(value)
  case value
  when nil
    nil
  when Acme::Client::Problem
    value
  when Hash
    new(value)
  end
end

Instance Method Details

#as_json(*_arguments) ⇒ Object



126
127
128
# File 'lib/acme/client/problem.rb', line 126

def as_json(*_arguments)
  to_h
end

#codeObject



66
67
68
69
70
71
# File 'lib/acme/client/problem.rb', line 66

def code
  return unless type
  return unless type.start_with?(ERROR_PREFIX)

  type[ERROR_PREFIX.length..-1]
end

#descriptionObject



109
110
111
# File 'lib/acme/client/problem.rb', line 109

def description
  REGISTERED_ERROR_TYPE_DESCRIPTIONS[code]
end

#detailObject



77
78
79
# File 'lib/acme/client/problem.rb', line 77

def detail
  fetch('detail')
end

#identifierObject



89
90
91
# File 'lib/acme/client/problem.rb', line 89

def identifier
  fetch('identifier')
end

#instanceObject



85
86
87
# File 'lib/acme/client/problem.rb', line 85

def instance
  fetch('instance')
end

#matches?(type_or_code) ⇒ Boolean

Returns:

  • (Boolean)


113
114
115
116
# File 'lib/acme/client/problem.rb', line 113

def matches?(type_or_code)
  candidate = type_or_code.to_s
  candidate == type || candidate == code || "#{ERROR_PREFIX}#{candidate}" == type
end

#messageObject



118
119
120
# File 'lib/acme/client/problem.rb', line 118

def message
  detail || title || type
end

#raw_subproblemsObject



99
100
101
# File 'lib/acme/client/problem.rb', line 99

def raw_subproblems
  fetch('subproblems')
end

#registered?Boolean Also known as: standard?

Returns:

  • (Boolean)


103
104
105
# File 'lib/acme/client/problem.rb', line 103

def registered?
  REGISTERED_ERROR_TYPE_DESCRIPTIONS.key?(code)
end

#statusObject



81
82
83
# File 'lib/acme/client/problem.rb', line 81

def status
  fetch('status')
end

#subproblemsObject



93
94
95
96
97
# File 'lib/acme/client/problem.rb', line 93

def subproblems
  return [] unless raw_subproblems.is_a?(Array)

  raw_subproblems.map { |subproblem| self.class.new(subproblem) }
end

#titleObject



73
74
75
# File 'lib/acme/client/problem.rb', line 73

def title
  fetch('title')
end

#to_hObject



122
123
124
# File 'lib/acme/client/problem.rb', line 122

def to_h
  raw
end

#typeObject



62
63
64
# File 'lib/acme/client/problem.rb', line 62

def type
  fetch('type')
end