Created
April 20, 2012 12:58
-
-
Save ringe/2428312 to your computer and use it in GitHub Desktop.
Signing a BrowserID client certificate
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# @private_key is an OpenSSL private key | |
# params is Rack request params, or Rails params | |
expiration = (Time.now.strftime("%s").to_i + params["duration"].to_i) * 1000 | |
issue = { "iss" => "example.org", | |
"exp" => expiration, | |
"public-key" => params["pubkey"], | |
"principal" => { "email"=> "mormor@example.org" } | |
} | |
jwt = JSON::JWT.new(issue) | |
jws = jwt.sign(@private_key, :RS256) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment