11cb0ef41Sopenharmony_ci'use strict'; 21cb0ef41Sopenharmony_ciconst common = require('../common'); 31cb0ef41Sopenharmony_ciif (!common.hasCrypto) 41cb0ef41Sopenharmony_ci common.skip('missing crypto'); 51cb0ef41Sopenharmony_ci 61cb0ef41Sopenharmony_ciif (common.hasOpenSSL3) 71cb0ef41Sopenharmony_ci // TODO(danbev) This test fails with the following error: 81cb0ef41Sopenharmony_ci // error:0D00008F:asn1 encoding routines::no matching choice type 91cb0ef41Sopenharmony_ci // 101cb0ef41Sopenharmony_ci // I've not been able to figure out the reason for this but there 111cb0ef41Sopenharmony_ci // is a note in https://wiki.openssl.org/index.php/OpenSSL_3.0 which 121cb0ef41Sopenharmony_ci // indicates that this might not work at the moment: 131cb0ef41Sopenharmony_ci // "OCSP, PEM, ASN.1 have some very limited library context support" 141cb0ef41Sopenharmony_ci common.skip('when using OpenSSL 3.x'); 151cb0ef41Sopenharmony_ci 161cb0ef41Sopenharmony_ci// NOTE: This certificate is hand-generated, hence it is not located in 171cb0ef41Sopenharmony_ci// `test/fixtures/keys` to avoid confusion. 181cb0ef41Sopenharmony_ci// 191cb0ef41Sopenharmony_ci// The key property of this cert is that subjectAltName contains a string with 201cb0ef41Sopenharmony_ci// a type `23` which cannot be encoded into string by `X509V3_EXT_print`. 211cb0ef41Sopenharmony_ciconst pem = ` 221cb0ef41Sopenharmony_ci-----BEGIN RSA PRIVATE KEY----- 231cb0ef41Sopenharmony_ciMIIEowIBAAKCAQEAzrmfPz5M3wTq2/CwMeSQr/N+R1FCJ+O5n+SMleKvBqaK63eJ 241cb0ef41Sopenharmony_cikL4BnySMc+ZLKCt4UQSsPFIBK63QFq8n6/vjuTDMJiBTsvzytw8zJt1Zr2HA71N3 251cb0ef41Sopenharmony_ciVIPt6NdJ/w5lgddTYxR7XudJZJ5lk3PkG8ZgrhuenPYP80UJYVzAC2YZ9KYe3r2B 261cb0ef41Sopenharmony_cirVbut1j+8h0TwVcx2Zg5PorsC/EVxHwo4dCmIHceodikr3UVqHneRcrDBytdG6Mo 271cb0ef41Sopenharmony_ciIqHhZJwBeii/EES9tpWwWbzYYh+38aGGLIF2h5UlVpr0bdBVVUg+uVX3y/Qmu2Qv 281cb0ef41Sopenharmony_ci4CrAO2IPV6JER9Niwl3ktzNjOMAUQG6BCRSqRQIDAQABAoIBAAmB0+cOsG5ZRYvT 291cb0ef41Sopenharmony_ci5+aDgnv1EMuq2wYGnRTTZ/vErxP5OM5XcwYrFtwAzEzQPIieZywisOEdTFx74+QH 301cb0ef41Sopenharmony_ciLijWLsTnj5v5RKAorejpVArnhyZfsoXPKt/CKYDZ1ddbDCQKiRU3be0RafisqDM9 311cb0ef41Sopenharmony_ci0zHLz8pyDrtdPaKMfD/0Cgj8KxlrLTmfD4otPXds8fZpQe1hR1y12XKVp47l1siW 321cb0ef41Sopenharmony_ciqFGTaUPDJpQ67xybR08x5DOqmyo4cNMOuReRWrc/qRbWint9U1882eOH09gVfpJZ 331cb0ef41Sopenharmony_ciGp6FZVPSgz10MZdLSPLhXqZkY4IxIvNltjBDqkmivd12CD+GVr0qUmTJHzTpk+kG 341cb0ef41Sopenharmony_ci/CWuRQkCgYEA4EFf8SJHEl0fLDJnOQFyUPY3MalMuopUkQ5CBUe3QXjQhHXsRDfj 351cb0ef41Sopenharmony_ciCi/lyzShJkHPbMDHb/rx3lYZB0xNhwnMWKS1gCFVgOCOTZLfD0K1Anxc1hOSgVxI 361cb0ef41Sopenharmony_ciy5FdO9VW7oQNlsMH/WuDHps0HhJW/00lcrmdyoUM1+fE/3yPQndhUmMCgYEA6/z6 371cb0ef41Sopenharmony_ci8Gq4PHHNql+gwunAH2cZKNdmcP4Co8MvXCZwIJsLenUuLIZQ/YBKZoM/y5X/cFAG 381cb0ef41Sopenharmony_ciWFJJuUe6KFetPaDm6NgZgpOmawyUwd5czDjJ6wWgsRywiTISInfJlgWLBVMOuba7 391cb0ef41Sopenharmony_ciiBL9Xuy0hmcbj0ByoRW9l3gCiBX3yJw3I6wqXTcCgYBnjei22eRF15iIeTHvQfq+ 401cb0ef41Sopenharmony_ci5iNwnEQhM7V/Uj0sYQR/iEGJmUaj7ca6somDf2cW2nblOlQeIpxD1jAyjYqTW/Pv 411cb0ef41Sopenharmony_cizwc9BqeMHqW3rqWwT1Z0smbQODOD5tB6qEKMWaSN+Y6o2qC65kWjAXpclI110PME 421cb0ef41Sopenharmony_ci+i+iEDRxEsaGT8d7otLfDwKBgQCs+xBaQG/x5p2SAGzP0xYALstzc4jk1FzM+5rw 431cb0ef41Sopenharmony_cimkBgtiXQyqpg+sfNOkfPIvAVZEsMYax0+0SNKrWbMsGLRjFchmMUovQ+zccQ4NT2 441cb0ef41Sopenharmony_ci4b2op8Rlbxk8R9ahK1s5u7Bu47YMjZSjJwBQn4OobVX3SI994njJ2a9JX4j0pQWK 451cb0ef41Sopenharmony_ciAX5AOwKBgAfOsr8HSHTcxSW4F9gegj+hXsRYbdA+eUkFhEGrYyRJgIlQrk/HbuZC 461cb0ef41Sopenharmony_cimKd/bQ5R/vwd1cxgV6A0APzpZtbwdhvP0RWji+WnPPovgGcfK0AHFstHnga67/uu 471cb0ef41Sopenharmony_cih2LHnKQZ1qWHn+BXWo5d7hBRwWVaK66g3GDN0blZpSz1kKcpy1Pl 481cb0ef41Sopenharmony_ci-----END RSA PRIVATE KEY----- 491cb0ef41Sopenharmony_ci-----BEGIN CERTIFICATE----- 501cb0ef41Sopenharmony_ciMIICwjCCAaqgAwIBAgIDAQABMA0GCSqGSIb3DQEBDQUAMBUxEzARBgNVBAMWCmxv 511cb0ef41Sopenharmony_ciY2FsLmhvc3QwHhcNMTkxMjA1MDQyODMzWhcNNDQxMTI5MDQyODMzWjAVMRMwEQYD 521cb0ef41Sopenharmony_ciVQQDFgpsb2NhbC5ob3N0MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA 531cb0ef41Sopenharmony_cizrmfPz5M3wTq2/CwMeSQr/N+R1FCJ+O5n+SMleKvBqaK63eJkL4BnySMc+ZLKCt4 541cb0ef41Sopenharmony_ciUQSsPFIBK63QFq8n6/vjuTDMJiBTsvzytw8zJt1Zr2HA71N3VIPt6NdJ/w5lgddT 551cb0ef41Sopenharmony_ciYxR7XudJZJ5lk3PkG8ZgrhuenPYP80UJYVzAC2YZ9KYe3r2BrVbut1j+8h0TwVcx 561cb0ef41Sopenharmony_ci2Zg5PorsC/EVxHwo4dCmIHceodikr3UVqHneRcrDBytdG6MoIqHhZJwBeii/EES9 571cb0ef41Sopenharmony_citpWwWbzYYh+38aGGLIF2h5UlVpr0bdBVVUg+uVX3y/Qmu2Qv4CrAO2IPV6JER9Ni 581cb0ef41Sopenharmony_ciwl3ktzNjOMAUQG6BCRSqRQIDAQABoxswGTAXBgNVHREEEDAOlwwqLmxvY2FsLmhv 591cb0ef41Sopenharmony_cic3QwDQYJKoZIhvcNAQENBQADggEBAH5ThRLDLwOGuhKsifyiq7k8gbx1FqRegO7H 601cb0ef41Sopenharmony_ciSIiIYYB35v5Pk0ZPN8QBJwNQzJEjUMjCpHXNdBxknBXRaA8vkbnryMfJm37gPTwA 611cb0ef41Sopenharmony_cim6r0uEG78WgcEAe8bgf9iKtQGP/iydKXpSSpDgKoHbswIxD5qtzT+o6VNnkRTSfK 621cb0ef41Sopenharmony_ci/OGwakluFSoJ/Q9rLpR8lKjA01BhetXMmHbETiY8LSkxOymMldXSzUTD1WdrVn8U 631cb0ef41Sopenharmony_ciL3dobxT//R/0GraKXG02mf3gZNlb0MMTvW0pVwVy39YmcPEGh8L0hWh1rpAA/VXC 641cb0ef41Sopenharmony_cif79uOowv3lLTzQ9na5EThA0tp8d837hdYrrIHh5cfTqBDxG0Tu8= 651cb0ef41Sopenharmony_ci-----END CERTIFICATE----- 661cb0ef41Sopenharmony_ci`; 671cb0ef41Sopenharmony_ci 681cb0ef41Sopenharmony_ciconst tls = require('tls'); 691cb0ef41Sopenharmony_ci 701cb0ef41Sopenharmony_ciconst options = { 711cb0ef41Sopenharmony_ci key: pem, 721cb0ef41Sopenharmony_ci cert: pem, 731cb0ef41Sopenharmony_ci}; 741cb0ef41Sopenharmony_ci 751cb0ef41Sopenharmony_ciconst server = tls.createServer(options, (socket) => { 761cb0ef41Sopenharmony_ci socket.end(); 771cb0ef41Sopenharmony_ci}); 781cb0ef41Sopenharmony_ciserver.listen(0, common.mustCall(function() { 791cb0ef41Sopenharmony_ci const client = tls.connect({ 801cb0ef41Sopenharmony_ci port: this.address().port, 811cb0ef41Sopenharmony_ci rejectUnauthorized: false 821cb0ef41Sopenharmony_ci }, common.mustCall(() => { 831cb0ef41Sopenharmony_ci // This should not crash process: 841cb0ef41Sopenharmony_ci client.getPeerCertificate(); 851cb0ef41Sopenharmony_ci 861cb0ef41Sopenharmony_ci server.close(); 871cb0ef41Sopenharmony_ci client.end(); 881cb0ef41Sopenharmony_ci })); 891cb0ef41Sopenharmony_ci})); 90