denoland/deno · error · TypeError

ERR_TLS_PROTOCOL_VERSION_CONFLICT

ERR_TLS_PROTOCOL_VERSION_CONFLICT

Error message

TLS protocol version ${minVersion || maxVersion} conflicts with secureProtocol secureProtocol

What it means

ERR_TLS_PROTOCOL_VERSION_CONFLICT from _tls_common's getProtocolRange(): TLS socket options accept either the legacy secureProtocol method selector (e.g. 'TLSv1_2_method') or the modern minVersion/maxVersion range — never both. If secureProtocol is set and minVersion or maxVersion is also truthy, the conflict is thrown before any other validation, echoing the offending version string.

Solutions

  1. Delete secureProtocol and keep minVersion/maxVersion (the modern style)
  2. Or keep secureProtocol and remove minVersion/maxVersion entirely
  3. Best modern default: minVersion: 'TLSv1.2', maxVersion: 'TLSv1.3'

Example fix

// before
tls.connect({ secureProtocol: 'TLSv1_2_method', minVersion: 'TLSv1.2', host }); // throws

// after
tls.connect({ minVersion: 'TLSv1.2', maxVersion: 'TLSv1.3', host });
Defensive patterns

Strategy: validation

Validate before calling

if (opts.secureProtocol && (opts.minVersion || opts.maxVersion)) {
  throw new Error('secureProtocol cannot be combined with minVersion/maxVersion');
}

Prevention

When it happens

Trigger: tls.connect({ secureProtocol: 'TLSv1_2_method', minVersion: 'TLSv1.2' }); https.createServer({ secureProtocol: 'SSLv23_method', maxVersion: 'TLSv1.3' }, handler);

Common situations: Legacy codebases carrying secureProtocol that receive a TLS-hardening patch adding minVersion; merged configs combining old and new styles; guidance copied from docs of different eras.

Understand the failure class

Related errors


AI-assisted analysis of denoland/deno@9ad36f7a2c (2026-08-20). Data as JSON: /api/errors/0dd96aea98d01fbc. Report an issue: GitHub.

Appendix: source

Thrown at ext/node/polyfills/_tls_common.ts:297

    return ArrayPrototypeFilter(
      ArrayPrototypeMap(val, (v: any) => toStringOrUndefined(v)!),
      Boolean,
    );
  }
  return toStringOrUndefined(val);
}

function getProtocolRange(
  options: any,
): { minVersion: string; maxVersion: string } {
  let minVersion = getDefaultMinVersion();
  let maxVersion = getDefaultMaxVersion();

  if (options.secureProtocol) {
    // If secureProtocol is set, minVersion/maxVersion must not also be set.
    // Node raises this conflict before validating the protocol method string.
    if (options.minVersion || options.maxVersion) {
      throw new ERR_TLS_PROTOCOL_VERSION_CONFLICT(
        options.minVersion || options.maxVersion,
        "secureProtocol",
      );
    }

    const range = kProtocolMap[options.secureProtocol];
    if (!range) {
      if (
        options.secureProtocol === "SSLv2_method" ||
        options.secureProtocol === "SSLv2_client_method" ||
        options.secureProtocol === "SSLv2_server_method"
      ) {
        throw new ERR_TLS_INVALID_PROTOCOL_METHOD("SSLv2 methods disabled");
      }
      if (
        options.secureProtocol === "SSLv3_method" ||
        options.secureProtocol === "SSLv3_client_method" ||
        options.secureProtocol === "SSLv3_server_method"

View on GitHub (pinned to 9ad36f7a2c)