code: public static KeyStore loadCertificates(final File pemFile)
  	{
  		try (final PemReader pem = new PemReader(new FileReader(pemFile)))
  		{
  			final KeyStore ks = createEmptyKeyStore();
  
  			int certIndex = 0;
  			Object obj;
  			while ((obj = parse(pem.readPemObject())) != null)
  			{
  				if (obj instanceof Certificate)
  				{
  					final Certificate cert = (Certificate) obj;
  
  					ks.setCertificateEntry("cert" + Integer.toString(certIndex++), cert);
  				}
  				else
  				{
  					throw new RuntimeException("Unknown PEM contents: " + obj + ". Expected a Certificate");
  				}
  			}
  
  			return ks;
  		}
  		catch (Exception e)
  		{
  			throw new RuntimeException("Error parsing PEM " + pemFile, e);
  		}
  	}
docs: Load one or more X.509 Certificates from a PEM file
  
  @param pemFile
  A PKCS8 PEM file containing only <code>CERTIFICATE</code> / <code>X.509 CERTIFICATE</code> blocks
  
  @return a JKS KeyStore with the certificate aliases "cert<code>index</code>" where index is the 0-based index of the
  certificate in the PEM
  
  @throws RuntimeException
  if a problem occurs