KeyLoader { public static KeyLoader fromFiles(final Vertx vertx, final String keyPath, final String certPath) { PrivateKey privateKey = null; List<Certificate> certChain = null; if (!Strings.isNullOrEmpty(keyPath)) { privateKey = loadPrivateKeyFromFile(vertx, keyPath); } if (!Strings.isNullOrEmpty(certPath)) { certChain = loadCertsFromFile(vertx, certPath); } return new KeyLoader(privateKey, certChain); } private  KeyLoader(final PrivateKey privateKey, final List<Certificate> certs); PrivateKey getPrivateKey(); Certificate[] getCertificateChain(); PublicKey getPublicKey(); static KeyLoader fromKeyStore(final Vertx vertx, final String keyStorePath, final char[] password); static KeyLoader fromFiles(final Vertx vertx, final String keyPath, final String certPath);  }
@Test public void testLoaderFailsForNonExistingKeyFile() { assertThatThrownBy(() -> KeyLoader.fromFiles(vertx, "non-existing-key.pem", PREFIX_KEY_PATH + "auth-server-cert.pem")) .isInstanceOf(IllegalArgumentException.class); }
@Test public void testLoaderFailsForNonExistingCertFile() { assertThatThrownBy(() -> KeyLoader.fromFiles(vertx, PREFIX_KEY_PATH + "auth-server-key.pem", "non-existing-cert.pem")) .isInstanceOf(IllegalArgumentException.class); }
@Test public void testLoaderPkcs1PrivateKey() { KeyLoader.fromFiles(vertx, PREFIX_KEY_PATH_2 + "pkcs1-private-key.pem", null); }