diff --git a/docs/src/api/params.md b/docs/src/api/params.md index 0a1e178559..28ed11a86f 100644 --- a/docs/src/api/params.md +++ b/docs/src/api/params.md @@ -518,10 +518,10 @@ Does not enforce fixed viewport, allows resizing window in the headed mode. - `clientCertificates` <[Array]<[Object]>> - `url` <[string]> Glob pattern to match the URLs that the certificate is valid for. - `certs` <[Array]<[Object]>> List of client certificates to be used. - - `cert` ?<[string]> Path to the file with the certificate in PEM format. - - `key` ?<[string]> Path to the file with the private key in PEM format. + - `certPath` ?<[string]> Path to the file with the certificate in PEM format. + - `keyPath` ?<[string]> Path to the file with the private key in PEM format. + - `pfxPath` ?<[string]> Path to the PFX or PKCS12 encoded private key and certificate chain. - `passphrase` ?<[string]> Passphrase for the private key (PEM or PFX). - - `pfx` ?<[string]> Path to the PFX or PKCS12 encoded private key and certificate chain. An array of client certificates to be used. Each certificate object must have `cert` and `key` or `pfx` to load the client certificate. Optionally, `passphrase` property should be provided if the private key is encrypted. If the certificate is valid only for specific URLs, the `url` property should be provided with a glob pattern to match the URLs that the certificate is valid for. diff --git a/docs/src/test-api/class-testoptions.md b/docs/src/test-api/class-testoptions.md index d4ea39262d..ac6b29473c 100644 --- a/docs/src/test-api/class-testoptions.md +++ b/docs/src/test-api/class-testoptions.md @@ -154,10 +154,10 @@ export default defineConfig({ use: { ...devices['Desktop Edge'], clientCertificates: [{ - url: 'https://example.com', + url: 'https://example.com/**', certs: [{ - cert: 'client/alice_cert.pem', - key: 'client/alice_key.pem', + certPath: './cert.pem', + keyPath: './key.pem', passphase: 'mysecretpassword', }], }], diff --git a/packages/playwright-core/src/client/browserContext.ts b/packages/playwright-core/src/client/browserContext.ts index a6765ec28a..5100b0db25 100644 --- a/packages/playwright-core/src/client/browserContext.ts +++ b/packages/playwright-core/src/client/browserContext.ts @@ -558,10 +558,10 @@ export async function toClientCertificatesProtocol(clientCertificates?: BrowserC url: clientCertificate.url, certs: await Promise.all(clientCertificate.certs.map(async cert => { return { - cert: cert.cert ? await fs.promises.readFile(cert.cert) : undefined, - key: cert.key ? await fs.promises.readFile(cert.key) : undefined, + cert: cert.certPath ? await fs.promises.readFile(cert.certPath) : undefined, + key: cert.keyPath ? await fs.promises.readFile(cert.keyPath) : undefined, + pfx: cert.pfxPath ? await fs.promises.readFile(cert.pfxPath) : undefined, passphrase: cert.passphrase, - pfx: cert.pfx ? await fs.promises.readFile(cert.pfx) : undefined, }; })) }; diff --git a/packages/playwright-core/src/client/types.ts b/packages/playwright-core/src/client/types.ts index 25b1f0df83..4c6f23d977 100644 --- a/packages/playwright-core/src/client/types.ts +++ b/packages/playwright-core/src/client/types.ts @@ -50,10 +50,10 @@ export const kLifecycleEvents: Set = new Set(['load', 'domconten export type ClientCertificate = { url: string; certs: { - cert?: string; - key?: string; + certPath?: string; + keyPath?: string; + pfxPath?: string; passphrase?: string; - pfx?: string; }[]; }; diff --git a/packages/playwright-core/types/types.d.ts b/packages/playwright-core/types/types.d.ts index c214ec3501..89b27a118a 100644 --- a/packages/playwright-core/types/types.d.ts +++ b/packages/playwright-core/types/types.d.ts @@ -13245,22 +13245,22 @@ export interface BrowserType { /** * Path to the file with the certificate in PEM format. */ - cert?: string; + certPath?: string; /** * Path to the file with the private key in PEM format. */ - key?: string; + keyPath?: string; + + /** + * Path to the PFX or PKCS12 encoded private key and certificate chain. + */ + pfxPath?: string; /** * Passphrase for the private key (PEM or PFX). */ passphrase?: string; - - /** - * Path to the PFX or PKCS12 encoded private key and certificate chain. - */ - pfx?: string; }>; }>; @@ -15657,22 +15657,22 @@ export interface APIRequest { /** * Path to the file with the certificate in PEM format. */ - cert?: string; + certPath?: string; /** * Path to the file with the private key in PEM format. */ - key?: string; + keyPath?: string; + + /** + * Path to the PFX or PKCS12 encoded private key and certificate chain. + */ + pfxPath?: string; /** * Passphrase for the private key (PEM or PFX). */ passphrase?: string; - - /** - * Path to the PFX or PKCS12 encoded private key and certificate chain. - */ - pfx?: string; }>; }>; @@ -16851,22 +16851,22 @@ export interface Browser extends EventEmitter { /** * Path to the file with the certificate in PEM format. */ - cert?: string; + certPath?: string; /** * Path to the file with the private key in PEM format. */ - key?: string; + keyPath?: string; + + /** + * Path to the PFX or PKCS12 encoded private key and certificate chain. + */ + pfxPath?: string; /** * Passphrase for the private key (PEM or PFX). */ passphrase?: string; - - /** - * Path to the PFX or PKCS12 encoded private key and certificate chain. - */ - pfx?: string; }>; }>; @@ -20326,22 +20326,22 @@ export interface BrowserContextOptions { /** * Path to the file with the certificate in PEM format. */ - cert?: string; + certPath?: string; /** * Path to the file with the private key in PEM format. */ - key?: string; + keyPath?: string; + + /** + * Path to the PFX or PKCS12 encoded private key and certificate chain. + */ + pfxPath?: string; /** * Passphrase for the private key (PEM or PFX). */ passphrase?: string; - - /** - * Path to the PFX or PKCS12 encoded private key and certificate chain. - */ - pfx?: string; }>; }>; diff --git a/packages/playwright/types/test.d.ts b/packages/playwright/types/test.d.ts index 7650946b3a..68db00c9cc 100644 --- a/packages/playwright/types/test.d.ts +++ b/packages/playwright/types/test.d.ts @@ -5225,10 +5225,10 @@ export interface PlaywrightTestOptions { * use: { * ...devices['Desktop Edge'], * clientCertificates: [{ - * url: 'https://example.com', + * url: 'https://example.com/**', * certs: [{ - * cert: 'client/alice_cert.pem', - * key: 'client/alice_key.pem', + * certPath: './cert.pem', + * keyPath: './key.pem', * passphase: 'mysecretpassword', * }], * }], diff --git a/tests/library/client-certificates.spec.ts b/tests/library/client-certificates.spec.ts index 94a321ee16..ede2164ddc 100644 --- a/tests/library/client-certificates.spec.ts +++ b/tests/library/client-certificates.spec.ts @@ -65,10 +65,10 @@ const kValidationSubTests: [BrowserContextOptions, string][] = [ clientCertificates: [{ url: 'test', certs: [{ - cert: kDummyFileName, - key: kDummyFileName, + certPath: kDummyFileName, + keyPath: kDummyFileName, + pfxPath: kDummyFileName, passphrase: kDummyFileName, - pfx: kDummyFileName, }] }] }, 'pfx is specified together with cert, key or passphrase'], @@ -77,10 +77,10 @@ const kValidationSubTests: [BrowserContextOptions, string][] = [ clientCertificates: [{ url: 'test', certs: [{ - cert: kDummyFileName, - key: kDummyFileName, + certPath: kDummyFileName, + keyPath: kDummyFileName, + pfxPath: kDummyFileName, passphrase: kDummyFileName, - pfx: kDummyFileName, }] }] }, 'Cannot specify both proxy and clientCertificates'], @@ -105,8 +105,8 @@ test.describe('fetch', () => { clientCertificates: [{ url: server.PREFIX, certs: [{ - cert: asset('client-certificates/client/alice_cert.pem'), - key: asset('client-certificates/client/alice_key.pem'), + certPath: asset('client-certificates/client/alice_cert.pem'), + keyPath: asset('client-certificates/client/alice_key.pem'), }], }], }); @@ -122,8 +122,8 @@ test.describe('fetch', () => { clientCertificates: [{ url: serverURL, certs: [{ - cert: asset('client-certificates/client/alice_cert.pem'), - key: asset('client-certificates/client/alice_key.pem'), + certPath: asset('client-certificates/client/alice_cert.pem'), + keyPath: asset('client-certificates/client/alice_key.pem'), }], }], }); @@ -136,8 +136,8 @@ test.describe('fetch', () => { clientCertificates: [{ url: serverURL, certs: [{ - cert: asset('client-certificates/client/bob_cert.pem'), - key: asset('client-certificates/client/bob_key.pem'), + certPath: asset('client-certificates/client/bob_cert.pem'), + keyPath: asset('client-certificates/client/bob_key.pem'), }], }], }); @@ -153,8 +153,8 @@ test.describe('fetch', () => { clientCertificates: [{ url: serverURL, certs: [{ - cert: asset('client-certificates/client/alice_cert.pem'), - key: asset('client-certificates/client/alice_key.pem'), + certPath: asset('client-certificates/client/alice_cert.pem'), + keyPath: asset('client-certificates/client/alice_key.pem'), }], }], ignoreHTTPSErrors: true, @@ -172,8 +172,8 @@ test.describe('fetch', () => { clientCertificates: [{ url: serverURL, certs: [{ - cert: asset('client-certificates/client/alice_cert.pem'), - key: asset('client-certificates/client/alice_key.pem'), + certPath: asset('client-certificates/client/alice_cert.pem'), + keyPath: asset('client-certificates/client/alice_key.pem'), }], }], }); @@ -201,8 +201,8 @@ test.describe('browser', () => { clientCertificates: [{ url: server.PREFIX, certs: [{ - cert: asset('client-certificates/client/alice_cert.pem'), - key: asset('client-certificates/client/alice_key.pem'), + certPath: asset('client-certificates/client/alice_cert.pem'), + keyPath: asset('client-certificates/client/alice_key.pem'), }], }], }); @@ -218,8 +218,8 @@ test.describe('browser', () => { clientCertificates: [{ url: 'https://not-matching.com', certs: [{ - cert: asset('client-certificates/client/alice_cert.pem'), - key: asset('client-certificates/client/alice_key.pem'), + certPath: asset('client-certificates/client/alice_cert.pem'), + keyPath: asset('client-certificates/client/alice_key.pem'), }], }], }); @@ -233,8 +233,8 @@ test.describe('browser', () => { clientCertificates: [{ url: serverURLRewrittenToLocalhost, certs: [{ - cert: asset('client-certificates/client/bob_cert.pem'), - key: asset('client-certificates/client/bob_key.pem'), + certPath: asset('client-certificates/client/bob_cert.pem'), + keyPath: asset('client-certificates/client/bob_key.pem'), }], }], }); @@ -249,8 +249,8 @@ test.describe('browser', () => { clientCertificates: [{ url: serverURLRewrittenToLocalhost, certs: [{ - cert: asset('client-certificates/client/alice_cert.pem'), - key: asset('client-certificates/client/alice_key.pem'), + certPath: asset('client-certificates/client/alice_cert.pem'), + keyPath: asset('client-certificates/client/alice_key.pem'), }], }], }); @@ -272,8 +272,8 @@ test.describe('browser', () => { clientCertificates: [{ url: serverURLRewrittenToLocalhost, certs: [{ - cert: asset('client-certificates/client/alice_cert.pem'), - key: asset('client-certificates/client/alice_key.pem'), + certPath: asset('client-certificates/client/alice_cert.pem'), + keyPath: asset('client-certificates/client/alice_key.pem'), }], }], });