SQL Server Connection with NodeJS - Certificate is not yet valid

y3bcpkx1  于 2023-06-28  发布在  SQL Server
关注(0)|答案(1)|浏览(153)

I am new to SQL Server and i am trying to establish connection between Nodejs and SQL Server which is hosted on my Local Machine which is authenticated using Windows Authentication

Here is my Connection Configurations

const sql = require("mssql");
require("msnodesqlv8");
const conn = new sql.ConnectionPool({
  database: "ApplicantsData",
  server: "localhost",
  driver: "msnodesqlv8",
  options: {
    trustedConnection: true,
    TrustServerCertificate:true
  }
});
conn.connect().then(() => {
//check
});

whenever i try to connect i got an error of

Failed to connect to localhost:1433 - certificate is not yet valid

i have searched for this type of error and i ensured that:

  1. TCP/IP enabled using SQL Server Configurations
  2. Enabled SQL Server Browsing

any solutions/fixes?

hmae6n7t

hmae6n7t1#

This is a problem with your current date and time of your IoT, where the nodejs is running(assume linux). set the date and time using below command.

date MMDDHHMMYYYY

for example
date 062611102023

then set the hwclock with

hwclock --systohc

run the .js again. enjoy

相关问题