/** * Returns a function that maps SNI server names to a {@link TrustManagerFactory} instance. * * The returned {@code TrustManagerFactory} must already be initialized and ready to use. * * The mapper is only used when the server has SNI enabled and the client indicated a server name. * <p/> * The returned function may return {@code null} in which case {@link #getTrustManagerFactory(Vertx)} is used as fallback. * * @param vertx the vertx instance * @return the trustManager */ default Function<String, TrustManager[]> trustManagerMapper(Vertx vertx) throws Exception { KeyStoreHelper helper = KeyStoreHelper.create((VertxInternal) vertx, this); return helper != null ? helper::getTrustMgr : null; } }
/** * Returns a function that maps SNI server names to {@link X509KeyManager} instance. * * The returned {@code X509KeyManager} must satisfies these rules: * * <ul> * <li>{@link X509KeyManager#getPrivateKey(String)} returns the private key for the indicated server name, * the {@code alias} parameter will be {@code null}.</li> * <li>{@link X509KeyManager#getCertificateChain(String)} returns the certificate chain for the indicated server name, * the {@code alias} parameter will be {@code null}.</li> * </ul> * * The mapper is only used when the server has SNI enabled and the client indicated a server name. * <p> * The returned function may return null in which case the default key manager provided by {@link #getKeyManagerFactory(Vertx)} * will be used. * */ default Function<String, X509KeyManager> keyManagerMapper(Vertx vertx) throws Exception { KeyStoreHelper helper = KeyStoreHelper.create((VertxInternal) vertx, this); return helper::getKeyMgr; } }
/** * Create and return the trust manager factory for these options. * <p> * The returned trust manager factory should be already initialized and ready to use. * * @param vertx the vertx instance * @return the trust manager factory */ default TrustManagerFactory getTrustManagerFactory(Vertx vertx) throws Exception { return KeyStoreHelper.create((VertxInternal) vertx, this).getTrustMgrFactory((VertxInternal) vertx); }
/** * Create and return the key manager factory for these options. * <p> * The returned key manager factory should be already initialized and ready to use. * * @param vertx the vertx instance * @return the key manager factory */ default KeyManagerFactory getKeyManagerFactory(Vertx vertx) throws Exception { return KeyStoreHelper.create((VertxInternal) vertx, this).getKeyMgrFactory(); }
public static KeyStoreHelper create(VertxInternal vertx, TrustOptions options) throws Exception { if (options instanceof KeyCertOptions) { return create(vertx, (KeyCertOptions) options); } else if (options instanceof PemTrustOptions) { PemTrustOptions trustOptions = (PemTrustOptions) options; Stream<Buffer> certValues = trustOptions. getCertPaths(). stream(). map(path -> vertx.resolveFile(path).getAbsolutePath()). map(vertx.fileSystem()::readFileBlocking); certValues = Stream.concat(certValues, trustOptions.getCertValues().stream()); return new KeyStoreHelper(loadCA(certValues), null); } else { return null; } }
private void testTrustStore(TrustOptions options) throws Exception { KeyStoreHelper helper = KeyStoreHelper.create((VertxInternal) vertx, options); TrustManager[] keyManagers = helper.getTrustMgrs((VertxInternal) vertx); assertTrue(keyManagers.length > 0); }
private void testKeyStore(KeyCertOptions options) throws Exception { KeyStoreHelper helper = KeyStoreHelper.create((VertxInternal) vertx, options); KeyStore keyStore = helper.store(); Enumeration<String> aliases = keyStore.aliases(); assertTrue(aliases.hasMoreElements()); KeyManager[] keyManagers = helper.getKeyMgr(); assertTrue(keyManagers.length > 0); }
/** * Returns a function that maps SNI server names to a {@link TrustManagerFactory} instance. * * The returned {@code TrustManagerFactory} must already be initialized and ready to use. * * The mapper is only used when the server has SNI enabled and the client indicated a server name. * <p/> * The returned function may return {@code null} in which case {@link #getTrustManagerFactory(Vertx)} is used as fallback. * * @param vertx the vertx instance * @return the trustManager */ default Function<String, TrustManager[]> trustManagerMapper(Vertx vertx) throws Exception { KeyStoreHelper helper = KeyStoreHelper.create((VertxInternal) vertx, this); return helper != null ? helper::getTrustMgr : null; } }
/** * Returns a function that maps SNI server names to {@link X509KeyManager} instance. * * The returned {@code X509KeyManager} must satisfies these rules: * * <ul> * <li>{@link X509KeyManager#getPrivateKey(String)} returns the private key for the indicated server name, * the {@code alias} parameter will be {@code null}.</li> * <li>{@link X509KeyManager#getCertificateChain(String)} returns the certificate chain for the indicated server name, * the {@code alias} parameter will be {@code null}.</li> * </ul> * * The mapper is only used when the server has SNI enabled and the client indicated a server name. * <p> * The returned function may return null in which case the default key manager provided by {@link #getKeyManagerFactory(Vertx)} * will be used. * */ default Function<String, X509KeyManager> keyManagerMapper(Vertx vertx) throws Exception { KeyStoreHelper helper = KeyStoreHelper.create((VertxInternal) vertx, this); return helper::getKeyMgr; } }
/** * Create and return the trust manager factory for these options. * <p> * The returned trust manager factory should be already initialized and ready to use. * * @param vertx the vertx instance * @return the trust manager factory */ default TrustManagerFactory getTrustManagerFactory(Vertx vertx) throws Exception { return KeyStoreHelper.create((VertxInternal) vertx, this).getTrustMgrFactory((VertxInternal) vertx); }
/** * Create and return the key manager factory for these options. * <p> * The returned key manager factory should be already initialized and ready to use. * * @param vertx the vertx instance * @return the key manager factory */ default KeyManagerFactory getKeyManagerFactory(Vertx vertx) throws Exception { return KeyStoreHelper.create((VertxInternal) vertx, this).getKeyMgrFactory(); }
public static KeyStoreHelper create(VertxInternal vertx, TrustOptions options) throws Exception { if (options instanceof KeyCertOptions) { return create(vertx, (KeyCertOptions) options); } else if (options instanceof PemTrustOptions) { PemTrustOptions trustOptions = (PemTrustOptions) options; Stream<Buffer> certValues = trustOptions. getCertPaths(). stream(). map(path -> vertx.resolveFile(path).getAbsolutePath()). map(vertx.fileSystem()::readFileBlocking); certValues = Stream.concat(certValues, trustOptions.getCertValues().stream()); return new KeyStoreHelper(loadCA(certValues), null); } else { return null; } }
private void testTrustStore(TrustOptions options) throws Exception { KeyStoreHelper helper = KeyStoreHelper.create((VertxInternal) vertx, options); TrustManager[] keyManagers = helper.getTrustMgrs((VertxInternal) vertx); assertTrue(keyManagers.length > 0); }
private void testKeyStore(KeyCertOptions options) throws Exception { KeyStoreHelper helper = KeyStoreHelper.create((VertxInternal) vertx, options); KeyStore keyStore = helper.store(); Enumeration<String> aliases = keyStore.aliases(); assertTrue(aliases.hasMoreElements()); KeyManager[] keyManagers = helper.getKeyMgr(); assertTrue(keyManagers.length > 0); }
KeyStoreHelper ksHelper = KeyStoreHelper.create((VertxInternal) vertx, ksOptions); if (ksHelper == null) { throw new VertxException("No key pair store configured");