11cb0ef41Sopenharmony_ci'use strict'; 21cb0ef41Sopenharmony_ci 31cb0ef41Sopenharmony_ciconst common = require('../common'); 41cb0ef41Sopenharmony_ci 51cb0ef41Sopenharmony_ciif (!common.hasCrypto) 61cb0ef41Sopenharmony_ci common.skip('missing crypto'); 71cb0ef41Sopenharmony_ci 81cb0ef41Sopenharmony_ciconst https = require('https'); 91cb0ef41Sopenharmony_ciconst tls = require('tls'); 101cb0ef41Sopenharmony_ci 111cb0ef41Sopenharmony_ciconst kMessage = 121cb0ef41Sopenharmony_ci 'GET / HTTP/1.1\r\nHost: localhost\r\nConnection: Keep-alive\r\n\r\n'; 131cb0ef41Sopenharmony_ci 141cb0ef41Sopenharmony_ciconst key = `-----BEGIN EC PARAMETERS----- 151cb0ef41Sopenharmony_ciBggqhkjOPQMBBw== 161cb0ef41Sopenharmony_ci-----END EC PARAMETERS----- 171cb0ef41Sopenharmony_ci-----BEGIN EC PRIVATE KEY----- 181cb0ef41Sopenharmony_ciMHcCAQEEIDKfHHbiJMdu2STyHL11fWC7psMY19/gUNpsUpkwgGACoAoGCCqGSM49 191cb0ef41Sopenharmony_ciAwEHoUQDQgAEItqm+pYj3Ca8bi5mBs+H8xSMxuW2JNn4I+kw3aREsetLk8pn3o81 201cb0ef41Sopenharmony_ciPWBiTdSZrGBGQSy+UAlQvYeE6Z/QXQk8aw== 211cb0ef41Sopenharmony_ci-----END EC PRIVATE KEY-----`; 221cb0ef41Sopenharmony_ci 231cb0ef41Sopenharmony_ciconst cert = `-----BEGIN CERTIFICATE----- 241cb0ef41Sopenharmony_ciMIIBhjCCASsCFDJU1tCo88NYU//pE+DQKO9hUDsFMAoGCCqGSM49BAMCMEUxCzAJ 251cb0ef41Sopenharmony_ciBgNVBAYTAkFVMRMwEQYDVQQIDApTb21lLVN0YXRlMSEwHwYDVQQKDBhJbnRlcm5l 261cb0ef41Sopenharmony_cidCBXaWRnaXRzIFB0eSBMdGQwHhcNMjAwOTIyMDg1NDU5WhcNNDgwMjA3MDg1NDU5 271cb0ef41Sopenharmony_ciWjBFMQswCQYDVQQGEwJBVTETMBEGA1UECAwKU29tZS1TdGF0ZTEhMB8GA1UECgwY 281cb0ef41Sopenharmony_ciSW50ZXJuZXQgV2lkZ2l0cyBQdHkgTHRkMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcD 291cb0ef41Sopenharmony_ciQgAEItqm+pYj3Ca8bi5mBs+H8xSMxuW2JNn4I+kw3aREsetLk8pn3o81PWBiTdSZ 301cb0ef41Sopenharmony_cirGBGQSy+UAlQvYeE6Z/QXQk8azAKBggqhkjOPQQDAgNJADBGAiEA7Bdn4F87KqIe 311cb0ef41Sopenharmony_ciY/ABy/XIXXpFUb2nyv3zV7POQi2lPcECIQC3UWLmfiedpiIKsf9YRIyO0uEood7+ 321cb0ef41Sopenharmony_ciglj2R1NNr1X68w== 331cb0ef41Sopenharmony_ci-----END CERTIFICATE-----`; 341cb0ef41Sopenharmony_ci 351cb0ef41Sopenharmony_ciconst server = https.createServer( 361cb0ef41Sopenharmony_ci { key, cert }, 371cb0ef41Sopenharmony_ci common.mustCall((req, res) => { 381cb0ef41Sopenharmony_ci res.writeHead(200); 391cb0ef41Sopenharmony_ci res.end('boom goes the dynamite\n'); 401cb0ef41Sopenharmony_ci }, 3)); 411cb0ef41Sopenharmony_ci 421cb0ef41Sopenharmony_ciserver.listen(0, common.mustCall(() => { 431cb0ef41Sopenharmony_ci const socket = 441cb0ef41Sopenharmony_ci tls.connect( 451cb0ef41Sopenharmony_ci server.address().port, 461cb0ef41Sopenharmony_ci 'localhost', 471cb0ef41Sopenharmony_ci { rejectUnauthorized: false }, 481cb0ef41Sopenharmony_ci common.mustCall(() => { 491cb0ef41Sopenharmony_ci socket.write(kMessage); 501cb0ef41Sopenharmony_ci socket.write(kMessage); 511cb0ef41Sopenharmony_ci socket.write(kMessage); 521cb0ef41Sopenharmony_ci })); 531cb0ef41Sopenharmony_ci 541cb0ef41Sopenharmony_ci socket.on('data', common.mustCall(() => socket.destroy())); 551cb0ef41Sopenharmony_ci socket.on('close', () => { 561cb0ef41Sopenharmony_ci setImmediate(() => server.close()); 571cb0ef41Sopenharmony_ci }); 581cb0ef41Sopenharmony_ci})); 59