Gatling encryption failed

163 views
Skip to first unread message

Muhammad Uzair Baig

unread,
Jul 10, 2015, 5:00:05 AM7/10/15
to gat...@googlegroups.com
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.<init>(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.<init>(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.<init>(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

Stéphane LANDELLE

unread,
Jul 10, 2015, 5:14:21 AM7/10/15
to gat...@googlegroups.com
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 (gatling.sh or gatling.bat) honor your JAVA_HOME that targets another JDK that hasn't been patched.

Am I right?

Stéphane Landelle
Lead developer


--
You received this message because you are subscribed to the Google Groups "Gatling User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gatling+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Muhammad Uzair Baig

unread,
Jul 10, 2015, 5:24:57 AM7/10/15
to gat...@googlegroups.com
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.

Stéphane LANDELLE

unread,
Jul 10, 2015, 5:38:32 AM7/10/15
to gat...@googlegroups.com
I'm sorry, but that's the only explanation...
Do your standalone samples use the sample bc version?
Can you please provide a reproducer?

Stéphane Landelle
Lead developer


--

Stéphane LANDELLE

unread,
Jul 10, 2015, 6:00:54 AM7/10/15
to gat...@googlegroups.com
Are you sure you patched BOTH your JDK and your JRE?

Stéphane Landelle
Lead developer


Muhammad Uzair Baig

unread,
Jul 10, 2015, 6:05:20 AM7/10/15
to gat...@googlegroups.com
We only need to patch JRE (in my case it resides inside JDK). Advise me if I am wrong.


On Friday, 10 July 2015 10:00:05 UTC+1, Muhammad Uzair Baig wrote:

Stéphane LANDELLE

unread,
Jul 10, 2015, 6:09:00 AM7/10/15
to gat...@googlegroups.com
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?).

Stéphane Landelle
Lead developer


--

adrian...@hushmail.com

unread,
Jul 10, 2015, 6:43:27 AM7/10/15
to gat...@googlegroups.com
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. 

Aidy
--
Reply all
Reply to author
Forward
0 new messages