Java Code Examples for org.apache.coyote.http11.Http11NioProtocol#setSSLEnabled()

The following examples show how to use org.apache.coyote.http11.Http11NioProtocol#setSSLEnabled() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TomcatConfig.java    From singleton with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * create the https additional connection for tomcat
 */
private Connector initiateHttpsConnector(ServerProperties serverProperties) {
	Connector connector = new Connector("org.apache.coyote.http11.Http11NioProtocol");
	connector.setScheme(ConstantsTomcat.HTTPS);
	connector.setPort(serverProperties.getServerPort());
	connector.setSecure(true);
	Http11NioProtocol protocol = (Http11NioProtocol) connector.getProtocolHandler();
	protocol.setSSLEnabled(true);
	protocol.setKeystoreFile(serverProperties.getHttpsKeyStore());
	protocol.setKeystorePass(serverProperties.getHttpsKeyStorePassword());
	protocol.setKeystoreType(serverProperties.getHttpsKeyStoreType());
	protocol.setKeyPass(serverProperties.getHttpsKeyPassword());
	protocol.setKeyAlias(serverProperties.getHttpsKeyAlias());
	protocol.setMaxHttpHeaderSize(serverProperties.getMaxHttpHeaderSize());
	connector.setRedirectPort(ConstantsTomcat.REDIRECT_PORT);
	connector.setAllowTrace(serverProperties.isAllowTrace());
	return connector;
}
 
Example 2
Source File: TomcatConfig.java    From singleton with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * create the https additional connection for tomcat
 */
private Connector initiateHttpsConnector(ServerProperties serverProperties) {
	Connector connector = new Connector("org.apache.coyote.http11.Http11NioProtocol");
	connector.setScheme(ConstantsTomcat.HTTPS);
	connector.setPort(serverProperties.getServerPort());
	connector.setSecure(true);
	Http11NioProtocol protocol = (Http11NioProtocol) connector.getProtocolHandler();
	protocol.setSSLEnabled(true);
	protocol.setKeystoreFile(serverProperties.getHttpsKeyStore());
	protocol.setKeystorePass(serverProperties.getHttpsKeyStorePassword());
	protocol.setKeystoreType(serverProperties.getHttpsKeyStoreType());
	protocol.setKeyPass(serverProperties.getHttpsKeyPassword());
	protocol.setKeyAlias(serverProperties.getHttpsKeyAlias());
	protocol.setMaxHttpHeaderSize(serverProperties.getMaxHttpHeaderSize());
	connector.setRedirectPort(ConstantsTomcat.REDIRECT_PORT);
	connector.setAllowTrace(serverProperties.isAllowTrace());
	return connector;
}
 
Example 3
Source File: ServletContainerConfiguration.java    From haven-platform with Apache License 2.0 6 votes vote down vote up
/**
 * Configures ssl connector
 *
 * @return
 */
Connector createSslConnector() {
    log.info("About to start ssl connector at port {} with {} keystoreFile", tlsPort, keystoreFile);
    final String absoluteKeystoreFile = new File(keystoreFile).getAbsolutePath();

    Connector connector = new Connector("org.apache.coyote.http11.Http11NioProtocol");
    connector.setPort(tlsPort);
    connector.setSecure(true);
    connector.setScheme("https");

    Http11NioProtocol proto = (Http11NioProtocol) connector.getProtocolHandler();
    proto.setSSLEnabled(true);
    proto.setKeystoreFile(absoluteKeystoreFile);
    proto.setKeystorePass(keystorePass);
    proto.setKeystoreType("PKCS12");
    proto.setSslProtocol("TLSv1.2");
    proto.setKeyAlias("tomcat");
    return connector;
}
 
Example 4
Source File: TomcatConfiguration.java    From odata with Apache License 2.0 6 votes vote down vote up
private Connector createSslConnector() {
    Connector connector = new Connector("org.apache.coyote.http11.Http11NioProtocol");
    Http11NioProtocol protocol = (Http11NioProtocol) connector.getProtocolHandler();
    try {
        File keystore = new ClassPathResource(keystorePath).getFile();
        connector.setScheme(HTTPS_SCHEME);
        connector.setSecure(true);
        connector.setPort(Integer.parseInt(httpsPort));
        protocol.setSSLEnabled(true);
        protocol.setKeystoreFile(keystore.getAbsolutePath());
        protocol.setKeystorePass(keystorePasswd);
        protocol.setTruststoreFile(keystore.getAbsolutePath());
        protocol.setTruststorePass(truststorePasswd);
        protocol.setKeyAlias(keyAlias);
        return connector;
    } catch (IOException ex) {
        throw new IllegalStateException("cant access keystore: [" + "keystore"
                + "] or truststore: [" + "keystore" + "]", ex);
    }
}
 
Example 5
Source File: TomcatConfig.java    From tailstreamer with MIT License 6 votes vote down vote up
private Connector createSslConnector() {
    if (sslConfig == null) {
        throw new IllegalStateException("SSL configuration not specified");
    }

    Connector connector = new Connector("org.apache.coyote.http11.Http11NioProtocol");
    Http11NioProtocol protocol = (Http11NioProtocol) connector.getProtocolHandler();
    connector.setScheme("https");
    connector.setSecure(true);
    connector.setPort(sslConfig.getPort());
    protocol.setSSLEnabled(sslConfig.isEnable());
    protocol.setKeystoreFile(sslConfig.getKeystore());
    protocol.setKeystorePass(sslConfig.getKeystorePassword());
    protocol.setKeyAlias(sslConfig.getKeyAlias());

    logger.info(String.format("Initializing SSL connector on port %d", sslConfig.getPort()));
    return connector;
}
 
Example 6
Source File: HttpProxyContainer.java    From odo with Apache License 2.0 6 votes vote down vote up
private Connector createSslConnector() {
    Connector connector = new Connector("org.apache.coyote.http11.Http11NioProtocol");
    Http11NioProtocol protocol = (Http11NioProtocol) connector.getProtocolHandler();
    final int httpsPort = Utils.getSystemPort(Constants.SYS_HTTPS_PORT);
    try {
        File keyStore = com.groupon.odo.proxylib.Utils.copyResourceToLocalFile("tomcat.ks", "tomcat.ks");
        connector.setScheme("https");
        connector.setSecure(true);
        connector.setPort(httpsPort);
        protocol.setSSLEnabled(true);
        protocol.setSslProtocol("TLS");
        protocol.setKeystoreFile(keyStore.getAbsolutePath());
        protocol.setKeystorePass("changeit");
        return connector;
    } catch (IOException ex) {
        throw new IllegalStateException("can't access keystore: [" + "keystore"
                                            + "] or truststore: [" + "keystore" + "]", ex);
    } catch (Exception e) {
        e.printStackTrace();
    }
    return null;
}
 
Example 7
Source File: TomcatConfig.java    From enhanced-pet-clinic with Apache License 2.0 6 votes vote down vote up
private Connector createSslConnector() {
	Connector connector = new Connector("org.apache.coyote.http11.Http11NioProtocol");
	Http11NioProtocol protocol = (Http11NioProtocol) connector.getProtocolHandler();
	try {
		connector.setScheme("https");
		connector.setSecure(true);
		connector.setPort(tlsPort);

		File keystore = getKeyStoreFile();
		File truststore = keystore;

		protocol.setSSLEnabled(true);
		protocol.setKeystoreFile(keystore.getAbsolutePath());
		protocol.setKeystorePass(sslKeystorePassword);
		protocol.setTruststoreFile(truststore.getAbsolutePath());
		protocol.setTruststorePass(sslKeystorePassword);
		protocol.setKeyAlias(sslKeystoreAlias);
		return connector;
	} catch (IOException ex) {
		throw new IllegalStateException(
				"can't access keystore: [" + "keystore" + "] or truststore: [" + "keystore" + "]", ex);
	}
}
 
Example 8
Source File: HttpsConfiguration.java    From spring-boot with Apache License 2.0 5 votes vote down vote up
public Connector createSslConnector() {

        Connector connector = new Connector("org.apache.coyote.http11.Http11NioProtocol");
        Http11NioProtocol protocol = (Http11NioProtocol) connector.getProtocolHandler();

        connector.setPort(properties.getPort());
        connector.setScheme("https");
        connector.setSecure(true);
        protocol.setSSLEnabled(true);
        protocol.setClientAuth("false");
        protocol.setSSLProtocol("TLSv1+TLSv1.1+TLSv1.2");
        protocol.setKeystoreFile(properties.getKeystoreFile());
        protocol.setKeystorePass(properties.getKeystorePassword());
        return connector;
    }