Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Documented TLS Authentication with node https.Agent #259

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions docs/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,48 @@ const registry = new SchemaRegistry({
})
```

HTTP Agent configuration offer a high degree of customization for underlying both HTTP and HTTPS requests.

#### TLS/SSL Authentication

If your Schema Registry requires TLS/SSL Authentication you can pass a custom `https.Agent` to its constructor which accept the options available in [tls.createSecureSocket()](https://nodejs.org/docs/latest/api/tls.html#tlscreatesecurecontextoptions).

```js
import { Agent } from 'https'
import * as fs from 'fs'

const agent = new Agent({
ca: [ fs.readFileSync('/path/to/yourca.crt', 'utf-8') ],
Copy link

@silverwind silverwind Apr 17, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems unnecessary to wrap in [] because it accepts both string or string[]. The same thing is in kafkajs docs, but I think unnecessary there as well.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can confirm it works just as well without the [].

cert: fs.readFileSync('/path/to/yourcert.crt', 'utf-8'),
key: fs.readFileSync('/path/to/yourket.key', 'utf-8')
})

const registry = new SchemaRegistry({
host: 'http://localhost:8081',
agent
})
```

Alteratively if you have PKCS12/PFX encoded certificate and key you can pass it as shown below:

```js
import { Agent } from 'https'
import * as fs from 'fs'

const agent = new Agent({
pfx: {
buf: fs.readFileSync('/path/to/keystore.p12'),
passphrase: 'your-keystore-password'
}
})

const registry = new SchemaRegistry({
host: 'http://localhost:8081',
agent
})
```


### Schema type options

The second argument to the `SchemaRegistry` constructor is an object with keys for each `SchemaType`.
Expand Down