kramsiv94
kramsiv94

Reputation: 711

Newman: How to send ssl cert in newman request

I have a curl command that I'd like to have run as a collection using newman:

curl -i -v \
 -H "X-FromAppId: APPLICATION" \
 -H "X-TransactionId: 22222222" \
 -H "Accept: application/json" \
 -H "Content-Type: application/json" \
 --cacert iis_cert_2018_07.pem \
 --key iis_cert_2018_07.pem \
 --cert iis_cert_2018_07.pem \
 -X GET https://iis-udev02.dev.test.com:8443/iis/v1/common/policies/343
 --insecure

I have a collection that executes that GET request, and it works just fine on Postman (after configuring the certs in the UI), but how do I notify newman of those certs when running the collection through the commandline?

I've tried:

newman run GETRequest.postman_collection.json  --ssl-client-cert iis_cert_2018_07.pem --ssl-client-passphrase iis_cert_2018_07.pem --insecure 

But that doesn't work.

How is a cert sent in a newman request?

Upvotes: 1

Views: 9589

Answers (3)

Ermiya Eskandary
Ermiya Eskandary

Reputation: 23672

If you have a PFX certificate, using --ssl-client-cert won't work.

Instead you need to use --ssl-client-cert-list to provide a JSON configuration, similar to how you would set it up in Postman.

Save something like the below as ssl-client-cert.json:

[
    {
        "name": "xxx",
        "matches": ["https://yyy.com/*"],
        "pfx": {"src": "certifcate.pfx"},
        "passphrase": "mycertpassword"
    }
]

And then run newman:

newman run "xxx" --ssl-client-cert-list "ssl-client-cert.json"

Upvotes: 1

irfaan
irfaan

Reputation: 11

if you have the key encrypted then you can use the below command

newman run GETRequest.postman_collection.json --ssl-client-cert iis_cert_2018_07.pem --ssl-client-key iis_cert_2018_07key.pem --ssl-client-passphrase password

Upvotes: 1

Jordan Stewart
Jordan Stewart

Reputation: 3395

You are passing in the key as the passphrase here: --ssl-client-passphrase iis_cert_2018_07.pem, it should be --ssl-client-key iis_cert_2018_07.pem

Try:

 newman run GETRequest.postman_collection.json  --ssl-client-cert iis_cert_2018_07.pem --ssl-client-key iis_cert_2018_07.pem --insecure

This should work assuming the key is not encrypted with a passphrase, and everything else is right.

The relevant newman documentation is here: https://www.npmjs.com/package/newman#ssl-client-certificates

Upvotes: 3

Related Questions