sslContext.setKeyStoreFile(sslProperties.getKeyStoreFile()); // contains server keypair sslContext.setKeyStorePass(sslProperties.getKeyStorePass());
sslConfig.setKeyStoreFile(new File(params.basePath, "keystore").getAbsolutePath()); sslConfig.setKeyStorePass("opentrip");
/** * Start SSL-secured HTTP test server. * * @throws IOException in case there is an error while reading server key store or trust store. * @return an instance of the started SSL-secured HTTP test server. */ public static Server start() throws IOException { // Grizzly ssl configuration SSLContextConfigurator sslContext = new SSLContextConfigurator(); // set up security context sslContext.setKeyStoreFile(KEYSTORE_SERVER_FILE); // contains server keypair sslContext.setKeyStorePass(KEYSTORE_SERVER_PWD); sslContext.setTrustStoreFile(TRUSTORE_SERVER_FILE); // contains client certificate sslContext.setTrustStorePass(TRUSTORE_SERVER_PWD); ResourceConfig rc = new ResourceConfig(); rc.registerClasses(RootResource.class, SecurityFilter.class, AuthenticationExceptionMapper.class); final HttpServer grizzlyServer = GrizzlyHttpServerFactory.createHttpServer( getBaseURI(), rc, true, new SSLEngineConfigurator(sslContext).setClientMode(false).setNeedClientAuth(true) ); // start Grizzly embedded server // LOGGER.info("Jersey app started. Try out " + BASE_URI + "\nHit CTRL + C to stop it..."); grizzlyServer.start(); return new Server(grizzlyServer); }
public void startServer() throws TelegramApiRequestException { ResourceConfig rc = new ResourceConfig(); rc.register(restApi); rc.register(JacksonFeature.class); final HttpServer grizzlyServer; if (keystoreServerFile != null && keystoreServerPwd != null) { SSLContextConfigurator sslContext = new SSLContextConfigurator(); // set up security context sslContext.setKeyStoreFile(keystoreServerFile); // contains server keypair sslContext.setKeyStorePass(keystoreServerPwd); grizzlyServer = GrizzlyHttpServerFactory.createHttpServer(getBaseURI(), rc, true, new SSLEngineConfigurator(sslContext).setClientMode(false).setNeedClientAuth(false)); } else { grizzlyServer = GrizzlyHttpServerFactory.createHttpServer(getBaseURI(), rc); } try { grizzlyServer.start(); } catch (IOException e) { throw new TelegramApiRequestException("Error starting webhook server", e); } }
static HttpServer startSecureServer() throws IOException { System.out.println("Starting server on port " + ConfigLoader.getHttpsServerPort()); ResourceConfig rc = new PackagesResourceConfig("com.kinpoint.server.grizzlyresources"); SSLContextConfigurator sslCon = new SSLContextConfigurator(); sslCon.setKeyStoreFile(ConfigLoader.getKeystoreLocation()); // contains server keypair sslCon.setKeyStorePass(ConfigLoader.getKeystorePassword()); HttpHandler hand = ContainerFactory.createContainer(HttpHandler.class, rc); HttpServer secure = GrizzlyServerFactory.createHttpServer(BASE_URI_SECURED, hand, true, new SSLEngineConfigurator(sslCon, false, false, false)); return secure; }
/** * Initialize server side SSL configuration. * * @return server side {@link SSLEngineConfigurator}. */ private static SSLEngineConfigurator createSslConfiguration() { // Initialize SSLContext configuration SSLContextConfigurator sslContextConfig = new SSLContextConfigurator(); ClassLoader cl = Server.class.getClassLoader(); // Set key store URL keystoreUrl = cl.getResource("ssltest-keystore.jks"); if (keystoreUrl != null) { sslContextConfig.setKeyStoreFile(keystoreUrl.getFile()); sslContextConfig.setKeyStorePass("changeit"); } // Create SSLEngine configurator return new SSLEngineConfigurator(sslContextConfig.createSSLContext(), false, false, false); }}
/** * Initialize server side SSL configuration. * * @return server side {@link SSLEngineConfigurator}. */ private static SSLEngineConfigurator createSslConfiguration(final String keyStoreName) { // Initialize SSLContext configuration SSLContextConfigurator sslContextConfig = new SSLContextConfigurator(); ClassLoader cl = Server.class.getClassLoader(); // Set key store URL keystoreUrl = cl.getResource(keyStoreName); if (keystoreUrl != null) { sslContextConfig.setKeyStoreFile(keystoreUrl.getFile()); sslContextConfig.setKeyStorePass("changeit"); } // Create SSLEngine configurator return new SSLEngineConfigurator(sslContextConfig.createSSLContext(), false, false, false); }}
/** * Initialize server side SSL configuration. * * @return server side {@link SSLEngineConfigurator}. */ private static SSLEngineConfigurator initializeSSL() { // Initialize SSLContext configuration SSLContextConfigurator sslContextConfig = new SSLContextConfigurator(); // Set key store ClassLoader cl = SSLEchoServer.class.getClassLoader(); URL cacertsUrl = cl.getResource("ssltest-cacerts.jks"); if (cacertsUrl != null) { sslContextConfig.setTrustStoreFile(cacertsUrl.getFile()); sslContextConfig.setTrustStorePass("changeit"); } // Set trust store URL keystoreUrl = cl.getResource("ssltest-keystore.jks"); if (keystoreUrl != null) { sslContextConfig.setKeyStoreFile(keystoreUrl.getFile()); sslContextConfig.setKeyStorePass("changeit"); } // Create SSLEngine configurator return new SSLEngineConfigurator(sslContextConfig.createSSLContext(), false, false, false); } }
/** * Initialize server side SSL configuration. * * @return server side {@link SSLEngineConfigurator}. */ private static SSLEngineConfigurator initializeSSL() { // Initialize SSLContext configuration SSLContextConfigurator sslContextConfig = new SSLContextConfigurator(); // Set key store ClassLoader cl = SSLEchoClient.class.getClassLoader(); URL cacertsUrl = cl.getResource("ssltest-cacerts.jks"); if (cacertsUrl != null) { sslContextConfig.setTrustStoreFile(cacertsUrl.getFile()); sslContextConfig.setTrustStorePass("changeit"); } // Set trust store URL keystoreUrl = cl.getResource("ssltest-keystore.jks"); if (keystoreUrl != null) { sslContextConfig.setKeyStoreFile(keystoreUrl.getFile()); sslContextConfig.setKeyStorePass("changeit"); } // Create SSLEngine configurator return new SSLEngineConfigurator(sslContextConfig.createSSLContext(), false, false, false); } }
sslCon.setKeyStoreFile(keyStoreFile); sslCon.setKeyStorePass(sslPassword);
private SSLContextConfigurator createSSLContextConfigurator() { SSLContextConfigurator sslContextConfigurator = new SSLContextConfigurator(); ClassLoader cl = getClass().getClassLoader(); // override system properties URL cacertsUrl = cl.getResource("ssltest-cacerts.jks"); if (cacertsUrl != null) { sslContextConfigurator.setTrustStoreFile(cacertsUrl.getFile()); sslContextConfigurator.setTrustStorePass("changeit"); } // override system properties URL keystoreUrl = cl.getResource("ssltest-keystore.jks"); if (keystoreUrl != null) { sslContextConfigurator.setKeyStoreFile(keystoreUrl.getFile()); sslContextConfigurator.setKeyStorePass("changeit"); } return sslContextConfigurator; }
SSLContextConfigurator sslContextConfigurator = new SSLContextConfigurator(); // set up security context sslContextConfigurator.setKeyStoreFile(configuration.getKeystore()); // contains the server keypair sslContextConfigurator.setKeyStorePass(configuration.getKeystorePassword()); sslContextConfigurator.setKeyStoreType(configuration.getKeystoreType()); sslContextConfigurator.setKeyPass(configuration.getKeystoreKeypass()); sslContextConfigurator.setTrustStoreFile(configuration.getTruststore()); // contains the list of trusted certificates sslContextConfigurator.setTrustStorePass(configuration.getTruststorePassword()); sslContextConfigurator.setTrustStoreType(configuration.getTruststoreType()); if (!sslContextConfigurator.validateConfiguration(true)) throw new Exception("Invalid SSL configuration");
@SuppressWarnings("squid:S2177") private SSLContextConfigurator getSslConfig() throws IOException { SSLContextConfigurator defaultConfig = SSLContextConfigurator.DEFAULT_CONFIG; if (!defaultConfig.validateConfiguration(true)) { String keystoreServer = createCertificateStore("keystore_server"); String truststoreServer = createCertificateStore("truststore_server"); defaultConfig.setKeyStoreFile(keystoreServer); defaultConfig.setKeyStorePass("secret"); defaultConfig.setTrustStoreFile(truststoreServer); defaultConfig.setTrustStorePass("secret"); } return defaultConfig; }
private SSLContextConfigurator getSslConfig() throws IOException { if(SSLContextConfigurator.DEFAULT_CONFIG.validateConfiguration(true)) { return SSLContextConfigurator.DEFAULT_CONFIG; } SSLContextConfigurator defaultConfig = SSLContextConfigurator.DEFAULT_CONFIG; String keystore_server = createCertificateStore("keystore_server"); String truststore_server = createCertificateStore("truststore_server"); defaultConfig.setKeyStoreFile(keystore_server); defaultConfig.setKeyStorePass("secret"); defaultConfig.setTrustStoreFile(truststore_server); defaultConfig.setTrustStorePass("secret"); return defaultConfig; }
sslContext.setKeyStoreFile(sslProperties.getKeyStoreFile()); // contains server keypair sslContext.setKeyStorePass(sslProperties.getKeyStorePass());
sslContext.setKeyStoreFile(sslProperties.getKeyStoreFile()); // contains server keypair sslContext.setKeyStorePass(sslProperties.getKeyStorePass());
private static SSLEngineConfigurator createSSLConfig() throws Exception { final SSLContextConfigurator sslContextConfigurator = new SSLContextConfigurator(); final ClassLoader cl = GrizzlyFeedableBodyGeneratorTest.class.getClassLoader(); // override system properties final URL cacertsUrl = cl.getResource("ssltest-cacerts.jks"); if (cacertsUrl != null) { sslContextConfigurator.setTrustStoreFile(cacertsUrl.getFile()); sslContextConfigurator.setTrustStorePass("changeit"); } // override system properties final URL keystoreUrl = cl.getResource("ssltest-keystore.jks"); if (keystoreUrl != null) { sslContextConfigurator.setKeyStoreFile(keystoreUrl.getFile()); sslContextConfigurator.setKeyStorePass("changeit"); } return new SSLEngineConfigurator( sslContextConfigurator.createSSLContext(false), false, false, false); }
private static SSLContextConfigurator createSSLContextConfigurator() { SSLContextConfigurator sslContextConfigurator = new SSLContextConfigurator(); ClassLoader cl = SNITest.class.getClassLoader(); // override system properties URL cacertsUrl = cl.getResource("ssltest-cacerts.jks"); if (cacertsUrl != null) { sslContextConfigurator.setTrustStoreFile(cacertsUrl.getFile()); sslContextConfigurator.setTrustStorePass("changeit"); } // override system properties URL keystoreUrl = cl.getResource("ssltest-keystore.jks"); if (keystoreUrl != null) { sslContextConfigurator.setKeyStoreFile(keystoreUrl.getFile()); sslContextConfigurator.setKeyStorePass("changeit"); } return sslContextConfigurator; } }
/** * Start REST service. */ @Override protected void startUp() { long traceId = LoggerHelpers.traceEnterWithContext(log, this.objectId, "startUp"); try { log.info("Starting REST server listening on port: {}", this.restServerConfig.getPort()); if (restServerConfig.isTlsEnabled()) { SSLContextConfigurator contextConfigurator = new SSLContextConfigurator(); contextConfigurator.setKeyStoreFile(restServerConfig.getKeyFilePath()); contextConfigurator.setKeyStorePass(JKSHelper.loadPasswordFrom(restServerConfig.getKeyFilePasswordPath())); httpServer = GrizzlyHttpServerFactory.createHttpServer(baseUri, resourceConfig, true, new SSLEngineConfigurator(contextConfigurator, false, false, false)); } else { httpServer = GrizzlyHttpServerFactory.createHttpServer(baseUri, resourceConfig, true); } } finally { LoggerHelpers.traceLeave(log, this.objectId, "startUp", traceId); } }
public void startServer() throws TelegramApiRequestException { ResourceConfig rc = new ResourceConfig(); rc.register(restApi); rc.register(JacksonFeature.class); final HttpServer grizzlyServer; if (keystoreServerFile != null && keystoreServerPwd != null) { SSLContextConfigurator sslContext = new SSLContextConfigurator(); // set up security context sslContext.setKeyStoreFile(keystoreServerFile); // contains server keypair sslContext.setKeyStorePass(keystoreServerPwd); grizzlyServer = GrizzlyHttpServerFactory.createHttpServer(getBaseURI(), rc, true, new SSLEngineConfigurator(sslContext).setClientMode(false).setNeedClientAuth(false)); } else { grizzlyServer = GrizzlyHttpServerFactory.createHttpServer(getBaseURI(), rc); } try { grizzlyServer.start(); } catch (IOException e) { throw new TelegramApiRequestException("Error starting webhook server", e); } }