Search in sources :

Example 1 with SSLHostConfig

use of org.apache.tomcat.util.net.SSLHostConfig in project tomcat by apache.

the class ConnectorSF method storeChildren.

@Override
public void storeChildren(PrintWriter aWriter, int indent, Object aConnector, StoreDescription parentDesc) throws Exception {
    if (aConnector instanceof Connector) {
        Connector connector = (Connector) aConnector;
        // Store nested <Listener> elements
        LifecycleListener[] listeners = connector.findLifecycleListeners();
        storeElementArray(aWriter, indent, listeners);
        // Store nested <UpgradeProtocol> elements
        UpgradeProtocol[] upgradeProtocols = connector.findUpgradeProtocols();
        storeElementArray(aWriter, indent, upgradeProtocols);
        // Store nested <SSLHostConfig> elements
        SSLHostConfig[] hostConfigs = connector.findSslHostConfigs();
        storeElementArray(aWriter, indent, hostConfigs);
    }
}
Also used : Connector(org.apache.catalina.connector.Connector) UpgradeProtocol(org.apache.coyote.UpgradeProtocol) LifecycleListener(org.apache.catalina.LifecycleListener) SSLHostConfig(org.apache.tomcat.util.net.SSLHostConfig)

Example 2 with SSLHostConfig

use of org.apache.tomcat.util.net.SSLHostConfig in project tomcat by apache.

the class AbstractHttp11Protocol method registerDefaultSSLHostConfig.

private void registerDefaultSSLHostConfig() {
    if (defaultSSLHostConfig == null) {
        defaultSSLHostConfig = new SSLHostConfig();
        defaultSSLHostConfig.setHostName(getDefaultSSLHostConfigName());
        getEndpoint().addSslHostConfig(defaultSSLHostConfig);
    }
}
Also used : SSLHostConfig(org.apache.tomcat.util.net.SSLHostConfig)

Example 3 with SSLHostConfig

use of org.apache.tomcat.util.net.SSLHostConfig in project tomcat by apache.

the class ManagerServlet method getConnectorCiphers.

protected Map<String, Set<String>> getConnectorCiphers() {
    Map<String, Set<String>> result = new HashMap<>();
    Engine e = (Engine) host.getParent();
    Service s = e.getService();
    Connector[] connectors = s.findConnectors();
    for (Connector connector : connectors) {
        if (Boolean.TRUE.equals(connector.getProperty("SSLEnabled"))) {
            SSLHostConfig[] sslHostConfigs = connector.getProtocolHandler().findSslHostConfigs();
            for (SSLHostConfig sslHostConfig : sslHostConfigs) {
                String name = connector.toString() + "-" + sslHostConfig.getHostName();
                Set<String> cipherList = new HashSet<>();
                String[] cipherNames = sslHostConfig.getEnabledCiphers();
                for (String cipherName : cipherNames) {
                    cipherList.add(cipherName);
                }
                result.put(name, cipherList);
            }
        } else {
            Set<String> cipherList = new HashSet<>();
            cipherList.add(sm.getString("managerServlet.notSslConnector"));
            result.put(connector.toString(), cipherList);
        }
    }
    return result;
}
Also used : Connector(org.apache.catalina.connector.Connector) HashSet(java.util.HashSet) Set(java.util.Set) HashMap(java.util.HashMap) Service(org.apache.catalina.Service) SSLHostConfig(org.apache.tomcat.util.net.SSLHostConfig) Engine(org.apache.catalina.Engine) HashSet(java.util.HashSet)

Example 4 with SSLHostConfig

use of org.apache.tomcat.util.net.SSLHostConfig in project tomcat by apache.

the class CertificateCreateRule method begin.

@Override
public void begin(String namespace, String name, Attributes attributes) throws Exception {
    SSLHostConfig sslHostConfig = (SSLHostConfig) digester.peek();
    Type type;
    String typeValue = attributes.getValue("type");
    if (typeValue == null || typeValue.length() == 0) {
        type = Type.UNDEFINED;
    } else {
        type = Type.valueOf(typeValue);
    }
    SSLHostConfigCertificate certificate = new SSLHostConfigCertificate(sslHostConfig, type);
    digester.push(certificate);
}
Also used : Type(org.apache.tomcat.util.net.SSLHostConfigCertificate.Type) SSLHostConfigCertificate(org.apache.tomcat.util.net.SSLHostConfigCertificate) SSLHostConfig(org.apache.tomcat.util.net.SSLHostConfig)

Example 5 with SSLHostConfig

use of org.apache.tomcat.util.net.SSLHostConfig in project spring-boot by spring-projects.

the class TomcatServletWebServerFactory method configureSsl.

/**
	 * Configure Tomcat's {@link AbstractHttp11JsseProtocol} for SSL.
	 * @param protocol the protocol
	 * @param ssl the ssl details
	 */
protected void configureSsl(AbstractHttp11JsseProtocol<?> protocol, Ssl ssl) {
    protocol.setSSLEnabled(true);
    protocol.setSslProtocol(ssl.getProtocol());
    configureSslClientAuth(protocol, ssl);
    protocol.setKeystorePass(ssl.getKeyStorePassword());
    protocol.setKeyPass(ssl.getKeyPassword());
    protocol.setKeyAlias(ssl.getKeyAlias());
    String ciphers = StringUtils.arrayToCommaDelimitedString(ssl.getCiphers());
    protocol.setCiphers(StringUtils.hasText(ciphers) ? ciphers : null);
    if (ssl.getEnabledProtocols() != null) {
        try {
            for (SSLHostConfig sslHostConfig : protocol.findSslHostConfigs()) {
                sslHostConfig.setProtocols(StringUtils.arrayToCommaDelimitedString(ssl.getEnabledProtocols()));
            }
        } catch (NoSuchMethodError ex) {
            // Tomcat 8.0.x or earlier
            Assert.isTrue(protocol.setProperty("sslEnabledProtocols", StringUtils.arrayToCommaDelimitedString(ssl.getEnabledProtocols())), "Failed to set sslEnabledProtocols");
        }
    }
    if (getSslStoreProvider() != null) {
        TomcatURLStreamHandlerFactory instance = TomcatURLStreamHandlerFactory.getInstance();
        instance.addUserFactory(new SslStoreProviderUrlStreamHandlerFactory(getSslStoreProvider()));
        protocol.setKeystoreFile(SslStoreProviderUrlStreamHandlerFactory.KEY_STORE_URL);
        protocol.setTruststoreFile(SslStoreProviderUrlStreamHandlerFactory.TRUST_STORE_URL);
    } else {
        configureSslKeyStore(protocol, ssl);
        configureSslTrustStore(protocol, ssl);
    }
}
Also used : TomcatURLStreamHandlerFactory(org.apache.catalina.webresources.TomcatURLStreamHandlerFactory) SSLHostConfig(org.apache.tomcat.util.net.SSLHostConfig)

Aggregations

SSLHostConfig (org.apache.tomcat.util.net.SSLHostConfig)9 Connector (org.apache.catalina.connector.Connector)5 Tomcat (org.apache.catalina.startup.Tomcat)3 Test (org.junit.Test)3 Ssl (org.springframework.boot.web.server.Ssl)3 SSLHostConfigCertificate (org.apache.tomcat.util.net.SSLHostConfigCertificate)2 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 Set (java.util.Set)1 Engine (org.apache.catalina.Engine)1 LifecycleListener (org.apache.catalina.LifecycleListener)1 Service (org.apache.catalina.Service)1 TomcatURLStreamHandlerFactory (org.apache.catalina.webresources.TomcatURLStreamHandlerFactory)1 UpgradeProtocol (org.apache.coyote.UpgradeProtocol)1 Type (org.apache.tomcat.util.net.SSLHostConfigCertificate.Type)1