Skip to content

Commit 07fc8f1

Browse files
author
epriestley
committedApr 14, 2016
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
1 parent 383ae76 commit 07fc8f1

File tree

4 files changed

+33
-5
lines changed

4 files changed

+33
-5
lines changed
 

‎conf/aphlict/aphlict.default.json

+4-2
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,16 @@
55
"port": 22280,
66
"listen": "0.0.0.0",
77
"ssl.key": null,
8-
"ssl.cert": null
8+
"ssl.cert": null,
9+
"ssl.chain": null
910
},
1011
{
1112
"type": "admin",
1213
"port": 22281,
1314
"listen": "127.0.0.1",
1415
"ssl.key": null,
15-
"ssl.cert": null
16+
"ssl.cert": null,
17+
"ssl.chain": null
1618
}
1719
],
1820
"logs": [

‎src/applications/aphlict/management/PhabricatorAphlictManagementWorkflow.php

+16
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ protected function parseLaunchArguments(PhutilArgumentParser $args) {
9999
'listen' => 'optional string|null',
100100
'ssl.key' => 'optional string|null',
101101
'ssl.cert' => 'optional string|null',
102+
'ssl.chain' => 'optional string|null',
102103
));
103104

104105
$port = $server['port'];
@@ -145,6 +146,21 @@ protected function parseLaunchArguments(PhutilArgumentParser $args) {
145146
'ssl.key',
146147
'ssl.cert'));
147148
}
149+
150+
$ssl_chain = idx($server, 'ssl.chain');
151+
if ($ssl_chain && (!$ssl_key && !$ssl_cert)) {
152+
throw new PhutilArgumentUsageException(
153+
pht(
154+
'A specified server (at index "%s", on port "%s") specifies '.
155+
'a value for "%s", but no value for "%s" or "%s". Servers '.
156+
'should only provide an SSL chain if they also provide an SSL '.
157+
'key and SSL certificate.',
158+
$index,
159+
$port,
160+
'ssl.chain',
161+
'ssl.key',
162+
'ssl.cert'));
163+
}
148164
}
149165

150166
if (!$servers) {

‎src/docs/user/configuration/notifications.diviner

+4-2
Original file line numberDiff line numberDiff line change
@@ -85,13 +85,15 @@ Each server in the `servers` list should be an object with these keys:
8585
`admin` or `client`. Normally, you should run one of each.
8686
- `port`: //Required int.// The port this server should listen on.
8787
- `listen`: //Optional string.// Which interface to bind to. By default,
88-
the `admin` server is bound to localhost (so only other services on the
88+
the `admin` server is bound to `127.0.0.1` (so only other services on the
8989
local machine can connect to it), while the `client` server is bound
90-
to `0.0.0.0` (so any client can connect.
90+
to `0.0.0.0` (so any client can connect).
9191
- `ssl.key`: //Optional string.// If you want to use SSL on this port,
9292
the path to an SSL key.
9393
- `ssl.cert`: //Optional string.// If you want to use SSL on this port,
9494
the path to an SSL certificate.
95+
- `ssl.chain`: //Optional string.// If you have configured SSL on this
96+
port, an optional path to a certificate chain file.
9597

9698
Each log in the `logs` list should be an object with these keys:
9799

‎support/aphlict/server/aphlict_server.js

+9-1
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,10 @@ for (ii = 0; ii < config.servers.length; ii++) {
104104
spec['ssl.cert'] = fs.readFileSync(spec['ssl.cert']);
105105
}
106106

107+
if (spec['ssl.chain']){
108+
spec['ssl.chain'] = fs.readFileSync(spec['ssl.chain']);
109+
}
110+
107111
servers.push(spec);
108112
}
109113

@@ -132,9 +136,13 @@ for (ii = 0; ii < servers.length; ii++) {
132136
if (server['ssl.key']) {
133137
var https_config = {
134138
key: server['ssl.key'],
135-
cert: server['ssl.cert']
139+
cert: server['ssl.cert'],
136140
};
137141

142+
if (server['ssl.chain']) {
143+
https_config.ca = server['ssl.chain'];
144+
}
145+
138146
http_server = https.createServer(https_config);
139147
} else {
140148
http_server = http.createServer();

0 commit comments

Comments
 (0)
Failed to load comments.