Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
require 'jose'
require 'faraday'
require 'fast_jsonparser'
endpoint = 'https://ext.payconiq.com/certificates'
kid = 'es.signature.ext.payconiq.com'
response = Faraday.get(endpoint, {}, { 'Accept' => 'application/json' })
keys = FastJsonparser.parse(response.body).dig(:keys)
cert = keys.filter { |c| c[:kid] == kid }.first
pem = JOSE::JWK.from(cert.to_json).to_pem
puts pem
# => Output:
# -----BEGIN PUBLIC KEY-----
# MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAE+f5wRbYRr7I6mDs7RPIjQjdTl4ar
# HZfGHSegiqLq2HOLPOzdMMIi+dyR/jfC8L4wfAW8T32Dd5zgwSw68vr2MA==
# -----END PUBLIC KEY-----
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.