8000 fix: add pfxBase64 to jsonCert instead of params (#1746) · microsoft/playwright-java@995cf90 · GitHub
[go: up one dir, main page]

Skip to content

Commit 995cf90

Browse files
authored
fix: add pfxBase64 to jsonCert instead of params (#1746)
1 parent 87152ec commit 995cf90

File tree

3 files changed

+20
-2
lines changed

3 files changed

+20
-2
lines changed

playwright/src/main/java/com/microsoft/playwright/impl/Utils.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,7 @@ static void addToProtocol(JsonObject params, List<ClientCertificate> clientCerti
434434
}
435435
String pfxBase64 = base64Buffer(cert.pfx, cert.pfxPath);
436436
if (pfxBase64 != null) {
437-
params.addProperty("pfx", pfxBase64);
437+
jsonCert.addProperty("pfx", pfxBase64);
438438
}
439439
} catch (IOException e) {
440440
throw new PlaywrightException("Failed to read from file", e);

playwright/src/test/java/com/microsoft/playwright/TestClientCertificates.java

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package com.microsoft.playwright;
22

33
import com.microsoft.playwright.options.ClientCertificate;
4-
import com.microsoft.playwright.options.Proxy;
54
import org.junit.jupiter.api.AfterAll;
65
import org.junit.jupiter.api.BeforeAll;
76
import org.junit.jupiter.api.Test;
@@ -120,6 +119,25 @@ public void passWithTrustedClientCertificates() {
120119
request.dispose();
121120
}
122121

122+
@Test
123+
public void passWithTrustedClientCertificatesPfx() {
124+
APIRequest.NewContextOptions requestOptions = new APIRequest.NewContextOptions()
125+
.setIgnoreHTTPSErrors(true) // TODO: remove once we can pass a custom CA.
126+
.setClientCertificates(asList(
127+
new ClientCertificate(customServer.origin)
128+
.setPfxPath(asset("client-certificates/client/trusted/client_keystore.p12"))
129+
.setPassphrase("passphrase")));
130+
131+
APIRequestContext request = playwright.request().newContext(requestOptions);
132+
APIResponse response = request.get(customServer.url);
133+
134+
assertEquals(customServer.url, response.url());
135+
assertEquals(200, response.status());
136+
assertTrue(response.text().contains("Hello CN=Alice, your certificate was issued by O=Client Certificate Demo,CN=localhost!"), response.text());
137+
138+
request.dispose();
139+
}
140+
123141
static boolean isWebKitMacOS() {
124142
return isWebKit() && isMac;
125143
}

0 commit comments

Comments
 (0)
0