@@ -23,7 +23,8 @@ const client = new ConfigClient('localhost:9090', {
2323| ` role ` | ` string ` | ` "superadmin" ` | Role for ` x-role ` metadata header |
2424| ` tenantId ` | ` string ` | — | Default tenant for ` x-tenant-id ` metadata header |
2525| ` token ` | ` string ` | — | Bearer token. When set, metadata headers are not sent |
26- | ` insecure ` | ` boolean ` | ` true ` | Use plaintext (no TLS) |
26+ | ` insecure ` | ` boolean ` | ` false ` | Use plaintext (no TLS) |
27+ | ` tls ` | ` TlsOptions ` | — | Custom CA or client cert/key for mTLS. Ignored when ` insecure ` is true |
2728| ` timeout ` | ` number ` | ` 10000 ` | Per-RPC timeout in milliseconds |
2829| ` retry ` | ` RetryConfig \| false ` | See below | Retry configuration. Set to ` false ` to disable |
2930
@@ -77,17 +78,55 @@ in the `authorization` metadata header. The `subject`, `role`, and
7778
7879## TLS
7980
80- By default, the SDK connects with plaintext ( ` insecure: true ` ). For
81- production, disable insecure mode to use TLS :
81+ By default, the SDK connects with TLS using the system certificate store. To
82+ use plaintext (local/dev only), set ` insecure: true ` :
8283
8384``` typescript
85+ const client = new ConfigClient (' localhost:9090' , {
86+ insecure: true ,
87+ });
88+ ```
89+
90+ ### Custom CA
91+
92+ To connect to a server with a private CA (self-signed or internal PKI):
93+
94+ ``` typescript
95+ import { readFileSync } from ' node:fs' ;
96+
8497const client = new ConfigClient (' production:9090' , {
85- insecure: false ,
98+ tls: {
99+ rootCerts: readFileSync (' /path/to/ca.pem' ),
100+ },
86101});
87102```
88103
89- This uses ` @grpc/grpc-js ` default TLS credentials, which trust the system
90- certificate store.
104+ ### mTLS (Mutual TLS)
105+
106+ To present a client certificate for mTLS authentication:
107+
108+ ``` typescript
109+ import { readFileSync } from ' node:fs' ;
110+
111+ const client = new ConfigClient (' production:9090' , {
112+ tls: {
113+ rootCerts: readFileSync (' /path/to/ca.pem' ),
114+ privateKey: readFileSync (' /path/to/client.key' ),
115+ certChain: readFileSync (' /path/to/client.crt' ),
116+ },
117+ });
118+ ```
119+
120+ ` rootCerts ` , ` privateKey ` , and ` certChain ` are all optional. Omit
121+ ` rootCerts ` to use the system store while still sending a client cert.
122+
123+ ### TlsOptions
124+
125+ | Option | Type | Description |
126+ | --------| ------| -------------|
127+ | ` rootCerts ` | ` Buffer ` | PEM-encoded root CA certificate(s). Overrides the system store |
128+ | ` privateKey ` | ` Buffer ` | PEM-encoded client private key for mTLS |
129+ | ` certChain ` | ` Buffer ` | PEM-encoded client certificate chain for mTLS |
91130
92131## Retry
93132
0 commit comments