1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 /* import-globals-from head_cache.js */
8 /* import-globals-from head_cookies.js */
9 /* import-globals-from head_channels.js */
10 /* import-globals-from head_servers.js */
12 function makeChan(uri) {
13 let chan = NetUtil.newChannel({
15 loadUsingSystemPrincipal: true,
16 }).QueryInterface(Ci.nsIHttpChannel);
17 chan.loadFlags = Ci.nsIChannel.LOAD_INITIAL_DOCUMENT_URI;
21 async function test_cert_failure(server_or_proxy, server_cert) {
22 let server = new server_or_proxy();
24 registerCleanupFunction(async () => {
27 let chan = makeChan(`https://localhost:${server.port()}/test`);
28 let req = await new Promise(resolve => {
29 chan.asyncOpen(new ChannelListener(resolve, null, CL_EXPECT_FAILURE));
31 equal(req.status, 0x805a1ff3); // SEC_ERROR_UNKNOWN_ISSUER
32 let secinfo = req.securityInfo;
33 secinfo.QueryInterface(Ci.nsITransportSecurityInfo);
35 Assert.equal(secinfo.serverCert.commonName, " HTTP2 Test Cert");
37 Assert.equal(secinfo.serverCert.commonName, " Proxy Test Cert");
41 add_task(async function test_https() {
42 await test_cert_failure(NodeHTTPSServer, true);
45 add_task(async function test_http2() {
46 await test_cert_failure(NodeHTTP2Server, true);
49 add_task(async function test_https_proxy() {
50 let proxy = new NodeHTTPSProxyServer();
52 registerCleanupFunction(() => {
55 await test_cert_failure(NodeHTTPSServer, false);
58 add_task(async function test_http2_proxy() {
59 let proxy = new NodeHTTP2ProxyServer();
61 registerCleanupFunction(() => {
65 await test_cert_failure(NodeHTTPSServer, false);