Skip to content

Instantly share code, notes, and snippets.

@ringe
Created April 20, 2012 12:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ringe/2428312 to your computer and use it in GitHub Desktop.
Save ringe/2428312 to your computer and use it in GitHub Desktop.
Signing a BrowserID client certificate
# @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