(node:17764) [DEP0123] DeprecationWarning: Setting the TLS ServerName to an IP address is not permitted by RFC 6066. This will be ignored in a future version. (Use `node --trace-deprecation ...` to show where the warning was created) ConnectionError: Failed to connect to 192.168.10.223:1433 - self signed certificate at D:\FangcloudV2\servodynamics\SystemDevelop\plugin-code\node_modules\mssql\lib\tedious\connection-pool.js:70:17 at Connection.onConnect (D:\FangcloudV2\servodynamics\SystemDevelop\plugin-code\node_modules\tedious\lib\connection.js:1012:9) at Object.onceWrapper (node:events:642:26) at Connection.emit (node:events:527:28) at Connection.emit (D:\FangcloudV2\servodynamics\SystemDevelop\plugin-code\node_modules\tedious\lib\connection.js:1040:18) at Connection.socketError (D:\FangcloudV2\servodynamics\SystemDevelop\plugin-code\node_modules\tedious\lib\connection.js:1395:12) at D:\FangcloudV2\servodynamics\SystemDevelop\plugin-code\node_modules\tedious\lib\connection.js:2402:25 at processTicksAndRejections (node:internal/process/task_queues:96:5) { code: 'ESOCKET', originalError: ConnectionError: Failed to connect to 192.168.10.223:1433 - self signed certificate at Connection.socketError (D:\FangcloudV2\servodynamics\SystemDevelop\plugin-code\node_modules\tedious\lib\connection.js:1395:28) at D:\FangcloudV2\servodynamics\SystemDevelop\plugin-code\node_modules\tedious\lib\connection.js:2402:25 at processTicksAndRejections (node:internal/process/task_queues:96:5) { code: 'ESOCKET', isTransient: undefined }
时间: 2023-07-22 22:09:07 浏览: 299
这个错误提示涉及到两个问题。
首先,关于 `DeprecationWarning` 的警告,它是在你的代码中使用了将来版本中将被忽略的功能。具体来说,警告指出在 `TLS ServerName` 中使用 IP 地址是不被 RFC 6066 允许的。你可以通过运行 `node --trace-deprecation` 命令来查看警告产生的位置,然后根据警告信息修改代码以避免使用这个功能。
其次,关于 `ConnectionError: Failed to connect to 192.168.10.223:1433 - self signed certificate` 的错误,它表示连接到目标地址时发生了错误。这个错误是由于目标服务器使用了自签名证书,而你的客户端不信任这个证书引起的。
解决这个问题的方法是在客户端中信任这个自签名证书。你可以通过设置 `rejectUnauthorized` 选项为 `false` 来实现,示例如下:
```javascript
const config = {
server: '192.168.10.223',
port: 1433,
user: 'your_username',
password: 'your_password',
database: 'your_database',
options: {
encrypt: true,
trustServerCertificate: true,
requestTimeout: 30000,
// 添加以下选项
cryptoCredentialsDetails: {
rejectUnauthorized: false
}
}
};
// 使用上述配置创建数据库连接
```
请注意,这会禁用对证书的验证,因此需要谨慎使用。如果你有其他可信的证书,建议使用它们来代替自签名证书,以确保连接的安全性。
希望这些信息对你有帮助!如果你还有其他问题,请随时提问。
阅读全文