1 year ago

#316842

test-img

Amol Maid

Scala play framework - convert Rest API to HTTPS using .JKS file using organizational CA

Currently I am running scala play application, now it's HTTP APIs are working fine in my Angular UI application locally. But in our organization for higher environment we need to convert it to SSL HTTPS API. We use our own organizational root CA and I got the myCA_trust.jks certificate file with me.

I added following properties in application.conf file,

play.server.https.keyStore.path="./myCA_trust.jks"
play.server.https.keyStore.password="change_me"

And for deploying the code I am creating the dist, and using following command to deploy it on linux server

./scala-rest-api -Dplay.http.secret.key="application_secreate_key" -Dhttps.port=8094 -Dplay.server.https.keyStore.path=./myCA_trust.jks -Dplay.server.https.keyStore.password=change_me

After doing this I can hit to the HTTPS URL using server address, but getting errors in server console like,

[error] a.a.OneForOneStrategy - ./myCA_trust.jks
akka.actor.ActorInitializationException: akka://application/system/StreamSupervisor-0/flow-2-1: exception during creation
        at akka.actor.ActorInitializationException$.apply(Actor.scala:202)
        at akka.actor.ActorCell.create(ActorCell.scala:698)
        at akka.actor.ActorCell.invokeAll$1(ActorCell.scala:549)
        at akka.actor.ActorCell.systemInvoke(ActorCell.scala:571)
        at akka.dispatch.Mailbox.processAllSystemMessages(Mailbox.scala:293)
        at akka.dispatch.Mailbox.run(Mailbox.scala:228)
        at akka.dispatch.Mailbox.exec(Mailbox.scala:241)
        at akka.dispatch.forkjoin.ForkJoinTask.doExec(ForkJoinTask.java:260)
        at akka.dispatch.forkjoin.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1339)
        at akka.dispatch.forkjoin.ForkJoinPool.runWorker(ForkJoinPool.java:1979)
Caused by: java.lang.reflect.InvocationTargetException: null
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
        at play.core.server.ssl.ServerSSLEngine$.createScalaSSLEngineProvider(ServerSSLEngine.scala:116)
        at play.core.server.ssl.ServerSSLEngine$.createSSLEngineProvider(ServerSSLEngine.scala:39)
        at play.core.server.AkkaHttpServer$$anon$4$$anon$5.sslEngineProvider$lzycompute(AkkaHttpServer.scala:527)
        at play.core.server.AkkaHttpServer$$anon$4$$anon$5.sslEngineProvider(AkkaHttpServer.scala:526)
        at play.core.server.AkkaHttpServer$$anon$4$$anon$5.engineCreateSSLEngine(AkkaHttpServer.scala:528)
        at javax.net.ssl.SSLContext.createSSLEngine(SSLContext.java:329)
Caused by: java.nio.file.NoSuchFileException: ./myCA_trust.jks

Please help me to configure HTTPS rest API URL, do let me know if there is anything else I need to add in the code and where. Thanks and in advance.

scala

https

playframework

ssl-certificate

jks

0 Answers

Your Answer

Accepted video resources