static PrivateKey loadPrivateKey(InputStream in) throws Exception {
final KeyFactory keyFactory = KeyFactory.getInstance("RSA");
final PemReader reader = new PemReader(new InputStreamReader(in));
final byte[] pubKey = reader.readPemObject().getContent();
// final X509EncodedKeySpec publicKeySpec = new
// X509EncodedKeySpec(pubKey);
reader.close();
PKCS8EncodedKeySpec publicKeySpec = new PKCS8EncodedKeySpec(pubKey);
PrivateKey publicKey = keyFactory.generatePrivate(publicKeySpec);