2

After generating certificate and key pem file using openssl on ubuntu 16.04 I configured tomcat connector in server.xml file as given below but, when I start tomcat I get an error.

In the browser when I hit this url: https://localhost:8443/ it gives below given error:

This site can’t provide a secure connection localhost sent an invalid response. 

command used to generate cert and key pem file is as:

openssl req -x509 -newkey rsa:4096 -keyout key.pem -out cert.pem -days 365 -nodes

Tomcat connector is as:

<Connector port="8443" maxHttpHeaderSize="8192"
        maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
        enableLookups="false" disableUploadTimeout="true"
        acceptCount="100" scheme="https" secure="true"
        clientAuth="false" sslProtocol="TLS"   SSLEngine="on"   SSLCertificateFile="conf/cert.pem"   SSLCertificateKeyFile="conf/key.pem" />

Something else:

openssl req -x509 -newkey rsa:4096 -keyout key.pem -out cert.pem -days 365 -nodes

Generating a 4096 bit RSA private key ..........................................................................

writing new private key to 'key.pem'

Country Name (2 letter code) [AU]:IN  State or Province Name (full
name) [Some-State]:MH  Locality Name (eg, city) []:Pune  Organization
Name (eg, company) [Internet Widgits Pty Ltd]:softdel Organizational
Unit Name (eg, section) []:iot  Common Name (e.g. server FQDN or YOUR
name) []:localhost  Email Address []:[email protected]

screenshot showing error

logs:

23-Jun-2018 13:29:35.460 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["http-nio-8080"]
23-Jun-2018 13:29:35.483 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["http-nio-8443"]
23-Jun-2018 13:29:35.488 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["ajp-nio-8009"]
23-Jun-2018 13:29:35.490 INFO [main] org.apache.catalina.startup.Catalina.start Server startup in 5150 ms
23-Jun-2018 13:29:35.656 INFO [http-nio-8443-exec-1] org.apache.coyote.http11.Http11Processor.service Error parsing HTTP request header
 Note: further occurrences of HTTP request parsing errors will be logged at DEBUG level.
 java.lang.IllegalArgumentException: Invalid character found in method name. HTTP method names must be tokens
    at org.apache.coyote.http11.Http11InputBuffer.parseRequestLine(Http11InputBuffer.java:410)
    at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:291)
    at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
    at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:754)
    at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1376)
    at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
    at java.lang.Thread.run(Thread.java:748)

23-Jun-2018 13:29:35.659 INFO [http-nio-8443-exec-2] org.apache.coyote.http11.Http11Processor.service Error parsing HTTP request header
 Note: further occurrences of HTTP request parsing errors will be logged at DEBUG level.
 java.lang.IllegalArgumentException: Invalid character found in method name. HTTP method names must be tokens
    at org.apache.coyote.http11.Http11InputBuffer.parseRequestLine(Http11InputBuffer.java:410)
    at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:291)
    at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
    at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:754)
    at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1376)
    at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
    at java.lang.Thread.run(Thread.java:748)

23-Jun-2018 13:29:35.720 INFO [http-nio-8443-exec-3] org.apache.coyote.http11.Http11Processor.service Error parsing HTTP request header
 Note: further occurrences of HTTP request parsing errors will be logged at DEBUG level.
 java.lang.IllegalArgumentException: Invalid character found in method name. HTTP method names must be tokens
    at org.apache.coyote.http11.Http11InputBuffer.parseRequestLine(Http11InputBuffer.java:410)
    at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:291)
    at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
    at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:754)
    at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1376)
    at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
    at java.lang.Thread.run(Thread.java:748)

2018-06-23 13:29:42 [http-nio-8443-exec-17] INFO  org.apache.jsp.index_jsp -  - Entered page login
5
  • What's your actual question?
    – Seth
    Commented Jun 22, 2018 at 9:09
  • After generating certificate and key pem file; am i configured tomcat connector in server.xml file as given below; but, when i start the tomcat and in browser if i hit this url: localhost:8443 it gives this error: This site can’t provide a secure connection localhost sent an invalid response. Commented Jun 22, 2018 at 9:18
  • What version of Tomcat? You may need to specify the full path of your certificate and key. Did you follow these steps: tomcat.apache.org/tomcat-7.0-doc/ssl-howto.html ? Commented Jun 22, 2018 at 9:43
  • on ubuntu 16.04, currentely i am using tomcat 9 as well as i tried on tomcat 8 as well. I followed the steps which are given in above link as well. Commented Jun 22, 2018 at 9:54
  • already i have tried with full path for certificate and key. Commented Jun 22, 2018 at 11:23

1 Answer 1

0

You need to and didn't set SSLEnabled="true" -- see the first para of the SSL section of the Connector doc. Tomcat is actually listening in HTTP-not-S mode, so when the browser sends SSL/TLS ClientHello Tomcat thinks that is an invalid HTTP request, and sends back an HTTP error response which the browser thinks is an invalid SSL/TLS response.

I don't know if the Ubuntu packages include APR (which uses OpenSSL stack) aka 'tomcat-native'. For Tomcat 8, the PEM-format cert&key files will only work if using APR; for the Java SSL/TLS stack (JSSE) you need to use a Java-format keystore. For Tomcat 8.5 or 9, it will take either and convert internally as needed. This is also described in the doc.

Note that for a browser to trust your selfsigned cert, you will need to add it to that browser's truststore; how you do this depends on the browser and sometimes platform, and I don't use any browsers on Ubuntu so I may not be able to help with that part.

1

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .