The Crystal programming language | http://crystal-lang.org | Fund Crystal's development: http://is.gd/X7PRtI | Docs: http://crystal-lang.org/docs/ | API: http://crystal-lang.org/api/
T?
and the latter returns a (typeof(x) & T)?
)
x.as?(T)
versus x.as(T) if x.is_a?(T)
require "logger"
log = Logger.new(STDOUT)
log.level = Logger::WARN
log.debug("Created logger")
log.info("Program started")
log.warn("Nothing to do!")
getting
require "logger"
^
Error: can't find file 'logger'
I am trying to verify google/AWS jwts using their public keys but not succeeding. Would anyone know how to do so?
For eg.
the google sign ins key is at;
pp! pub_key_jwk = HTTP::Client.get "https://www.googleapis.com/oauth2/v3/certs"
pp! pub_key_pem = HTTP::Client.get "https://www.googleapis.com/oauth2/v1/certs"
and I would want to decode like this;payload, header = JWT.decode(token, pub_key_pem , JWT::Algorithm::HS256)
But I couldn't find a way to do this using https://github.com/crystal-community/jwt#usage
@jhass:m.aeshna.de , I did try to extract the keys and then use it in JWT decode, but that didn't work;
# Fetch the Google public key
pp! pub_key_jwk = HTTP::Client.get "https://www.googleapis.com/oauth2/v3/certs"
pp! pub_key_pem = HTTP::Client.get "https://www.googleapis.com/oauth2/v1/certs"
# pub_key.status_code # => 200
pp! parsed = JSON.parse(pub_key_jwk.body)
pp! key1 = parsed["keys"][0]["kid"].to_s
pp! key2 = parsed["keys"][1]["kid"].to_s
payload1, header1 = JWT.decode(id_token, key1, JWT::Algorithm::RS256)
pp! payload1
pp! header1
would throw;
2021-07-05T09:51:34.441087Z ERROR - Neither PUB or PRIV key: error:0D06B08E:asn1 encoding routines:asn1_d2i_read_bio:not enough data
Neither PUB or PRIV key: error:0D06B08E:asn1 encoding routines:asn1_d2i_read_bio:not enough data (OpenSSL::PKey::RsaError)
Is this bit of string
"-----BEGIN CERTIFICATE-----\nMIIDJjCCAg6gAwIBAgIIRAoQks63w4EwDQYJKoZIhvcNAQEFBQAwNjE0MDIGA1UE\nAxMrZmVkZXJhdGVkLXNpZ25vbi5zeXN0ZW0uZ3NlcnZpY2VhY2NvdW50Lm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iling. So I'm clear: I need the current crystal version to compile the current crystal? I user the Portalier 0.33.0 and it compiled 0.33.0 but not 0.36.1. I got an error
In src/number.cr:147:67
147 | def step(*, to limit = nil, by step, exclusive : Bool = false, &) : Nil
^
Error: duplicated argument name:
make: *** [Makefile:122: .build/crystal] Error 1
The same happened when trying to compile 1.0.0.
Thanks