fix: add pfxBase64 to jsonCert instead of params (#1746)

This commit is contained in:
stevenfuhr 2025-02-07 21:33:20 +01:00 committed by GitHub
parent 87152ecc71
commit 995cf902fb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 20 additions and 2 deletions

View File

@ -434,7 +434,7 @@ public class Utils {
}
String pfxBase64 = base64Buffer(cert.pfx, cert.pfxPath);
if (pfxBase64 != null) {
params.addProperty("pfx", pfxBase64);
jsonCert.addProperty("pfx", pfxBase64);
}
} catch (IOException e) {
throw new PlaywrightException("Failed to read from file", e);

View File

@ -1,7 +1,6 @@
package com.microsoft.playwright;
import com.microsoft.playwright.options.ClientCertificate;
import com.microsoft.playwright.options.Proxy;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
@ -120,6 +119,25 @@ public class TestClientCertificates extends TestBase {
request.dispose();
}
@Test
public void passWithTrustedClientCertificatesPfx() {
APIRequest.NewContextOptions requestOptions = new APIRequest.NewContextOptions()
.setIgnoreHTTPSErrors(true) // TODO: remove once we can pass a custom CA.
.setClientCertificates(asList(
new ClientCertificate(customServer.origin)
.setPfxPath(asset("client-certificates/client/trusted/client_keystore.p12"))
.setPassphrase("passphrase")));
APIRequestContext request = playwright.request().newContext(requestOptions);
APIResponse response = request.get(customServer.url);
assertEquals(customServer.url, response.url());
assertEquals(200, response.status());
assertTrue(response.text().contains("Hello CN=Alice, your certificate was issued by O=Client Certificate Demo,CN=localhost!"), response.text());
request.dispose();
}
static boolean isWebKitMacOS() {
return isWebKit() && isMac;
}