I need to use a client certificate to log into a website to test it. I'm able to see how to configure them with the docs at https://docs.cypress.io/guides/references/client-certificates#Usage, but I can't seem to find any examples on actually using the configuration.
Store your certificates in /certs folder and link it in your cypress.config.ts file as follows. (There are 2 approaches one with a pfx file and other with cert+key):
import { defineConfig } from 'cypress';
export default defineConfig({
clientCertificates: [
{
url: 'https://federation-qa.mycompany.com/**',
ca: [],
certs: [
{
pfx: 'certs/mycertificate.pfx',
passphrase: 'certs/mycertificate-passphrase.txt',
},
],
},
{
url: 'https://federation-qa.mycompany.com/**',
ca: [],
certs: [
{
cert: 'certs/mycertificate.crt.pem',
key: 'certs/mycertificate.key.pem',
passphrase: 'certs/mycertificate-passphrase.txt',
},
],
},
],
e2e: {
setupNodeEvents() {
// implement node event listeners here
},
},
});