title: Error signing payload (JWT, jsrsasign)
body: <p>I'm using <code>jsrsasign</code> to create JWT. Following the tutorial <a href="https://github.com/kjur/jsrsasign/wiki/Tutorial-for-JWT-generation" rel="nofollow">here</a> I did the following:</p>
  
  <pre><code>// Header
  var oHeader = {alg: 'RS256', typ: 'JWT'};
  // Payload
  var oPayload = {};
  var tNow = KJUR.jws.IntDate.get('now');
  var tEnd = KJUR.jws.IntDate.get('now + 1day');
  oPayload.iss = "http://foo.com";
  oPayload.sub = "mailto:mike@foo.com";
  oPayload.nbf = tNow;
  oPayload.iat = tNow;
  oPayload.exp = tEnd;
  oPayload.jti = "id123456";
  oPayload.aud = "http://foo.com/employee";
  
  var sHeader = JSON.stringify(oHeader);
  var sPayload = JSON.stringify(oPayload);
  
  var pbKey = KEYUTIL.getKey("-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA+bg0doaHG2Pg/WplPgc0\nstTEdPyuNqD6jhvCOLrnq01R1M8QoBgiOmKhYUJrti/hybXSqp9uTp61dGPQ4KUU\nP7r4vjwzBYXzSUiS7YfCdWbX6bY8MW7eFXf3EADgNCi6NUBsTpOwKVyJuHFMxWFy\nR2Z9Pdw4gUuCrIqWaoGARIJ0Tkf5zT99C8AuwcJ46fZqPs6cNHtUaNu/CdXcgtPA\n3iXIXBZqlBkKPaNE6ATjtIUHftZhOx0aQLUDm2skbDmDre78R7GKNXPUWknfw7xV\nMpa93zYckxjce2MYNDbvmsK4gbzwm8zxYp+o0eMobOq7xe5hy/sRFbbHOZTqQWtp\nrwIDAQAB\n-----END PUBLIC KEY-----\n");
  
  var sJWT = KJUR.jws.JWS.sign("RS256", sHeader, sPayload, pbKey);
  
  console.log(sJWT);
  </code></pre>
  
  <p>I generated the public key using the Ruby <code>jwt</code> gem as follows:</p>
  
  <pre><code>rsa_private = OpenSSL::PKey::RSA.generate 2048
  rsa_public = rsa_private.public_key
  
  public_key = rsa_public.to_pem 
  </code></pre>
  
  <p>I keep getting the following error while signing the payload:</p>
  
  <pre><code>"error"
  "Uncaught Signature: unsupported public key alg: rsa (line 24)"
  </code></pre>
  
  <p>What am I doing wrong?</p>
  
  <p>Here's the link to JS Bin: <a href="http://jsbin.com/yehiyo/edit?js,console" rel="nofollow">http://jsbin.com/yehiyo/edit?js,console</a></p>