code: @CheckForNull
      public static PrivateKey loadPrivateKey(final Reader reader) throws IOException, NoSuchAlgorithmException,
              InvalidKeySpecException {
          try (PEMParser pemParser = new PEMParser(reader)) {
              Object readObject = pemParser.readObject();
              while (readObject != null) {
                  PrivateKeyInfo privateKeyInfo = getPrivateKeyInfoOrNull(readObject);
                  if (privateKeyInfo != null) {
                      return new JcaPEMKeyConverter().getPrivateKey(privateKeyInfo);
                  }
                  readObject = pemParser.readObject();
              }
          }
  
          return null;
      }
docs: Return private key ("key.pem") from Reader