code: public static ApnsVerificationKey loadFromInputStream(final InputStream inputStream, final String teamId, final String keyId) throws IOException, NoSuchAlgorithmException, InvalidKeyException {
          final ECPublicKey verificationKey;
          {
              final String base64EncodedPublicKey;
              {
                  final StringBuilder publicKeyBuilder = new StringBuilder();
  
                  final BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));
                  boolean haveReadHeader = false;
                  boolean haveReadFooter = false;
  
                  for (String line; (line = reader.readLine()) != null; ) {
                      if (!haveReadHeader) {
                          if (line.contains("BEGIN PUBLIC KEY")) {
                              haveReadHeader = true;
                          }
                      } else {
                          if (line.contains("END PUBLIC KEY")) {
                              haveReadFooter = true;
                              break;
                          } else {
                              publicKeyBuilder.append(line);
                          }
                      }
                  }
  
                  if (!(haveReadHeader && haveReadFooter)) {
                      throw new IOException("Could not find public key header/footer");
                  }
  
                  base64EncodedPublicKey = publicKeyBuilder.toString();
              }
  
              final byte[] keyBytes = decodeBase64EncodedString(base64EncodedPublicKey);
  
              final X509EncodedKeySpec keySpec = new X509EncodedKeySpec(keyBytes);
              final KeyFactory keyFactory = KeyFactory.getInstance("EC");
  
              try {
                  verificationKey = (ECPublicKey) keyFactory.generatePublic(keySpec);
              } catch (InvalidKeySpecException e) {
                  throw new InvalidKeyException(e);
              }
          }
  
          return new ApnsVerificationKey(keyId, teamId, verificationKey);
      }
docs: Loads a verification key from the given input stream.
  
  @param inputStream the input stream from which to load the key
  @param teamId the ten-character, Apple-issued identifier for the team to which the key belongs
  @param keyId the ten-character, Apple-issued identitifier for the key itself
  
  @return an APNs verification key with the given key ID and associated with the given team
  
  @throws IOException if a key could not be loaded from the given file for any reason
  @throws NoSuchAlgorithmException if the JVM does not support elliptic curve keys
  @throws InvalidKeyException if the loaded key is invalid for any reason