Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
(async () => {
const auth = new Pulsar.AuthenticationTls({
certificatePath: '/path/to/client.crt',
privateKeyPath: '/path/to/client.key',
});
// Create a client
const client = new Pulsar.Client({
serviceUrl: 'pulsar+ssl://localhost:6651',
authentication: auth,
tlsTrustCertsFilePath: '/path/to/server.crt',
});
// Create a producer
const producer = await client.createProducer({
topic: 'persistent://public/default/my-topic',
});
(async () => {
const auth = new Pulsar.AuthenticationTls({
certificatePath: '/path/to/client.crt',
privateKeyPath: '/path/to/client.key',
});
// Create a client
const client = new Pulsar.Client({
serviceUrl: 'pulsar+ssl://localhost:6651',
authentication: auth,
tlsTrustCertsFilePath: '/path/to/server.crt',
});
// Create a consumer
const consumer = await client.subscribe({
topic: 'persistent://public/default/my-topic',
subscription: 'sub1',
subscriptionType: 'Shared',