(
clientCertificates: Optional[List[ClientCertificate]],
)
| 93 | |
| 94 | |
| 95 | async 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 | |
| 129 | class Request(ChannelOwner): |
no test coverage detected