Cannot use Connector with SQL Server if SSL is enforced

Đang mở
#230 3 bình luận 0 reaction 1 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

@hessjcg đang làm issue này rồi.

Từ ngày 24/4/2025.

  • #578 của @Haihan-Jiang — đang mở

Đánh giá

Issue này chưa được đánh giá.

Mô tả

priority: p2 type: cleanup type: docs

Bug Description

I guess this should be considered a bug. I know that we do not need to enforce SSL when using a Connector, since it handles secure connection for us. However, on the other hand, with PostgreSQL and MySQL, we can use Connector even when SSL is enforced, so this makes SQL Server an exception where it doesn't work.

I know that Connector returns tedious options with encrypt: false so that connection is not double-encrypted. But perhaps there should be a way for tedious to know that we are already passing secure connection.

Example code

import { AuthTypes, Connector, IpAddressTypes } from '@google-cloud/cloud-sql-connector'
import knex from 'knex'

const clientOpts = await connector.getTediousOptions({
  instanceConnectionName: 'my-project.my-region.my-instance',
  ipType: IpAddressTypes.PUBLIC,
  authType: AuthTypes.PASSWORD,
})

const database = knex({
  client: 'mssql',
  connection: {
    server: '0.0.0.0', # dummy value due to a bug
    user: 'user',
    password: 'password',
    database: 'database',
    options: {
      ...clientOpts,
    },
  }
})

const result = await database.first(database.raw(`'True' AS connected`))

Stacktrace

ConnectionError: Server requires encryption, set 'encrypt' config option to true.
    at /project/node_modules/tedious/src/connection.ts:3251:34
    at processTicksAndRejections (node:internal/process/task_queues:95:5) {
  code: 'EENCRYPT',
  isTransient: undefined
}

How to reproduce

  1. Create Cloud SQL Server instance.
  2. Check "Allow only SSL connections" checkbox.
  3. Connect using above example.
Environment details
  • OS: MacOS 11.6
  • Node.js version: v18.18.0
  • npm version: v9.8.1
  • connector version: 1.0.0
  • tedious version: 16.4.0
Ngôn ngữ chính
TypeScript
Star
99
Fork
18
Merge trung bình
1 ngày 23 giờ
Pull request đã merge (30 ngày)
20

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của GoogleCloudPlatform/cloud-sql-nodejs-connector

Tất cả issue của GoogleCloudPlatform/cloud-sql-nodejs-connector

Issue tương tự

Thêm issue về TypeScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.