1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-09-19 00:38:51 +02:00

Support "ssl.chain" in Aphlict configuration

Summary: Fixes T10806. Although browsers don't seem to care about this, it's more correct to support it, and the new test console uses normal `cURL` and does care.

Test Plan:
  - Hit the error case for providing a chain but no key/cert.
  - Used `openssl s_client -connect localhost:22280` to connect to local Aphlict servers.
  - With SSL but no chain, saw `openssl` fail to verify the remote.
  - With SSL and a chain, saw `openssl` verify the identify of the remote.

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T10806

Differential Revision: https://secure.phabricator.com/D15709
This commit is contained in:
epriestley 2016-04-14 05:44:04 -07:00
parent 383ae7621f
commit 07fc8f17cc
4 changed files with 33 additions and 5 deletions

View file

@ -5,14 +5,16 @@
"port": 22280,
"listen": "0.0.0.0",
"ssl.key": null,
"ssl.cert": null
"ssl.cert": null,
"ssl.chain": null
},
{
"type": "admin",
"port": 22281,
"listen": "127.0.0.1",
"ssl.key": null,
"ssl.cert": null
"ssl.cert": null,
"ssl.chain": null
}
],
"logs": [

View file

@ -99,6 +99,7 @@ abstract class PhabricatorAphlictManagementWorkflow
'listen' => 'optional string|null',
'ssl.key' => 'optional string|null',
'ssl.cert' => 'optional string|null',
'ssl.chain' => 'optional string|null',
));
$port = $server['port'];
@ -145,6 +146,21 @@ abstract class PhabricatorAphlictManagementWorkflow
'ssl.key',
'ssl.cert'));
}
$ssl_chain = idx($server, 'ssl.chain');
if ($ssl_chain && (!$ssl_key && !$ssl_cert)) {
throw new PhutilArgumentUsageException(
pht(
'A specified server (at index "%s", on port "%s") specifies '.
'a value for "%s", but no value for "%s" or "%s". Servers '.
'should only provide an SSL chain if they also provide an SSL '.
'key and SSL certificate.',
$index,
$port,
'ssl.chain',
'ssl.key',
'ssl.cert'));
}
}
if (!$servers) {

View file

@ -85,13 +85,15 @@ Each server in the `servers` list should be an object with these keys:
`admin` or `client`. Normally, you should run one of each.
- `port`: //Required int.// The port this server should listen on.
- `listen`: //Optional string.// Which interface to bind to. By default,
the `admin` server is bound to localhost (so only other services on the
the `admin` server is bound to `127.0.0.1` (so only other services on the
local machine can connect to it), while the `client` server is bound
to `0.0.0.0` (so any client can connect.
to `0.0.0.0` (so any client can connect).
- `ssl.key`: //Optional string.// If you want to use SSL on this port,
the path to an SSL key.
- `ssl.cert`: //Optional string.// If you want to use SSL on this port,
the path to an SSL certificate.
- `ssl.chain`: //Optional string.// If you have configured SSL on this
port, an optional path to a certificate chain file.
Each log in the `logs` list should be an object with these keys:

View file

@ -104,6 +104,10 @@ for (ii = 0; ii < config.servers.length; ii++) {
spec['ssl.cert'] = fs.readFileSync(spec['ssl.cert']);
}
if (spec['ssl.chain']){
spec['ssl.chain'] = fs.readFileSync(spec['ssl.chain']);
}
servers.push(spec);
}
@ -132,9 +136,13 @@ for (ii = 0; ii < servers.length; ii++) {
if (server['ssl.key']) {
var https_config = {
key: server['ssl.key'],
cert: server['ssl.cert']
cert: server['ssl.cert'],
};
if (server['ssl.chain']) {
https_config.ca = server['ssl.chain'];
}
http_server = https.createServer(https_config);
} else {
http_server = http.createServer();