I am trying to use HTTPS with Tomcat 8. I have followed the procedure mentioned at tomcat8-ssl-howto to use HTTPS but currently I can't seem to get it working.
Since, the problem seems to be with keystore, I am listing the steps followed-
1. keytool -genkeypair -keyalg RSA -validity 3650 -alias tomcat
2. keytool -certreq -alias tomcat -file tomcat.csr
3. openssl req -nodes -config conf/openssl.cnf -days 3650 -x509 -newkey rsa:2048 -out public/company_public.pem -outform PEM
4. openssl x509 -in public/company_public.pem -outform DER -out public/company_public.crt and then place it in docroot
5. Updated web.xml with
<mime-mapping>
<extension>crt</extension>
<mime-type>application/x-x509-ca-cert</mime-type>
</mime-mapping>
<mime-mapping>
<extension>cert</extension>
<mime-type>application/x-x509-ca-cert</mime-type>
</mime-mapping>
<mime-mapping>
<extension>pem</extension>
<mime-type>application/x-x509-ca-cert</mime-type>
</mime-mapping>
6.Imported the trusted root certificate into the web browser
7. openssl ca -batch -config conf/openssl.cnf -in tomcat.csr -out tomcat.cert
8. openssl x509 -in tomca.cert -out tomcat.crt
9. keytool -importcert -v -trustcacerts -alias companycaroot -file company_public.crt
10. keytool -import -v -alias tomcat -file tomcat.crt
The below error is logged in catalina.out:-
#|INFO|2016-03-02 21:03:30.385+1000|129|org.apache.coyote.http11.AbstractHttp11Processor.process|Error parsing HTTP request header
Note: further occurrences of HTTP header parsing errors will be logged at DEBUG level.|#
As the issue is with parsing HTTP request header, I have updated the maxHttpHeaderSize=99999 just to ensure that is not causing a problem.
Below are the configuration in server.xml:
<Connector executor="tomcatThreadPool"
port="50915"
protocol="org.apache.coyote.http11.Http11NioProtocol"
maxHttpHeaderSize="99999"
server="Test Web"
keepAliveTimeout="90000"
maxKeepAliveRequests="-1"
acceptorThreadCount="40"
redirectPort="50921" />
<Connector executor="tomcatThreadPool"
port="50921"
protocol="org.apache.coyote.http11.Http11NioProtocol"
maxHttpHeaderSize="99999"
SSLEnabled="true"
maxThreads="150"
scheme="https"
secure="true"
clientAuth="false"
server="Test Web"
keepAliveTimeout="90000"
maxKeepAliveRequests="-1"
acceptorThreadCount="40"
keystoreFile="/web/home/wb10d1/.keystore"
keystorePass="changeit"
allowTrace="true"
sslProtocol="TLS" />
I have tried using Fiddler to investigate the HTTPS response:
fiddler.network.https> HTTPS handshake to hostname.domainname.com (for #4) failed. System.IO.IOException The handshake failed due to an unexpected packet format.
Error returned for Firefox 44.0.2: With HTTP Connect - PORT 50915
An error occurred during a connection to hostname:50915. SSL received a record that exceeded the maximum permissible length. (Error code: ssl_error_rx_record_too_long)
UPDATE #1 With HTTPS Connector - PORT 50921 The owner of hostname:50921 has configured their website improperly. To protect your information from being stolen, Firefox has not connected to this website. Advanced info: ssl_error_no_cypher_overlap
Update#2: Added more debugging information Here, I see the below errors in catalina.out:- http://pastebin.com/PTatkMQN
Unsupported extension type_23, data:
Extension renegotiation_info, renegotiated_connection: <empty>
***
I got the code which causes this error:- http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/8u40-b25/sun/security/ssl/HelloExtensions.java/
It seems that the Extension type is being checked to one from the below enum values but it is not http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/8u40-b25/sun/security/ssl/ExtensionType.java#ExtensionType.0EXT_SERVER_NAME
I am not able to figure out what causes the an unknown extension to be set.
I have checked other links on internet about the error, but the things recommended for others have already been done.
**Note:**I am able to access the URL using HTTP without any problem. So, the issue is clearly with HTTPS.