{"action":"opened","issue":{"url":"https://api.github.com/repos/auth0/node-jsonwebtoken/issues/211","repository_url":"https://api.github.com/repos/auth0/node-jsonwebtoken","labels_url":"https://api.github.com/repos/auth0/node-jsonwebtoken/issues/211/labels{/name}","comments_url":"https://api.github.com/repos/auth0/node-jsonwebtoken/issues/211/comments","events_url":"https://api.github.com/repos/auth0/node-jsonwebtoken/issues/211/events","html_url":"https://github.com/auth0/node-jsonwebtoken/issues/211","id":158370818,"number":211,"title":"Invalid signature on the key/pem pait","user":{"login":"cope","id":112515,"avatar_url":"https://avatars.githubusercontent.com/u/112515?v=3","gravatar_id":"","url":"https://api.github.com/users/cope","html_url":"https://github.com/cope","followers_url":"https://api.github.com/users/cope/followers","following_url":"https://api.github.com/users/cope/following{/other_user}","gists_url":"https://api.github.com/users/cope/gists{/gist_id}","starred_url":"https://api.github.com/users/cope/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cope/subscriptions","organizations_url":"https://api.github.com/users/cope/orgs","repos_url":"https://api.github.com/users/cope/repos","events_url":"https://api.github.com/users/cope/events{/privacy}","received_events_url":"https://api.github.com/users/cope/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2016-06-03T13:46:00Z","updated_at":"2016-06-03T13:46:00Z","closed_at":null,"body":"I've created a private/public key pair using\r\n```\r\nopenssl genrsa -out private.key 2048\r\nopenssl rsa -in private.key -pubout -out public.pem\r\n```\r\nWhen I try to sign/verify, it only works if I use the private key to both sign and verify.\r\n\r\nIf I use the public key to verify, I get the `JsonWebTokenError: invalid algorithm` error, no matter which key I used to sign.\r\n\r\nAnd if I try to do it properly: sign with the public key and verify with the private key, I get the ` JsonWebTokenError: invalid signature` error.\r\n\r\n```\r\nvar key = fs.readFileSync('ssl/private.key');\r\nvar pub = fs.readFileSync('ssl/public.pem');\r\nvar json = {\r\n\tjwtid: \"sexy2puppy-\" + new Date().getTime(),\r\n\tissuer: 'Sexy',\r\n\taudience: 'Puppy'\r\n};\r\nvar s = jsonwebtoken.sign(json, key);\t// signing with private key\r\nvar p = jsonwebtoken.sign(json, pub);\t// signing with public key\r\n\r\nconsole.log(jsonwebtoken.verify(s, key));\t// works\r\nconsole.log(jsonwebtoken.verify(s, pub));\t// invalid algorithm\r\nconsole.log(jsonwebtoken.verify(p, key));\t// invalid signature\r\nconsole.log(jsonwebtoken.verify(p, pub));\t// invalid algorithm\r\n```\r\nAm I missing something here?"}}
{"actor":{"display_login":"cope"}}