@Override
  public Keyset read() throws IOException {
    Keyset.Builder keyset = Keyset.newBuilder();
    for (PemKey pemKey : pemKeys) {
      for (Keyset.Key key = readKey(pemKey.reader, pemKey.type);
          key != null;
          key = readKey(pemKey.reader, pemKey.type)) {
        keyset.addKey(key);
      }
    }

    if (keyset.getKeyCount() == 0) {
      throw new IOException("cannot find any key");
    }
    // Use the first key as the primary key id.
    keyset.setPrimaryKeyId(keyset.getKey(0).getKeyId());
    return keyset.build();
  }
Adds a PEM.

<p>A single PEM can contain multiple keys, but all must have the same {@code keyType}.
Invalid or unparsable keys are ignored.

<p>The first key in the first added PEM is the primary key.
java_src/src/main/java/com/google/crypto/tink/signature/SignaturePemKeysetReader.java