11cb0ef41Sopenharmony_ci'use strict';
21cb0ef41Sopenharmony_ciconst common = require('../common');
31cb0ef41Sopenharmony_ci
41cb0ef41Sopenharmony_ciif (!common.hasCrypto)
51cb0ef41Sopenharmony_ci  common.skip('missing crypto');
61cb0ef41Sopenharmony_ci
71cb0ef41Sopenharmony_ciconst assert = require('assert');
81cb0ef41Sopenharmony_ciconst tls = require('tls');
91cb0ef41Sopenharmony_ci
101cb0ef41Sopenharmony_ci{
111cb0ef41Sopenharmony_ci  // Check tlsClientError on invalid pskIdentityHint.
121cb0ef41Sopenharmony_ci
131cb0ef41Sopenharmony_ci  const server = tls.createServer({
141cb0ef41Sopenharmony_ci    ciphers: 'PSK+HIGH',
151cb0ef41Sopenharmony_ci    pskCallback: () => {},
161cb0ef41Sopenharmony_ci    pskIdentityHint: 'a'.repeat(512), // Too long identity hint.
171cb0ef41Sopenharmony_ci  });
181cb0ef41Sopenharmony_ci  server.on('tlsClientError', (err) => {
191cb0ef41Sopenharmony_ci    assert.ok(err instanceof Error);
201cb0ef41Sopenharmony_ci    assert.strictEqual(err.code, 'ERR_TLS_PSK_SET_IDENTIY_HINT_FAILED');
211cb0ef41Sopenharmony_ci    server.close();
221cb0ef41Sopenharmony_ci  });
231cb0ef41Sopenharmony_ci  server.listen(0, () => {
241cb0ef41Sopenharmony_ci    const client = tls.connect({
251cb0ef41Sopenharmony_ci      port: server.address().port,
261cb0ef41Sopenharmony_ci      ciphers: 'PSK+HIGH',
271cb0ef41Sopenharmony_ci      checkServerIdentity: () => {},
281cb0ef41Sopenharmony_ci      pskCallback: () => {},
291cb0ef41Sopenharmony_ci    }, () => {});
301cb0ef41Sopenharmony_ci    client.on('error', common.expectsError({ code: 'ECONNRESET' }));
311cb0ef41Sopenharmony_ci  });
321cb0ef41Sopenharmony_ci}
33