{"id":20231000,"url":"https://github.com/bewaremypower/pulsar-tls-examples","last_synced_at":"2025-10-08T07:39:40.745Z","repository":{"id":109020574,"uuid":"605609493","full_name":"BewareMyPower/pulsar-tls-examples","owner":"BewareMyPower","description":null,"archived":false,"fork":false,"pushed_at":"2023-02-23T17:04:51.000Z","size":6,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-08-15T15:45:58.153Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/BewareMyPower.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-02-23T14:22:34.000Z","updated_at":"2023-02-23T14:23:42.000Z","dependencies_parsed_at":"2023-08-26T16:30:35.666Z","dependency_job_id":null,"html_url":"https://github.com/BewareMyPower/pulsar-tls-examples","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/BewareMyPower/pulsar-tls-examples","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BewareMyPower%2Fpulsar-tls-examples","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BewareMyPower%2Fpulsar-tls-examples/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BewareMyPower%2Fpulsar-tls-examples/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BewareMyPower%2Fpulsar-tls-examples/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/BewareMyPower","download_url":"https://codeload.github.com/BewareMyPower/pulsar-tls-examples/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BewareMyPower%2Fpulsar-tls-examples/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278909716,"owners_count":26066887,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-08T02:00:06.501Z","response_time":56,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-14T07:44:45.748Z","updated_at":"2025-10-08T07:39:40.724Z","avatar_url":"https://github.com/BewareMyPower.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# pulsar-tls-examples\n\nExamples for TLS encription. It tested two cases:\n1. TLS encryption + JWT authentication\n2. TLS encryption + OAuth2 authentication\n\n## Configure the connection info\n\nBefore running examples under [python](./python) directory, you should configure some environment variables of the connection info.\n\nFor JWT authentication, you should fill the environment variables in [token_env.sh](./token_env.sh) and run:\n\n```bash\nsource token_env.sh\n```\n\nFor OAuth2 authentication, you should fill the environment variables in [oauth_env.sh](./oauth_env.sh) and run:\n\n```bash\nsource oauth_env.sh\n```\n\n## Install the Python client\n\nGo to the [python](./python) directory, install the Python client 3.1.0 candidate 3:\n\n```bash\n# Choose the wheel according to your OS and Python version\n./install.sh https://dist.apache.org/repos/dist/dev/pulsar/pulsar-client-python-3.1.0-candidate-3/linux-glibc-x86_64/pulsar_client-3.1.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl\n```\n\nThen, run:\n- `python3 token_tls.py` for JWT authentication\n- `python3 oauth_tls.py` for OAuth2 authentication\n\n## Install the Node.js client\n\nGo to the [node](./node) directory, install the Node.js client 1.8.0 candidate 1:\n\n```bash\nnpm install pulsar-client@1.8.1-rc.1 --pulsar_binary_host_mirror=https://dist.apache.org/repos/dist/dev/pulsar/pulsar-client-node/\n```\n\nThen, run:\n- `node token_tls.js` for JWT authentication\n- `node oauth_tls.js` for OAuth2 authentication\n\n## Test result conclusion\n\n| OS | Authentication | Python | Node.js |\n| :- | :- | :- | :- |\n| Ubuntu 20.04 | JWT | OK | OK |\n| Ubuntu 20.04 | OAuth2 | OK | Failed |\n| Windows 10 | JWT | OK | Failed |\n| Windows 10 | OAuth2 | OK | Failed |\n| macOS Ventura 13.2.1 | JWT | OK | Failed |\n| macOS Ventura 13.2.1 | OAuth2 | OK | **(TODO)** |\n\n### Test results on Ubuntu 20.04\n\nPython 3.8.10, Node.js v16.19.0.\n\nJWT authentication: both succeeded.\n\nOAuth2 authentication: Python client succeeded, Node.js client failed:\n\n```\n[INFO][ClientConnection:190] [\u003cnone\u003e -\u003e \u003cservice-url\u003e] Create ClientConnection, timeout=10000\n[ERROR][AuthOauth2:229] Response failed for getting the well-known configuration https://auth.streamnative.cloud/. Error Code 77: error setting certificate verify locations:  CAfile: /etc/pki/tls/certs/ca-bundle.crt CApath: none\n[INFO][ConnectionPool:97] Created connection for \u003cservice-url\u003e\n[INFO][ClientConnection:388] [172.22.62.199:49472 -\u003e \u003cremote-ip\u003e:6651] Connected to broker\n[ERROR][ClientConnection:498] [172.22.62.199:49472 -\u003e \u003cremote-ip\u003e:6651] Failed to establish connection: AuthenticationError\n[INFO][ClientConnection:1600] [172.22.62.199:49472 -\u003e \u003cremote-ip\u003e:6651] Connection closed with AuthenticationError\n[ERROR][ClientImpl:184] Error Checking/Getting Partition Metadata while creating producer on persistent://public/default/my-topic -- AuthenticationError\n[INFO][ClientConnection:269] [172.22.62.199:49472 -\u003e \u003cremote-ip\u003e:6651] Destroyed connection\nnode:internal/process/promises:279\n            triggerUncaughtException(err, true /* fromPromise */);\n            ^\n\n[Error: Failed to create producer: AuthenticationError]\n```\n\n### Test results on Windows\n\nPython 3.10.9, Node.js v18.12.1.\n\n\u003e **NOTE**:\n\u003e\n\u003e On Windows, you should replace `python3` with `py` in PowerShell. And you have to set the environment variables manually.\n\nJWT authentication: Python client succeeded, Node.js client failed:\n\n```\n[INFO][D:\\a\\pulsar-client-cpp\\pulsar-client-cpp\\lib\\ClientConnection:190] [\u003cnone\u003e -\u003e \u003cservice-url\u003e] Create ClientConnection, timeout=10000\n[INFO][D:\\a\\pulsar-client-cpp\\pulsar-client-cpp\\lib\\ConnectionPool:97] Created connection for \u003cservice-url\u003e\n[INFO][D:\\a\\pulsar-client-cpp\\pulsar-client-cpp\\lib\\ClientConnection:388] [192.168.16.101:2334 -\u003e \u003cremote-ip\u003e:6651] Connected to broker\n[ERROR][D:\\a\\pulsar-client-cpp\\pulsar-client-cpp\\lib\\ClientConnection:488] [192.168.16.101:2334 -\u003e \u003cremote-ip\u003e:6651] Handshake failed: unregistered scheme (STORE routines)\n[INFO][D:\\a\\pulsar-client-cpp\\pulsar-client-cpp\\lib\\ClientConnection:1600] [192.168.16.101:2334 -\u003e \u003cremote-ip\u003e:6651] Connection closed with ConnectError\n[ERROR][D:\\a\\pulsar-client-cpp\\pulsar-client-cpp\\lib\\ClientImpl:184] Error Checking/Getting Partition Metadata while creating producer on persistent://public/default/my-topic -- ConnectError\n[INFO][D:\\a\\pulsar-client-cpp\\pulsar-client-cpp\\lib\\ClientConnection:269] [192.168.16.101:2334 -\u003e \u003cremote-ip\u003e:6651] Destroyed connection\nnode:internal/process/promises:288\n            triggerUncaughtException(err, true /* fromPromise */);\n            ^\n\n[Error: Failed to create producer: ConnectError]\n```\n\nOAuth2 authentication: Python client succeeded, Node.js client failed:\n\n```\n[INFO][D:\\a\\pulsar-client-cpp\\pulsar-client-cpp\\lib\\ClientConnection:190] [\u003cnone\u003e -\u003e \u003cservice-url\u003e] Create ClientConnection, timeout=10000\n[INFO][D:\\a\\pulsar-client-cpp\\pulsar-client-cpp\\lib\\ConnectionPool:97] Created connection for \u003cservice-url\u003e\n[INFO][D:\\a\\pulsar-client-cpp\\pulsar-client-cpp\\lib\\ClientConnection:388] [192.168.16.101:2459 -\u003e \u003cremote-ip\u003e:6651] Connected to broker\n[ERROR][D:\\a\\pulsar-client-cpp\\pulsar-client-cpp\\lib\\ClientConnection:488] [192.168.16.101:2459 -\u003e \u003cremote-ip\u003e:6651] Handshake failed: unregistered scheme (STORE routines)\n[INFO][D:\\a\\pulsar-client-cpp\\pulsar-client-cpp\\lib\\ClientConnection:1600] [192.168.16.101:2459 -\u003e \u003cremote-ip\u003e:6651] Connection closed with ConnectError\n[ERROR][D:\\a\\pulsar-client-cpp\\pulsar-client-cpp\\lib\\ClientImpl:184] Error Checking/Getting Partition Metadata while creating producer on persistent://public/default/my-topic -- ConnectError\n[INFO][D:\\a\\pulsar-client-cpp\\pulsar-client-cpp\\lib\\ClientConnection:269] [192.168.16.101:2459 -\u003e \u003cremote-ip\u003e:6651] Destroyed connection\nnode:internal/process/promises:288\n            triggerUncaughtException(err, true /* fromPromise */);\n            ^\n\n[Error: Failed to create producer: ConnectError]\n```\n\n### Test results on macOS\n\nPython 3.10.9, Node.js v16.17.0.\n\nJWT authentication: Python client succeeded, Node.js client failed:\n\n```\n[INFO][ClientConnection:190] [\u003cnone\u003e -\u003e \u003cservice-url\u003e] Create ClientConnection, timeout=10000\n[INFO][ConnectionPool:97] Created connection for \u003cservice-url\u003e\n[INFO][ClientConnection:388] [10.6.103.176:49745 -\u003e \u003cremote-ip\u003e:6651] Connected to broker\n[ERROR][ClientConnection:488] [10.6.103.176:49745 -\u003e \u003cremote-ip\u003e:6651] Handshake failed: certificate verify failed (SSL routines, tls_process_server_certificate)\n[INFO][ClientConnection:1600] [10.6.103.176:49745 -\u003e \u003cremote-ip\u003e:6651] Connection closed with ConnectError\n[ERROR][ClientImpl:184] Error Checking/Getting Partition Metadata while creating producer on persistent://public/default/my-topic -- ConnectError\n[INFO][ClientConnection:269] [10.6.103.176:49745 -\u003e \u003cremote-ip\u003e:6651] Destroyed connection\nnode:internal/process/promises:279\n            triggerUncaughtException(err, true /* fromPromise */);\n            ^\n\n[Error: Failed to create producer: ConnectError]\n```\n\nOAuth2 authentication: Python client succeeded, ~~Node.js client failed~~:\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbewaremypower%2Fpulsar-tls-examples","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbewaremypower%2Fpulsar-tls-examples","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbewaremypower%2Fpulsar-tls-examples/lists"}