Node.js 使用TypeORM连接MySQL数据库时如何禁用SSL
我正在尝试使用禁用SSL的TypeORM通过节点API连接到MySQL数据库。我使用MySQL2作为客户端来连接数据库 我在ormconfig中使用不同的连接选项做了很多更改,但没有一个成功 ormconfig.tsNode.js 使用TypeORM连接MySQL数据库时如何禁用SSL,node.js,ssl,mysql2,typeorm,Node.js,Ssl,Mysql2,Typeorm,我正在尝试使用禁用SSL的TypeORM通过节点API连接到MySQL数据库。我使用MySQL2作为客户端来连接数据库 我在ormconfig中使用不同的连接选项做了很多更改,但没有一个成功 ormconfig.ts // import { // SSL_OP_NO_SSLv2, // SSL_OP_NO_SSLv3, // SSL_OP_NO_TLSv1, // SSL_OP_NO_TLSv1_1, // SSL_OP_NO_TLSv1_2 // } from "const
// import {
// SSL_OP_NO_SSLv2,
// SSL_OP_NO_SSLv3,
// SSL_OP_NO_TLSv1,
// SSL_OP_NO_TLSv1_1,
// SSL_OP_NO_TLSv1_2
// } from "constants";
import { ConnectionOptions } from "typeorm";
export function getConfig() {
const isTest = process.env.NODE_ENV === "test";
// const secureOptionsBitMask: number =
// SSL_OP_NO_SSLv2 |
// SSL_OP_NO_SSLv3 |
// SSL_OP_NO_TLSv1 |
// SSL_OP_NO_TLSv1_1 |
// SSL_OP_NO_TLSv1_2;
return {
autoSchemaSync: false,
database: DB_NAME,
entities: DB_ENTITIES,
host: DB_HOST,
logging: "all",
migrations: "./test/*-migration.ts",
migrationsRun: isTest,
password: DB_PASS,
port: DB_PORT,
ssl: {},
synchronize: false,
type: DB_TYPE,
username: DB_USER
} as ConnectionOptions;
}
server.js
import { Connection, createConnection } from 'typeorm';
import { getConfig } from '../../ormconfig';
let dbConnection: Connection;
...
dbConnection = await createConnection(getConfig());
...