1

I am trying to configure tomcat7 on server with SSL because I need to send a request via https://

I am following steps -:

               1.Create a keystore file using Java
               2.Configure Tomcat to use the keystore

I tried to create a keystore directly with

          keytool -genkey -alias tomcat -keyalg RSA

and then tried to access https://[host]:8443 it worked

But when I tried to create keystore with the .cer file

        keytool -import -trustcacerts -alias server -file your_site_name.p7b -keystore your_site_name.jks 

Also used

         keytool -import -alias simple -file Example.cer -keystore exampleraystore

and tried to access https://[host]:8443 it is not working .. showing "WEB PAGE CAN"T BE DISPLAYED"

why

Mudit
  • 199
  • 2
  • 21

3 Answers3

0
  • Do you use self signed certificate, or signed by external CA ?
  • Did you modify server.xml as said in tomcat doc ?
  • Does simple self signed cert work, and only imported from your_site_name.p7b doesn't work ?

If simple self signed certificate doesn't work try

https://stackoverflow.com/a/30192138/1423685

it helped me.

Community
  • 1
  • 1
bastiat
  • 1,799
  • 2
  • 19
  • 38
  • Its a self assigned Certificate in first try and in second try I used .cer file to create the key store , yeah I did modify server.xml that's why its working when I tried to create keystore directly ,yeah self signed is working – Mudit Jun 17 '16 at 04:11
0

But when I tried to create keystore with the .cer file

    keytool -import -trustcacerts -alias server 

... you were doing something invalid. This creates a truststore, not a keystore. There is no private key there. If you were attempting to import a signed certificate, you should have omitted the -trustcacerts flag, and used the same alias you used when generating the keypair and CSR.

This is all stated clearly by example in the Tomcat SSL documentation.

user207421
  • 305,947
  • 44
  • 307
  • 483
-1

Did you change your server.xml to redirect to port 8443?

<Connector protocol="org.apache.coyote.http11.Http11Protocol"
               port="8080" redirectPort="8443"

<Connector protocol="org.apache.coyote.http11.Http11Protocol"
               port="8443"
               SSLEnabled="true"
               scheme="https" 
               secure="true"
               sslProtocol="TLS" 
               keystorePass="<pass>" keystoreFile="<path to keystore>"
               ciphers="TLS_RSA_WITH_AES_256_CBC_SHA, <add more ciphers>"/>
bluedevil2k
  • 9,366
  • 8
  • 43
  • 57