4 files changed +33
-5
lines changed Original file line number Diff line number Diff line change 5
5
"port" : 22280 ,
6
6
"listen" : " 0.0.0.0" ,
7
7
"ssl.key" : null ,
8
- "ssl.cert" : null
8
+ "ssl.cert" : null ,
9
+ "ssl.chain" : null
9
10
},
10
11
{
11
12
"type" : " admin" ,
12
13
"port" : 22281 ,
13
14
"listen" : " 127.0.0.1" ,
14
15
"ssl.key" : null ,
15
- "ssl.cert" : null
16
+ "ssl.cert" : null ,
17
+ "ssl.chain" : null
16
18
}
17
19
],
18
20
"logs" : [
Original file line number Diff line number Diff line change @@ -99,6 +99,7 @@ protected function parseLaunchArguments(PhutilArgumentParser $args) {
99
99
'listen ' => 'optional string|null ' ,
100
100
'ssl.key ' => 'optional string|null ' ,
101
101
'ssl.cert ' => 'optional string|null ' ,
102
+ 'ssl.chain ' => 'optional string|null ' ,
102
103
));
103
104
104
105
$ port = $ server ['port ' ];
@@ -145,6 +146,21 @@ protected function parseLaunchArguments(PhutilArgumentParser $args) {
145
146
'ssl.key ' ,
146
147
'ssl.cert ' ));
147
148
}
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
+ }
148
164
}
149
165
150
166
if (!$ servers ) {
Original file line number Diff line number Diff line change @@ -85,13 +85,15 @@ Each server in the `servers` list should be an object with these keys:
85
85
`admin` or `client`. Normally, you should run one of each.
86
86
- `port`: //Required int.// The port this server should listen on.
87
87
- `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
89
89
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) .
91
91
- `ssl.key`: //Optional string.// If you want to use SSL on this port,
92
92
the path to an SSL key.
93
93
- `ssl.cert`: //Optional string.// If you want to use SSL on this port,
94
94
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.
95
97
96
98
Each log in the `logs` list should be an object with these keys:
97
99
Original file line number Diff line number Diff line change @@ -104,6 +104,10 @@ for (ii = 0; ii < config.servers.length; ii++) {
104
104
spec [ 'ssl.cert' ] = fs . readFileSync ( spec [ 'ssl.cert' ] ) ;
105
105
}
106
106
107
+ if ( spec [ 'ssl.chain' ] ) {
108
+ spec [ 'ssl.chain' ] = fs . readFileSync ( spec [ 'ssl.chain' ] ) ;
109
+ }
110
+
107
111
servers . push ( spec ) ;
108
112
}
109
113
@@ -132,9 +136,13 @@ for (ii = 0; ii < servers.length; ii++) {
132
136
if ( server [ 'ssl.key' ] ) {
133
137
var https_config = {
134
138
key : server [ 'ssl.key' ] ,
135
- cert : server [ 'ssl.cert' ]
139
+ cert : server [ 'ssl.cert' ] ,
136
140
} ;
137
141
142
+ if ( server [ 'ssl.chain' ] ) {
143
+ https_config . ca = server [ 'ssl.chain' ] ;
144
+ }
145
+
138
146
http_server = https . createServer ( https_config ) ;
139
147
} else {
140
148
http_server = http . createServer ( ) ;
0 commit comments