Search code examples
azure-devopspostmannewmanpostman-newman

How to send ssl certificate in a Newman request


How to send ssl certificate in a Newman request

  • I have a postman collection which runs only if we provide .PFX , .CER and .KEY file.

its easy to run these tests in Postman UI as you can easily import these certificates in Postman UI.

But how to pass or send these files while trying to run these tests in Newman.

Please guide.

Expected result - Run the tests successfully in newman by sending required certificates


Solution

  • how to pass or send these files while trying to run these tests in Newman.

    Based on your requirement, you need to pass multiple certificates when using Newman.

    You can add the argument: --ssl-client-cert-list cer.json.

    Here are the steps:

    Step1: add the certificates in the json file.

    For example:

    [
        {
            "name": "domain1",
            "matches": ["https://test.domain1.com/*", "https://www.domain1/*"],
            "key": {"src": "./client.domain1.key"},
            "cert": {"src": "./client.domain1.crt"},
            "passphrase": "changeme"
        },
        {
            "name": "domain2",
            "matches": ["https://domain2.com/*"],
            "key": {"src": "./client.domain2.key"},
            "cert": {"src": "./client.domain2.crt"},
            "passphrase": "changeme"
        }
    ]
    

    Step2: you can use the certificate json file in the newman commnad:

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

    For more detailed info, you can refer to this doc: Using SSL client certificates configuration file (supports multiple certificates per run)