Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TomcatConfiguration generates invalid configuration #104

Open
mmadzin opened this issue Aug 13, 2020 · 4 comments
Open

TomcatConfiguration generates invalid configuration #104

mmadzin opened this issue Aug 13, 2020 · 4 comments

Comments

@mmadzin
Copy link
Collaborator

mmadzin commented Aug 13, 2020

Seems that TomcatConfigurator's function httpsConnector generates invalid configuration:

e.g.
<Connector port="8443" protocol="org.apache.coyote.http11.Http11NioProtocol" secure="true" scheme="https" SSLEnabled="true" keystoreFile="/tmp/ssl/self_signed/server.jks" keystorePass="changeit" clientAuth="false"/> <Connector redirectPort="8443"/>

which results in:
SEVERE [main] org.apache.catalina.util.LifecycleBase.handleSubClassException Failed to initialize component [Connector[HTTP/1.1-auto-1]] org.apache.catalina.LifecycleException: Protocol handler initialization failed at org.apache.catalina.connector.Connector.initInternal(Connector.java:983) at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:136) at org.apache.catalina.core.StandardService.initInternal(StandardService.java:533) at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:136) at org.apache.catalina.core.StandardServer.initInternal(StandardServer.java:1057) at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:136) at org.apache.catalina.startup.Catalina.load(Catalina.java:584) at org.apache.catalina.startup.Catalina.start(Catalina.java:621) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:343) at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:474) Caused by: java.lang.IllegalArgumentException: port out of range:-1 at java.net.InetSocketAddress.checkPort(InetSocketAddress.java:143) at java.net.InetSocketAddress.<init>(InetSocketAddress.java:188) at org.apache.tomcat.util.net.NioEndpoint.initServerSocket(NioEndpoint.java:228) at org.apache.tomcat.util.net.NioEndpoint.bind(NioEndpoint.java:212) at org.apache.tomcat.util.net.AbstractEndpoint.bindWithCleanup(AbstractEndpoint.java:1141) at org.apache.tomcat.util.net.AbstractEndpoint.init(AbstractEndpoint.java:1154) at org.apache.coyote.AbstractProtocol.init(AbstractProtocol.java:575) at org.apache.coyote.http11.AbstractHttp11Protocol.init(AbstractHttp11Protocol.java:74) at org.apache.catalina.connector.Connector.initInternal(Connector.java:980) ... 13 more

Source code:
TomcatConfigurator configurator = new TomcatConfigurator(tomcat)

SecureHttpConnectorTomcat conn = new SecureHttpConnectorTomcat()
    .setPort(tomcat.getMainHttpsPort())
    .setScheme("https")
    .setSecure(true)
    .setProtocol(protocol)
    .setKeystoreFile(tomcat.keystorePath)
    .setKeystorePass(tomcat.sslKeystorePassword)

configurator.httpsConnector(conn)
@jstefl
Copy link
Collaborator

jstefl commented Aug 13, 2020

How input server.xml look like? (the connectors part)
What is the expected output after the code execution?

@mmadzin
Copy link
Collaborator Author

mmadzin commented Aug 13, 2020

The connector part is in the description:

<Connector port="8443" protocol="org.apache.coyote.http11.Http11NioProtocol" secure="true" scheme="https" SSLEnabled="true" keystoreFile="/tmp/ssl/self_signed/server.jks" keystorePass="changeit" clientAuth="false"/>
 <Connector redirectPort="8443"/>

Instead of one connector element it creates 2. I believe that it should not create the second connector.

@jstefl
Copy link
Collaborator

jstefl commented Aug 13, 2020

In the description, is what is "output" in server.xml.
My question is what is in "input" server.xml? (it's content before any your code execution).

@mmadzin
Copy link
Collaborator Author

mmadzin commented Sep 7, 2020

The code, I shared, is creating a new connector. Hence no configuration of the connector is on the input.

Input server.xml is default server.xml file: https://github.com/apache/tomcat/blob/9.0.x/conf/server.xml

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants