Creating SSL Certificate Server failed to start: com.ibm.crypto.tools.KeyTool error?

269 Views Asked by At

i am using grails 2.2.

I am running the grails app using the following command

run-app -noreloading -https -Dgrails.server.port.https=8443 -Dgrails.server.port.http=8080

I am getting the following error on starting the app

"C:\Program Files\Zulu\zulu-7\bin\java.exe" -Dgrails.home=C:\Users\user\Desktop\grails-2.2.0 "-Dtools.jar=C:\Program Files\Zulu\zulu-7\lib\tools.jar" -Dgroovy.starter.conf=C:\Users\user\Desktop\grails-2.2.0/conf/groovy-starter.conf -Xmx768M -Xms768M -XX:MaxPermSize=256m -XX:PermSize=256m -Djline.WindowsTerminal.directConsole=false -Dbase.dir=C:\Users\user\IdeaProjects\RCRoadRaceWeb -Dfile.encoding=UTF-8 -classpath C:\Users\user\Desktop\grails-2.2.0\lib\org.codehaus.groovy\groovy-all\jars\groovy-all-2.0.5.jar;C:\Users\user\Desktop\grails-2.2.0\dist\grails-bootstrap-2.2.0.jar org.codehaus.groovy.grails.cli.support.GrailsStarter --main org.codehaus.groovy.grails.cli.GrailsScriptRunner --conf C:\Users\user\Desktop\grails-2.2.0/conf/groovy-starter.conf "run-app -noreloading -https -Dgrails.server.port.https=8443 -Dgrails.server.port.http=8080 -Duser.timezone=US/Mountain -plain-output"

|Loading Grails 2.2.0
|Configuring classpath
.
|Environment set to development
.................................
|Packaging Grails application
......
|Compiling 1 source files
...........
|Running Grails application
|Creating SSL Certificate...
Error |
Server failed to start: com.ibm.crypto.tools.KeyTool (Use --stacktrace to see the full trace)

Process finished with exit code 1

If i run it normally without the https flag then it works but when i use https it fails on creating ssl certificate.

I am using java 1.7.

I appreciate any help as to how to overcome this error. Thanks for the help!

UPDATE:

After adding --stacktrace i am getting the following error

"C:\Program Files\Zulu\zulu-7\bin\java.exe" -Dgrails.home=C:\Users\user\Desktop\grails-2.2.0 "-Dtools.jar=C:\Program Files\Zulu\zulu-7\lib\tools.jar" -Dgroovy.starter.conf=C:\Users\user\Desktop\grails-2.2.0/conf/groovy-starter.conf -Xmx768M -Xms768M -XX:MaxPermSize=256m -XX:PermSize=256m -Djline.WindowsTerminal.directConsole=false -Dbase.dir=C:\Users\user\IdeaProjects\RCRoadRaceWeb -Dfile.encoding=UTF-8 -classpath C:\Users\user\Desktop\grails-2.2.0\lib\org.codehaus.groovy\groovy-all\jars\groovy-all-2.0.5.jar;C:\Users\user\Desktop\grails-2.2.0\dist\grails-bootstrap-2.2.0.jar org.codehaus.groovy.grails.cli.support.GrailsStarter --main org.codehaus.groovy.grails.cli.GrailsScriptRunner --conf C:\Users\user\Desktop\grails-2.2.0/conf/groovy-starter.conf "run-app -noreloading -https --stacktrace -Dgrails.server.port.https=8443 -Dgrails.server.port.http=8080 -Duser.timezone=US/Mountain -plain-output"

|Loading Grails 2.2.0
|Configuring classpath
.
|Environment set to development
.................................
|Packaging Grails application
......
|Compiling 1 source files
...........
|Running Grails application
|Creating SSL Certificate...
Error |
Server failed to start: com.ibm.crypto.tools.KeyTool (NOTE: Stack trace has been filtered. Use --verbose to see entire trace.)
java.lang.ClassNotFoundException: com.ibm.crypto.tools.KeyTool
    at java_lang_Class$forName.call(Unknown Source)
    at org.grails.plugins.tomcat.TomcatServer.getKeyToolClass(TomcatServer.groovy:186)
    at org.grails.plugins.tomcat.TomcatServer.this$2$getKeyToolClass(TomcatServer.groovy)
    at org.grails.plugins.tomcat.TomcatServer$this$2$getKeyToolClass.callCurrent(Unknown Source)
    at org.grails.plugins.tomcat.TomcatServer.createSSLCertificate(TomcatServer.groovy:167)
    at org.grails.plugins.tomcat.TomcatServer.startSecure(TomcatServer.groovy:140)
    at grails.web.container.EmbeddableServer$startSecure.call(Unknown Source)
    at _GrailsRun_groovy$_run_closure2.doCall(_GrailsRun_groovy:72)
    at org.codehaus.gant.GantMetaClass.invokeMethod(GantMetaClass.java:133)
    at org.codehaus.gant.GantMetaClass.invokeMethod(GantMetaClass.java:133)
    at org.codehaus.gant.GantBinding$_initializeGantBinding_closure5_closure16_closure18.doCall(GantBinding.groovy:185)
    at org.codehaus.gant.GantBinding$_initializeGantBinding_closure5_closure16_closure18.doCall(GantBinding.groovy)
    at org.codehaus.gant.GantBinding.withTargetEvent(GantBinding.groovy:90)
    at org.codehaus.gant.GantBinding.this$4$withTargetEvent(GantBinding.groovy)
    at org.codehaus.gant.GantBinding$_initializeGantBinding_closure5_closure16.doCall(GantBinding.groovy:185)
    at org.codehaus.gant.GantBinding$_initializeGantBinding_closure5_closure16.doCall(GantBinding.groovy)
    at org.codehaus.gant.GantMetaClass.invokeMethod(GantMetaClass.java:133)
    at RunApp$_run_closure1.doCall(RunApp.groovy:32)
    at org.codehaus.gant.GantMetaClass.invokeMethod(GantMetaClass.java:133)
    at org.codehaus.gant.GantMetaClass.invokeMethod(GantMetaClass.java:133)
    at org.codehaus.gant.GantBinding$_initializeGantBinding_closure5_closure16_closure18.doCall(GantBinding.groovy:185)
    at org.codehaus.gant.GantBinding$_initializeGantBinding_closure5_closure16_closure18.doCall(GantBinding.groovy)
    at org.codehaus.gant.GantBinding.withTargetEvent(GantBinding.groovy:90)
    at org.codehaus.gant.GantBinding.this$4$withTargetEvent(GantBinding.groovy)
    at org.codehaus.gant.GantBinding$_initializeGantBinding_closure5_closure16.doCall(GantBinding.groovy:185)
    at org.codehaus.gant.GantBinding$_initializeGantBinding_closure5_closure16.doCall(GantBinding.groovy)
    at gant.Gant$_dispatch_closure5.doCall(Gant.groovy:381)
    at gant.Gant$_dispatch_closure7.doCall(Gant.groovy:415)
    at gant.Gant$_dispatch_closure7.doCall(Gant.groovy)
    at gant.Gant.withBuildListeners(Gant.groovy:427)
    at gant.Gant.this$2$withBuildListeners(Gant.groovy)
    at gant.Gant$this$2$withBuildListeners.callCurrent(Unknown Source)
    at gant.Gant.dispatch(Gant.groovy:415)
    at gant.Gant.this$2$dispatch(Gant.groovy)
    at gant.Gant.invokeMethod(Gant.groovy)
    at gant.Gant.executeTargets(Gant.groovy:591)
    at gant.Gant.executeTargets(Gant.groovy:590)

Error |
Server failed to start: com.ibm.crypto.tools.KeyTool
1

There are 1 best solutions below

0
On

So i first manually generated the ssl certificate as guided here

https://community.pivotal.io/s/article/Generating-a-self-signed-SSL-certificate-using-the-Java-keytool-command?language=en_US

after that as pointed here

http://grails.1312388.n4.nabble.com/Specifying-the-SSL-certificate-in-Grails-2-x-td4629128.html

I pasted the following two lines in BuildConfig.groovy

grails.tomcat.keystorePath = "c:/Users/user/selfsigned.jks"
grails.tomcat.keystorePassword = "secret"

I was little puzzled locating the keystore path

since i used this command

keytool -genkey -keyalg RSA -alias tomcat -keystore selfsigned.jks -validity <days> -keysize 2048

and i was in C:\Users\user>

so i just did dir there and noticed selfsigned.jks

so i realized the path would be

c:/Users/user/selfsigned.jks

after this change the app ran happily. Seems like if there is self signed certifiacte configured using buildconfig then it will not create ssl certificate which would fail.

thank you ;op from

http://grails.1312388.n4.nabble.com/Specifying-the-SSL-certificate-in-Grails-2-x-td4629128.html

the solution was yours.