Skip to content

As a user, I want to avoid specifying all the options for enabling TLS #265

@apietroni51

Description

@apietroni51

In ClientParams, ssl should be optional, or boolean as a shortcut. All SSLConnectionParams fields should be optional as supported by tls.connect()

export interface SSLConnectionParams {
  key?: string
  cert?: string
  ca?: string
  rejectUnauthorized?: boolean
}

Pseudocode for the socket creation:

private createSocket() {
    const socket = this.params.ssl
      ? tls.connect(this.params.port, this.params.hostname, typeof this.params.ssl === Boolean ? {} : this.params.ssl)
      : new Socket().connect(this.params.port, this.params.hostname)
    if (this.params.socketTimeout) socket.setTimeout(this.params.socketTimeout)
    return socket
}

This will also address #254

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions