11cb0ef41Sopenharmony_ci'use strict';
21cb0ef41Sopenharmony_ci
31cb0ef41Sopenharmony_ciconst common = require('../common');
41cb0ef41Sopenharmony_ciconst fixtures = require('../common/fixtures');
51cb0ef41Sopenharmony_ci
61cb0ef41Sopenharmony_ci// Confirm that for TLSv1.3, renegotiate() is disallowed.
71cb0ef41Sopenharmony_ci
81cb0ef41Sopenharmony_ciconst {
91cb0ef41Sopenharmony_ci  assert, connect, keys
101cb0ef41Sopenharmony_ci} = require(fixtures.path('tls-connect'));
111cb0ef41Sopenharmony_ci
121cb0ef41Sopenharmony_ciconst server = keys.agent10;
131cb0ef41Sopenharmony_ci
141cb0ef41Sopenharmony_ciconnect({
151cb0ef41Sopenharmony_ci  client: {
161cb0ef41Sopenharmony_ci    ca: server.ca,
171cb0ef41Sopenharmony_ci    checkServerIdentity: common.mustCall(),
181cb0ef41Sopenharmony_ci  },
191cb0ef41Sopenharmony_ci  server: {
201cb0ef41Sopenharmony_ci    key: server.key,
211cb0ef41Sopenharmony_ci    cert: server.cert,
221cb0ef41Sopenharmony_ci  },
231cb0ef41Sopenharmony_ci}, function(err, pair, cleanup) {
241cb0ef41Sopenharmony_ci  assert.ifError(err);
251cb0ef41Sopenharmony_ci
261cb0ef41Sopenharmony_ci  const client = pair.client.conn;
271cb0ef41Sopenharmony_ci
281cb0ef41Sopenharmony_ci  assert.strictEqual(client.getProtocol(), 'TLSv1.3');
291cb0ef41Sopenharmony_ci
301cb0ef41Sopenharmony_ci  const ok = client.renegotiate({}, common.mustCall((err) => {
311cb0ef41Sopenharmony_ci    assert.throws(() => { throw err; }, {
321cb0ef41Sopenharmony_ci      message: common.hasOpenSSL3 ?
331cb0ef41Sopenharmony_ci        'error:0A00010A:SSL routines::wrong ssl version' :
341cb0ef41Sopenharmony_ci        'error:1420410A:SSL routines:SSL_renegotiate:wrong ssl version',
351cb0ef41Sopenharmony_ci      code: 'ERR_SSL_WRONG_SSL_VERSION',
361cb0ef41Sopenharmony_ci      library: 'SSL routines',
371cb0ef41Sopenharmony_ci      reason: 'wrong ssl version',
381cb0ef41Sopenharmony_ci    });
391cb0ef41Sopenharmony_ci    cleanup();
401cb0ef41Sopenharmony_ci  }));
411cb0ef41Sopenharmony_ci
421cb0ef41Sopenharmony_ci  assert.strictEqual(ok, false);
431cb0ef41Sopenharmony_ci});
44