Matt
Matt

Reputation: 1053

Karate how to send server SSL certificate client.crt

I want to convert the following curl command into a Karate script:

curl --cacert ca.crt --key client.key --cert client.crt "https://myurl"

All three SSL parts are required, i.e. client cert, client key AND server cert.

Is this possible in Karate?

Upvotes: 0

Views: 1533

Answers (1)

Matt
Matt

Reputation: 1053

To resolve this I converted ca.crt, client.key and client.crt into a .pfx file using this command:

openssl pkcs12 -export -out certificate.pfx -inkey client.key -in client.crt -certfile CA.crt

This created a file called certificate.pfx

I then added this line to karateconfig.js:

  karate-configure('ssl', { trustAll: true });

I copied my new certificate.pfx file into this location:

src\test\resources\sslCertificates\certificate.pfx

I added the following line to the Background section of my feature file:

* configure ssl = { keyStore: 'classpath:sslCertificates/certificate.pfx', keyStorePassword: '', keyStoreType: 'pkcs12' }

I then received a successful response for my request.

Upvotes: 1

Related Questions