MCPcopy Index your code
hub / github.com/microsoft/playwright-python / to_client_certificates_protocol

Function to_client_certificates_protocol

playwright/_impl/_network.py:95–126  ·  view source on GitHub ↗
(
    clientCertificates: Optional[List[ClientCertificate]],
)

Source from the content-addressed store, hash-verified

93
94
95async def to_client_certificates_protocol(
96 clientCertificates: Optional[List[ClientCertificate]],
97) -> Optional[List[Dict[str, str]]]:
98 if not clientCertificates:
99 return None
100 out = []
101 for clientCertificate in clientCertificates:
102 out_record = {
103 "origin": clientCertificate["origin"],
104 }
105 if passphrase := clientCertificate.get("passphrase"):
106 out_record["passphrase"] = passphrase
107 if pfx := clientCertificate.get("pfx"):
108 out_record["pfx"] = base64.b64encode(pfx).decode()
109 if pfx_path := clientCertificate.get("pfxPath"):
110 out_record["pfx"] = base64.b64encode(
111 await async_readfile(pfx_path)
112 ).decode()
113 if cert := clientCertificate.get("cert"):
114 out_record["cert"] = base64.b64encode(cert).decode()
115 if cert_path := clientCertificate.get("certPath"):
116 out_record["cert"] = base64.b64encode(
117 await async_readfile(cert_path)
118 ).decode()
119 if key := clientCertificate.get("key"):
120 out_record["key"] = base64.b64encode(key).decode()
121 if key_path := clientCertificate.get("keyPath"):
122 out_record["key"] = base64.b64encode(
123 await async_readfile(key_path)
124 ).decode()
125 out.append(out_record)
126 return out
127
128
129class Request(ChannelOwner):

Callers 2

new_contextMethod · 0.90

Calls 3

async_readfileFunction · 0.90
appendMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected