-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[wip] Initial HTTPS->HTTP test, updated https-secure example. Work in…
… progress, need to add more https tests
- Loading branch information
Showing
6 changed files
with
117 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
-----BEGIN CERTIFICATE----- | ||
MIIB7DCCAZYCCQC7gs0MDNn6MTANBgkqhkiG9w0BAQUFADB9MQswCQYDVQQGEwJV | ||
UzELMAkGA1UECBMCQ0ExCzAJBgNVBAcTAlNGMQ8wDQYDVQQKEwZKb3llbnQxEDAO | ||
BgNVBAsTB05vZGUuanMxDzANBgNVBAMTBmFnZW50MjEgMB4GCSqGSIb3DQEJARYR | ||
cnlAdGlueWNsb3Vkcy5vcmcwHhcNMTEwMzE0MTgyOTEyWhcNMzgwNzI5MTgyOTEy | ||
WjB9MQswCQYDVQQGEwJVUzELMAkGA1UECBMCQ0ExCzAJBgNVBAcTAlNGMQ8wDQYD | ||
VQQKEwZKb3llbnQxEDAOBgNVBAsTB05vZGUuanMxDzANBgNVBAMTBmFnZW50MjEg | ||
MB4GCSqGSIb3DQEJARYRcnlAdGlueWNsb3Vkcy5vcmcwXDANBgkqhkiG9w0BAQEF | ||
AANLADBIAkEAyXb8FrRdKbhrKLgLSsn61i1C7w7fVVVd7OQsmV/7p9WB2lWFiDlC | ||
WKGU9SiIz/A6wNZDUAuc2E+VwtpCT561AQIDAQABMA0GCSqGSIb3DQEBBQUAA0EA | ||
C8HzpuNhFLCI3A5KkBS5zHAQax6TFUOhbpBCR0aTDbJ6F1liDTK1lmU/BjvPoj+9 | ||
1LHwrmh29rK8kBPEjmymCQ== | ||
-----END CERTIFICATE----- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
-----BEGIN CERTIFICATE REQUEST----- | ||
MIIBXTCCAQcCAQAwfTELMAkGA1UEBhMCVVMxCzAJBgNVBAgTAkNBMQswCQYDVQQH | ||
EwJTRjEPMA0GA1UEChMGSm95ZW50MRAwDgYDVQQLEwdOb2RlLmpzMQ8wDQYDVQQD | ||
EwZhZ2VudDIxIDAeBgkqhkiG9w0BCQEWEXJ5QHRpbnljbG91ZHMub3JnMFwwDQYJ | ||
KoZIhvcNAQEBBQADSwAwSAJBAMl2/Ba0XSm4ayi4C0rJ+tYtQu8O31VVXezkLJlf | ||
+6fVgdpVhYg5QlihlPUoiM/wOsDWQ1ALnNhPlcLaQk+etQECAwEAAaAlMCMGCSqG | ||
SIb3DQEJBzEWExRBIGNoYWxsZW5nZSBwYXNzd29yZDANBgkqhkiG9w0BAQUFAANB | ||
AJnll2pt5l0pzskQSpjjLVTlFDFmJr/AZ3UK8v0WxBjYjCe5Jx4YehkChpxIyDUm | ||
U3J9q9MDUf0+Y2+EGkssFfk= | ||
-----END CERTIFICATE REQUEST----- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
-----BEGIN RSA PRIVATE KEY----- | ||
MIIBOgIBAAJBAMl2/Ba0XSm4ayi4C0rJ+tYtQu8O31VVXezkLJlf+6fVgdpVhYg5 | ||
QlihlPUoiM/wOsDWQ1ALnNhPlcLaQk+etQECAwEAAQJBAMT6Bf34+UHKY1ObpsbH | ||
9u2jsVblFq1rWvs8GPMY6oertzvwm3DpuSUp7PTgOB1nLTLYtCERbQ4ovtN8tn3p | ||
OHUCIQDzIEGsoCr5vlxXvy2zJwu+fxYuhTZWMVuo1397L0VyhwIhANQh+yzqUgaf | ||
WRtSB4T2W7ADtJI35ET61jKBty3CqJY3AiAIwju7dVW3A5WeD6Qc1SZGKZvp9yCb | ||
AFI2BfVwwaY11wIgXF3PeGcvACMyMWsuSv7aPXHfliswAbkWuzcwA4TW01ECIGWa | ||
cgsDvVFxmfM5NPSuT/UDTa6R5BFISB5ea0N0AR3I | ||
-----END RSA PRIVATE KEY----- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
[ req ] | ||
default_bits = 1024 | ||
days = 999 | ||
distinguished_name = req_distinguished_name | ||
attributes = req_attributes | ||
prompt = no | ||
|
||
[ req_distinguished_name ] | ||
C = US | ||
ST = CA | ||
L = SF | ||
O = Joyent | ||
OU = Node.js | ||
CN = agent2 | ||
emailAddress = [email protected] | ||
|
||
[ req_attributes ] | ||
challengePassword = A challenge password | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
var httpProxy = require('../lib/http-proxy'), | ||
expect = require('expect.js'), | ||
http = require('http') | ||
https = require('https'), | ||
path = require('path'), | ||
fs = require('fs'); | ||
|
||
// | ||
// Expose a port number generator. | ||
// thanks to @3rd-Eden | ||
// | ||
var initialPort = 1024, gen = {}; | ||
Object.defineProperty(gen, 'port', { | ||
get: function get() { | ||
return initialPort++; | ||
} | ||
}); | ||
|
||
describe('lib/http-proxy.js', function() { | ||
describe('#createProxyServer using HTTPS', function() { | ||
describe('HTTPS to HTTP', function () { | ||
it('should proxy the request en send back the response', function (done) { | ||
var ports = { source: gen.port, proxy: gen.port }; | ||
var source = http.createServer(function(req, res) { | ||
console.log('Request:', req.headers); | ||
expect(req.method).to.eql('GET'); | ||
expect(req.headers.host.split(':')[1]).to.eql(ports.proxy); | ||
res.writeHead(200, { 'Content-Type': 'text/plain' }); | ||
res.end('Hello from ' + ports.source); | ||
}); | ||
|
||
source.listen(ports.source); | ||
|
||
var proxy = httpProxy.createProxyServer({ | ||
forward: 'http://127.0.0.1:' + ports.source, | ||
ssl: { | ||
key: fs.readFileSync(path.join(__dirname, 'fixtures', 'agent2-key.pem')), | ||
cert: fs.readFileSync(path.join(__dirname, 'fixtures', 'agent2-cert.pem')), | ||
} | ||
}).listen(ports.proxy); | ||
|
||
var req = https.request({ | ||
host: 'localhost', | ||
port: ports.proxy, | ||
path: '/', | ||
method: 'GET', | ||
localAddress: '127.0.0.1', | ||
rejectUnauthorized: false | ||
}, function(res) { | ||
console.log(res); | ||
res.on('data', function (ch) { | ||
console.log('Chunks', ch) | ||
}) | ||
console.log('Response:', res.statusCode); | ||
source.close(); | ||
proxy._server.close(); | ||
done(); | ||
}); | ||
|
||
req.on('error', function (err) { console.log('Erroring', err); }); | ||
req.end(); | ||
}) | ||
}) | ||
}); | ||
}); |