lib/certmeister/base.rb in certmeister-0.0.2 vs lib/certmeister/base.rb in certmeister-0.1.0
- old
+ new
@@ -13,11 +13,12 @@
@ca_cert = config.ca_cert
@ca_key = config.ca_key
@store = config.store
@openssl_digest = config.openssl_digest
else
- raise RuntimeError.new("invalid config")
+ reasons = config.errors.map { |kv| kv.join(' ') }
+ raise RuntimeError.new("invalid config: #{reasons.join('; ')}")
end
end
def sign(request)
subject_to_policy(@sign_policy, request) do |request|
@@ -37,16 +38,24 @@
end
end
def fetch(request)
subject_to_policy(@fetch_policy, request) do |request|
- Certmeister::Response.new(@store.fetch(request[:cn]), nil)
+ if pem = @store.fetch(request[:cn])
+ Certmeister::Response.hit(pem)
+ else
+ Certmeister::Response.miss
+ end
end
end
def remove(request)
subject_to_policy(@remove_policy, request) do |request|
- Certmeister::Response.new(!!@store.remove(request[:cn]), nil)
+ if @store.remove(request[:cn])
+ Certmeister::Response.hit
+ else
+ Certmeister::Response.miss
+ end
end
end
private