Gatling encryption failed


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 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(“”, 80));

val scn = scenario(“https2kb”)


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 Source)
at Source)
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 scala.Option.getOrElse(Option.scala:121)
Caused by: org.bouncycastle.openpgp.PGPException: invalid key: Illegal key size
at org.bouncycastle.openpgp.operator.jcajce.JcePGPDataEncryptorBuilder$MyPGPDataEncryptor.(Unknown Source)
at 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.


Wild guess: you have multiple JDKs on your machine.
When you run your standalone programs, you indeed use one where you’ve patched JCE.
But when you run Gatling from the command line, our scripts ( or gatling.bat) honor your JAVA_HOME that targets another JDK that hasn’t been patched.

Am I right?

I have already confirmed this thing. I have only one JDK on my machine and its sets to correct JAVA_HOME and Gatling using it from there.

I’m sorry, but that’s the only explanation…
Do your standalone samples use the sample bc version?
Can you please provide a reproducer?

Are you sure you patched BOTH your JDK and your JRE?

We only need to patch JRE (in my case it resides inside JDK). Advise me if I am wrong.

If you’re running on Windows, you most likely both have a JDK, and a standalone JRE.
If so, please trying patching it too.
Otherwise, please provide a reproducer, and more information (OS, Gatling version, way to launch Gatling: cli, sbt, maven?).

Hi Muhammad,

You are using a BBC import which makes me think that you work at the BBC.

If you send me the test via my BBC email, I could try it myself.