Hi Mattanapol Konguthaikul (TH)
Since you have already installed the certificate from the emulator but are still facing the error, here are a few additional things you can try:
Double-check that the certificate is correctly installed in your OS's trust store. If you're on Windows, ensure it's listed under the "Trusted Root Certification Authorities". You can use the certlm.msc
tool to verify this.
Make sure you’re running an up-to-date version of Node.js. If you're using an older version, consider updating it, as there may be fixes related to SSL/TLS connections in newer releases.
In your mongoose connection string, make sure you include the necessary options as follows:
mongoose.connect('mongodb://your-connection-string', {
ssl: true,
sslValidate: true,
sslCA: [fs.readFileSync('path_to_your_cert.pem')],
useNewUrlParser: true,
useUnifiedTopology: true,
});
Adjust the path to your PEM certificate as necessary.
If you are still having trouble, you might want to set environment variables which may help with certificate validation:
export NODE_TLS_REJECT_UNAUTHORIZED=0
(Note: This disables SSL validation and is not recommended for production environments. Only use for testing purposes.)
Ensure that there's no firewall or proxy blocking your connection. Sometimes, network configurations can interfere with SSL handshakes.
I request you click on this link for additional information https://learn.microsoft.com/en-us/azure/cosmos-db/emulator?tabs=ssl-netstd21#import-certificate
I hope this information helps. Please do let us know if you have any further queries.