Hi,
I have to test my API which received a encrypted message from client. I need to encrypt message using public key. I have a simple java code (JAR) which I use to generate encrypted message for endpoint input. When I run this java program outside Gatling it works fine and give me proper encrypted message. I write a simple Scala test (not Gatling) and call this Java code inside Scala test and its also works fine.
But whenever I try to call this java code (using Jar in gatling lib directory) I got encryption error “illegal key size”. Here is my Gatling code.
import io.gatling.core.Predef._
import io.gatling.core.session.Expression
import io.gatling.http.Predef._
import io.gatling.jdbc.Predef._
import scala.concurrent.duration._
import awscala., sqs.
import org.slf4j._
import uk.co.bbc.notifications.subscriber.sqs.service._
import scala.collection.JavaConverters._
import java.util.Calendar
class SQSGatling extends Simulation {
val sqsMessageService: SqsMessageService = new SqsMessageService()
val messages = sqsMessageService.getBatchMessages().asScala
val httpConf = http.proxy(Proxy(“myproxy.xyz”, 80));
val scn = scenario(“https2kb”)
.exec(
http(“request_0”)
…
setUp(scn.inject(atOnceUsers(5)).protocols(httpConf))
}
Its fails Inside my java service as soon as I called it.
// val messages = sqsMessageService.getBatchMessages().asScala
Stack trace
org.bouncycastle.openpgp.PGPException: Exception creating cipher
at org.bouncycastle.openpgp.PGPEncryptedDataGenerator.open(Unknown Source)
at org.bouncycastle.openpgp.PGPEncryptedDataGenerator.open(Unknown Source)
at uk.co.bbc.notifications.subscriber.util.PGPEncryptionUtil.(PGPEncryptionUtil.java:58)
at uk.co.bbc.notifications.subscriber.sqs.service.SqsMessageService.encryptMessage(SqsMessageService.java:120)
at uk.co.bbc.notifications.subscriber.sqs.service.SqsMessageService.prepareMessages(SqsMessageService.java:62)
at uk.co.bbc.notifications.subscriber.sqs.service.SqsMessageService.getBatchMessages(SqsMessageService.java:44)
at SQSGatling.(SQSGatling.scala:16)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at java.lang.Class.newInstance(Unknown Source)
at io.gatling.core.runner.Runner.run(Runner.scala:36)
at io.gatling.app.Gatling$$anonfun$runSimulationIfNecessary$1.apply(Gatling.scala:138)
at io.gatling.app.Gatling$$anonfun$runSimulationIfNecessary$1.apply(Gatling.scala:123)
at scala.Option.getOrElse(Option.scala:121)
at io.gatling.app.Gatling.runSimulationIfNecessary(Gatling.scala:123)
at io.gatling.app.Gatling.start(Gatling.scala:73)
at io.gatling.app.Gatling$.fromArgs(Gatling.scala:59)
at io.gatling.app.Gatling$.main(Gatling.scala:44)
at io.gatling.app.Gatling.main(Gatling.scala)
Caused by: org.bouncycastle.openpgp.PGPException: invalid key: Illegal key size
at org.bouncycastle.openpgp.operator.jcajce.JcePGPDataEncryptorBuilder$MyPGPDataEncryptor.(Unknown Source)
at org.bouncycastle.openpgp.operator.jcajce.JcePGPDataEncryptorBuilder.build(Unknown Source)
… 21 more
Again it work fine independently so there is no issue with JCE unlimited Strength (its already installed).
Your help is much appreciated.
Regards