title: JWT(JSON Web Token) generated in node.js not validated in java
body: <p>I am generating JWT using Node.js with <code>require('jsonwebtoken')</code> using public key which is generated by <code>puttygen</code> tool in windows. Then i will pass that token to other application in headers. The Other application is not developed in Node.js. Using java I need to validate the token with public key. But none of the sites i found  a valid sample to verify using public/private key.</p>
  
  <p>Can any one please provide me steps how i can load public/private key in java and verify jwt token. Please provide me examples if any you have. Thanks in advance.</p>
  
  <h2>Sample public key (public.pem) :-</h2>
  
  <pre><code>---- BEGIN SSH2 PUBLIC KEY ----
  Comment: "rsa-key-20160721"
  AAAAB3NzaC1yc2EAAAABJQAAAQEAhk1i7Jwz2M6zakReDgg0NkVPn1kK1R8qAp2p
  Ayh0eUPCb2XICDDVRnpUIK7/4k4dlLeeSi10TwwXe85zZ0gXcNMIOpnEKIWcnqJM
  ctbYwyrl2tAb/tKjvBCvHMA9ZnfNADkN6reBZq8u7kYJ3bF9PxvS3QM+vgJ8/8ZS
  qkRWcsmRZdq+wthwGt43J3NSKFfhMVP08/V/hTASq06vvFYApHsEH6zLxNNQ63Tt
  Bzedh+C5efyqYqEVqnA7S9bXimyY2ViqpqFTx1lM9dV+12dSOxd7CQzX8eo00Phi
  EAnY2hfoTooUeCO3/L6YavRl+CXgjhvA9mg4QO554qI1YCUvBw==
  ---- END SSH2 PUBLIC KEY ----
  </code></pre>
  
  <h2>Node JS code:-</h2>
  
  <pre><code>var privateKey = fs.readFileSync("public.pem");
  var userData = {username:'John'};
  var token = jwt.sign(userData, privateKey);
  </code></pre>
  
  <h2>Java Code:-</h2>
  
  <p>Needed java code which can verify above token using above public key.</p>