SSL_cert file in Gatling Script

I know this issue has been addressed previously but I’m unable to resolve even now. Especially as previous solution required “. disableClientSharing” which is depreciated now.

Required Set-up

  1. I have saved the Cert file (.pfx) file under /test/cert (CertFile.jpg screesnhot)
  2. Complete content of gatling.conf file

trustStore {
#type = “pfx”
file = “cert/f5-to-crew-hub-service-qa.pfx”
password = “****”
#algorithm = “”
}

  1. Simulation File:
    package simulation

class CreateUserSimulation extends Simulation {

System.setProperty(“javax.net.debug”, “all”)

System.setProperty(“gatling.http.ssl.trustStore.file”, “f5-to-crew-hub-service-qa.pfx”)
System.setProperty(“gatling.http.ssl.trustStore.password”, "***")
/
System.setProperty(“gatling.http.ssl.trustStore.type”, “pfx”)
*/

val feeder_Certificates = Array(
Map(
“gatling.http.ssl.keyStore.file” → “cert/f5-to-crew-hub-service-qa.pfx”,
“gatling.http.ssl.keyStore.password” → “****”))

println(“Environment variables”)
println(" gatling.http.ssl.trustStore.file=" + System.getProperty(“gatling.http.ssl.trustStore.file”))
println(" gatling.http.ssl.trustStore.password=" + System.getProperty(“gatling.http.ssl.trustStore.password”))
// println(" gatling.http.ssl.trustStore.type=" + System.getProperty(“gatling.http.ssl.trustStore.type”))

println(“Environment variables2”)
println(System.getProperties)

/*
Setting up Http Protocols (BaseUrl , Headers etc.)
*/
val httpProtocol: HttpProtocolBuilder = http
.baseUrl(PropertiesReader.getProperty(Constants.BASE_URL))
.acceptHeader(Constants.JSON_CONTENT_TYPE)

val createUserScenario: ScenarioBuilder = scenario(Constants.CREATE_USER_SCENARIO_NAME)
.feed(feeder_Certificates)
.exec(http(userCreateRequest)
.post(Constants.CREATE_USER_URL)
.check(status.in(200))
.body(ElFileBody(Constants.CREATE_USER_REQUEST_BODY_PATH))
.asJson
)

setUp(
createUserScenario.inject(atOnceUsers(1))
).protocols(httpProtocol)

Error Observed:

---- Errors --------------------------------------------------------------------

Java doesn’t support PFX format. You have to convert it: https://dzone.com/articles/convert-pfx-certificate-to-jks-p12-crt

Thanks for the quick response Stephane…
I did update the certificate to .jks for trustStore & tried with both “,jks & .p12” for keyStore. But I still get the same error.

---- Errors --------------------------------------------------------------------

j.n.s.SSLHandshakeException: error:10000410:SSL routines:OPENS 1 (100.0%)
SL_internal:SSLV3_ALERT_HANDSHAKE_FAILURE

Below is the updated “gatling.conf”.

http {
        ssl {
        trustStore {
                #type = "pfx"      # Type of SSLContext's KeyManagers store
                file = "cert/truststore.jks"      # Location of SSLContext's KeyManagers store
                password = "123456"  # Password for SSLContext's KeyManagers store
                #algorithm = "" # Algorithm used SSLContext's KeyManagers store
              }

        keyStore {
                #type = "pfx"      # Type of SSLContext's KeyManagers store
                file = "cert/keystore.p12"      # Location of SSLContext's KeyManagers store
                password = "123456"  # Password for SSLContext's KeyManagers store
                #algorithm = "" # Algorithm used SSLContext's KeyManagers store
              }
        }
}

I only had “trustStore & keyStore” also without http/ssl in the file body to try the various options.
Attached is the simulation file & logs file for reference.

Thanks,
-Nalin

simulation_file.txt (3.48 KB)

logs.txt (21.5 KB)

Any help…

I have further updated the gatling.conf file but still same error.

gatling {

    ssl {
      useOpenSsl = false                    # if OpenSSL should be used instead of JSSE (only the latter can be debugged with -Djava.net.debug=ssl)
      useOpenSslFinalizers = false         # if OpenSSL contexts should be freed with Finalizer or if using RefCounted is fine
        handshakeTimeout = 10000             # TLS handshake timeout in millis
      useInsecureTrustManager = true       # Use an insecure TrustManager that trusts all server certificates
      enabledProtocols = []             # Array of enabled protocols for HTTPS, if empty use Netty's defaults
        enabledCipherSuites = []          # Array of enabled cipher suites for HTTPS, if empty enable all available ciphers
      sessionCacheSize = 0              # SSLSession cache size, set to 0 to use JDK's default
        sessionTimeout = 0                # SSLSession timeout in seconds, set to 0 to use JDK's default (24h)
      enableSni = false                      # When set to true, enable Server Name indication (SNI)
      keyStore {
        type = "jks"      # Type of SSLContext's KeyManagers store
        file = "cert/keystore"      # Location of SSLContext's KeyManagers store
        password = "123456"  # Password for SSLContext's KeyManagers store
       # algorithm = "" # Algorithm used SSLContext's KeyManagers store
      }
      trustStore {
        type = "jks"      # Type of SSLContext's TrustManagers store
        file = "cert/truststore"      # Location of SSLContext's TrustManagers store
        password = "123456"  # Password for SSLContext's TrustManagers store
        #algorithm = "" # Algorithm used by SSLContext's TrustManagers store
      }
    }

}

I feel the gatling conf file is not correct, probably you can download the Gatling OSS of the version you use and copy the gatling.conf from conf folder into your project
or if you use Maven or Gradle or SBT, you will get one already while bootstrapping the project

Then try adding the certificate file path into the gatling.conf file

Placed the certificate and followed the steps mentioned
https://stackoverflow.com/questions/28694659/gatling-change-ssl-cert-used-in-feeder-per-request
https://stackoverflow.com/questions/48592672/ssl-signed-certificate-authentication-in-gatling
Still seeing the same issues. can someone shed some light to fix this issue?

Trust Store is captured:

KeyStore is not:

So finally getting error

facing the similar issue tried all various steps but no luck. Please check share the way to fix this issue.

Error:

---- Errors --------------------------------------------------------------------