Corey Ogburn
Corey Ogburn

Reputation: 24739

Postman and multiple Client Certificates for a single domain?

I've been using Fiddler for a couple of weeks to test an API but we're moving to Postman.

Our APIs workflow is that a device must register by using a common cert and as a response to a successful registration a private cert is issued to that device. All requests the device makes after that uses the private cert.

I'm trying to test multiple devices which means I need Postman to use 5 or 6 certs for a single domain. In Fiddler I could modify the fiddlerscript so I had an array of all the certs I intended to use. If I wanted to switch certs I opened the script and used a different index of my cert array. I'd set oSession["https-Client-Certificate"] and the request would use that cert.

In postman, I see that I can set a client cert for a particular domain. I've been able to get that to work for the global cert and running a /register request successfully. I can then change the cert and keep going. It's an annoying process if I want to change this cert after every request as I emulate multiple devices each with their own cert.

I see there's a Pre-Request Script tab. Is there a way to change the client cert in this script? If not with a Pre-Request Script, is there any other place where I can have multiple certs for a single domain and easily switch between them between requests?

Upvotes: 2

Views: 3116

Answers (1)

Veener
Veener

Reputation: 5201

I don't think that's possible, but maybe you can trick it by updating your local hosts file by creating fake local domains

  • 104.244.42.130 cert1.api.twitter.com
  • 104.244.42.130 cert2.api.twitter.com
  • 104.244.42.130 cert3.api.twitter.com
  • 104.244.42.130 cert4.api.twitter.com
  • 104.244.42.130 cert5.api.twitter.com

Then map each local domain in postman to each certificate

  • cert1.api.twitter.com
  • cert2.api.twitter.com
  • cert3.api.twitter.com
  • cert4.api.twitter.com
  • cert5.api.twitter.com

and create an environment for each certificate and update the url of each request to include the {{cert}} environment. Then by switching environments you should be switching the certificate at the same time.

Upvotes: 1

Related Questions