You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by GitBox <gi...@apache.org> on 2022/10/19 09:32:02 UTC
[GitHub] [pulsar] nodece commented on a diff in pull request #15485: [improve][doc] Add code example for WebSocket API to use TLS with CLI tools
nodece commented on code in PR #15485:
URL: https://github.com/apache/pulsar/pull/15485#discussion_r999189147
##########
site2/docs/security-tls-transport.md:
##########
@@ -324,6 +324,46 @@ var client = PulsarClient.Builder()
> Note that `VerifyCertificateName` refers to the configuration of hostname verification in the C# client.
+</TabItem>
+<TabItem value="WebSocket API">
+
+```python
+import websockets
+import asyncio
+import base64
+import json
+import ssl
+import pathlib
+
+ssl_context = ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT)
Review Comment:
```suggestion
ssl_context = ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT)
client_cert_pem = pathlib.Path(__file__).with_name("client.cert.pem")
client_key_pem = pathlib.Path(__file__).with_name("client.key.pem")
ca_cert_pem = pathlib.Path(__file__).with_name("ca.cert.pem")
ssl_context.load_cert_chain(certfile=client_cert_pem, keyfile=client_key_pem)
ssl_context.load_verify_locations(ca_cert_pem)
# websocket producer uri wss, not ws
uri = "wss://localhost:8080/ws/v2/producer/persistent/public/default/testtopic"
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org