TLS exchange FAILS between Azure cosmos db and client Node 18.14.2 openssl 3.0.8+quic

Isha Padmanaban 0 Reputation points
2023-02-22T18:51:43.3366667+00:00

Hi, I have setup Azure cosmos db and written a simple conn.ts script to create document in cosmos db. I am using Node 18.14.2 which has built-in openssl 3.0.8+quic in it. I am getting an error as shown below:

**The same code works fine with Node version v16.19.1 which has openssl 1.1.1t+quic version.
**
Is Azure server not compatible for Node 18 openssl 3 version? Or should I need to change anything in my conn.ts to make the connection work?

ERROR :

$ npx ts-node conn.ts
v18.14.2
(node:12796) Warning: Accessing non-existent property 'zero' of module exports inside circular dependency
(Use node --trace-warnings ... to show where the warning was created)
Failed to insert document: Error: write EPROTO A8590000:error:0A00014D:SSL routines:tls_process_key_exchange:legacy sigalg disallowed or unsupported:c:\ws\deps\openssl\openssl\ssl\statem\statem_clnt.c:2263:

at WriteWrap.onWriteComplete [as oncomplete] (node:internal/stream_base_commons:94:16) {

errno: -4046,
code: 'EPROTO',
syscall: 'write',
isTimedout: false,
duration: 110
}

Please find the contents of conn.ts:

import * as DocumentDB from 'documentdb';

console.log(process.version);
console.log(process.versions.openssl);

// Set up the Cosmos DB client
const endpoint = ****;
const key = ****;
const databaseId = ****;
const collectionId = ****;

const client = new DocumentDB.DocumentClient(endpoint, {
masterKey: key,
});

// Define a sample document to insert
const document = {
id: 'hello-world',
message: 'Hello, World!',
};

// Insert the document
client.createDocument(
dbs/${databaseId}/colls/${collectionId},
document,
(error, createdDocument) => {
if (error) {
console.error('Failed to insert document:', error);
} else {
console.log('Document inserted successfully:', createdDocument);
}
}
);

Azure Cosmos DB
Azure Cosmos DB
An Azure NoSQL database service for app development.
1,400 questions
{count} votes

1 answer

Sort by: Most helpful
  1. erastus iilonga 30 Reputation points
    2023-03-25T08:48:29.93+00:00

    That can be solved by bumping the Cosmos DB client to the latest version like that in package.json:

    "@azure/cosmos": "^3.17.3",

    That would require a small change in the db.js file:

    client = new CosmosClient({ endpoint, key: masterKey });

    credit to @ https://github.com/MicrosoftDocs/mslearn-advocates.azure-functions-and-signalr/issues/41#issuecomment-1473677091

    6 people found this answer helpful.
    0 comments No comments