Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1373 from nylen/tests-rewrite-tunnel
Rewrite tunnel test to be pure Node.js
- Loading branch information
Showing
8 changed files
with
348 additions
and
65 deletions.
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,20 @@ | ||
#!/bin/sh | ||
|
||
# Adapted from: | ||
# http://nodejs.org/api/tls.html | ||
# https://github.com/joyent/node/blob/master/test/fixtures/keys/Makefile | ||
|
||
# Create a private key | ||
openssl genrsa -out localhost.key 2048 | ||
|
||
# Create a certificate signing request | ||
openssl req -new -sha256 -key localhost.key -out localhost.csr -config localhost.cnf | ||
|
||
# Use the CSR and the CA key (previously generated) to create a certificate | ||
openssl x509 -req \ | ||
-in localhost.csr \ | ||
-CA ca.crt \ | ||
-CAkey ca.key \ | ||
-set_serial 0x`cat ca.srl` \ | ||
-passin 'pass:password' \ | ||
-out localhost.crt |
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,20 @@ | ||
[ req ] | ||
default_bits = 1024 | ||
days = 3650 | ||
distinguished_name = req_distinguished_name | ||
attributes = req_attributes | ||
prompt = no | ||
output_password = password | ||
|
||
[ req_distinguished_name ] | ||
C = US | ||
ST = CA | ||
L = Oakland | ||
O = request | ||
OU = request@localhost | ||
CN = localhost | ||
emailAddress = do.not@email.me | ||
|
||
[ req_attributes ] | ||
challengePassword = password challenge | ||
|
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,20 @@ | ||
-----BEGIN CERTIFICATE----- | ||
MIIDLTCCApYCCQCt9iAWqkDJwzANBgkqhkiG9w0BAQsFADCBojELMAkGA1UEBhMC | ||
VVMxCzAJBgNVBAgTAkNBMRAwDgYDVQQHEwdPYWtsYW5kMRAwDgYDVQQKEwdyZXF1 | ||
ZXN0MSYwJAYDVQQLEx1yZXF1ZXN0IENlcnRpZmljYXRlIEF1dGhvcml0eTESMBAG | ||
A1UEAxMJcmVxdWVzdENBMSYwJAYJKoZIhvcNAQkBFhdtaWtlYWxAbWlrZWFscm9n | ||
ZXJzLmNvbTAeFw0xNTAxMjQwNDEzMzVaFw0xNTAyMjMwNDEzMzVaMIGOMQswCQYD | ||
VQQGEwJVUzELMAkGA1UECBMCQ0ExEDAOBgNVBAcTB09ha2xhbmQxEDAOBgNVBAoT | ||
B3JlcXVlc3QxGjAYBgNVBAsUEXJlcXVlc3RAbG9jYWxob3N0MRIwEAYDVQQDEwls | ||
b2NhbGhvc3QxHjAcBgkqhkiG9w0BCQEWD2RvLm5vdEBlbWFpbC5tZTCCASIwDQYJ | ||
KoZIhvcNAQEBBQADggEPADCCAQoCggEBAJ8rQcGbUWXLZZ0XAq0A5OSG/yunu0D5 | ||
x5GcgArmiWo2EwgkdGGd3DrECmsXAqg05LDTP8LjN5wdvtdEXc4R+vf54VN/CD31 | ||
AtFXILfGEQZioWtdni+T9K0jEcVukdklAwCC1jjplJ8MxTXyJ9pEVoyv/tX4EFMf | ||
+ayUsDUCSrJQLW069iV4GXQglZr6UVfSG3ip4+1JDvP0MKUhitfWkrAYtb8m30AS | ||
fRj2Le/9HhhBWwxLDK1G23TqC86Sqe0Mhk5a1V5DKZPanDld5jVNKlrXTUMU4OcL | ||
b3mdidAy5kSFmRSJJdficeXnp6eBGK5kOFoRIyjeJ0Ut/ntw2c7WcLsCAwEAATAN | ||
BgkqhkiG9w0BAQsFAAOBgQAgie0OE8U3w4w2cGgCa8qqraOezz961/i/6zNLamMn | ||
XSjoIpB8syOgXzPTwk/pR1OPOIfv2C06usqTR31r/zAN63Ev+wqBW4RIQ6mD1J0O | ||
WxmuY7pYyISD+5CXGMoxmM4Mh78GBQaUWTwhbsZr+vNSgEWwJfEvoh2BAVUgqjHh | ||
ug== | ||
-----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,18 @@ | ||
-----BEGIN CERTIFICATE REQUEST----- | ||
MIIC9zCCAd8CAQAwgY4xCzAJBgNVBAYTAlVTMQswCQYDVQQIEwJDQTEQMA4GA1UE | ||
BxMHT2FrbGFuZDEQMA4GA1UEChMHcmVxdWVzdDEaMBgGA1UECxQRcmVxdWVzdEBs | ||
b2NhbGhvc3QxEjAQBgNVBAMTCWxvY2FsaG9zdDEeMBwGCSqGSIb3DQEJARYPZG8u | ||
bm90QGVtYWlsLm1lMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAnytB | ||
wZtRZctlnRcCrQDk5Ib/K6e7QPnHkZyACuaJajYTCCR0YZ3cOsQKaxcCqDTksNM/ | ||
wuM3nB2+10RdzhH69/nhU38IPfUC0Vcgt8YRBmKha12eL5P0rSMRxW6R2SUDAILW | ||
OOmUnwzFNfIn2kRWjK/+1fgQUx/5rJSwNQJKslAtbTr2JXgZdCCVmvpRV9IbeKnj | ||
7UkO8/QwpSGK19aSsBi1vybfQBJ9GPYt7/0eGEFbDEsMrUbbdOoLzpKp7QyGTlrV | ||
XkMpk9qcOV3mNU0qWtdNQxTg5wtveZ2J0DLmRIWZFIkl1+Jx5eenp4EYrmQ4WhEj | ||
KN4nRS3+e3DZztZwuwIDAQABoCMwIQYJKoZIhvcNAQkHMRQTEnBhc3N3b3JkIGNo | ||
YWxsZW5nZTANBgkqhkiG9w0BAQsFAAOCAQEAQBSAV6pyGnm1+EsDku9sKWy1ZhM8 | ||
75+nQ2rJvAtmcLE7mAzJ5QEB8MfGELfPbpKJEHi/TUHvONyrIyml9zy1+0+fkxRx | ||
5gXZ6Ggw64t5OpNgEc2EtJta+dua+W7gNeGFWPJ36iAHlkRIgK4PxttM7YV4hEwQ | ||
kJ5jWmNPj/e033kPShBAnWPGFdFTG92oq9Xb0+yF4a1ff4PpQLVivj5tDzs80B5M | ||
Khm38sQOK7qPR4IdugoJHkRtBcXQKNmeSXhYPl+0FYIFpvPd+E8DKWEOfR6LjQ9J | ||
WBLLMvr4B8BXnoJu4uHzJln6uVWFxizfa+u9LRIrL7CjxgAupKQ6kRprgQ== | ||
-----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,29 @@ | ||
'use strict' | ||
|
||
var fs = require('fs') | ||
var https = require('https') | ||
var options = { key: fs.readFileSync('./localhost.key') | ||
, cert: fs.readFileSync('./localhost.crt') } | ||
|
||
var server = https.createServer(options, function (req, res) { | ||
res.writeHead(200) | ||
res.end() | ||
server.close() | ||
}) | ||
server.listen(1337) | ||
|
||
var ca = fs.readFileSync('./ca.crt') | ||
var agent = new https.Agent({ host: 'localhost', port: 1337, ca: ca }) | ||
|
||
https.request({ host: 'localhost' | ||
, method: 'HEAD' | ||
, port: 1337 | ||
, agent: agent | ||
, ca: [ ca ] | ||
, path: '/' }, function (res) { | ||
if (res.client.authorized) { | ||
console.log('node test: OK') | ||
} else { | ||
throw new Error(res.client.authorizationError) | ||
} | ||
}).end() |
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,27 @@ | ||
-----B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6JnrZnmQixoQCSyC4CbTfpUpDxr8/2cKDU6982eo0sG2Tu | ||
I0CCDrqWMQFMBkeQBdQECBXi9rQs2hc7Ji29EnECgYBLp5uzhL01nucxI/oq+wJM | ||
it8WS32RHsXI8B/fkb1NlUc7rGu5RxLXRjqrAAzg8CjHByV1ikN0ofMfdrln31uA | ||
mWlhDNZsBGYmTybWeLScA6myR6Y2Eutjr3FTOBWzECK7O9inipYYVCfuYt6ElHIB | ||
EH2zmNrqMuqKh0TQnVPPJwKBgCmYrxjVQby2ZbsFNK8F1O/f8wzeZC+QNssaExLP | ||
pPmSJSJzOzyZUgnfpiZCDOZy6+RE4g7AAGc4fgJchQChNMc40r34+g2lMn7D/foL | ||
GNsDIMz4KoZmCflg1fdo0qIsOxaptu6PLi4jih1NZjzSdCmkVAvVeamt5s7umqbO | ||
YZEhAoGAeICIxtu1kx0LQxvQ3nfBv5aJwvksvTcAZvC02XpFIpL8l8WE1pUAWHMC | ||
R4K4O8uzBH3ILAmnihG096lhTtnt9RiEtPzOPkAB/83nipa/NCLgOIPOVqTgnS1Z | ||
2Zmckn2mbYTNxB8g+nQmeLeH6pM9+KhxHioQJIzPPpubfUTriY8= | ||
-----END RSA PRIVATE KEY----- |
Oops, something went wrong.