Project

General

Profile

Download (18.3 KB) Statistics
| Branch: | Tag: | Revision:
1
<?php
2
/*
3
	vpn_ipsec_settings.php
4

    
5
	Copyright (C) 2015 Electric Sheep Fencing, LLC
6
	All rights reserved.
7

    
8
	Redistribution and use in source and binary forms, with or without
9
	modification, are permitted provided that the following conditions are met:
10

    
11
	1. Redistributions of source code must retain the above copyright notice,
12
	   this list of conditions and the following disclaimer.
13

    
14
	2. Redistributions in binary form must reproduce the above copyright
15
	   notice, this list of conditions and the following disclaimer in the
16
	   documentation and/or other materials provided with the distribution.
17

    
18
	THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
19
	INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
20
	AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
21
	AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
22
	OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23
	SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24
	INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25
	CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26
	ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27
	POSSIBILITY OF SUCH DAMAGE.
28
*/
29

    
30
##|+PRIV
31
##|*IDENT=page-vpn-ipsec-settings
32
##|*NAME=VPN: IPsec: Settings page
33
##|*DESCR=Allow access to the 'VPN: IPsec: Settings' page.
34
##|*MATCH=vpn_ipsec_settings.php*
35
##|-PRIV
36

    
37
require("functions.inc");
38
require("guiconfig.inc");
39
require_once("filter.inc");
40
require_once("shaper.inc");
41
require_once("ipsec.inc");
42
require_once("vpn.inc");
43

    
44
foreach ($ipsec_loglevels as $lkey => $ldescr) {
45
	if (!empty($config['ipsec']["ipsec_{$lkey}"])) {
46
		$pconfig["ipsec_{$lkey}"] = $config['ipsec']["ipsec_{$lkey}"];
47
	}
48
}
49
$pconfig['unityplugin'] = isset($config['ipsec']['unityplugin']);
50
$pconfig['strictcrlpolicy'] = isset($config['ipsec']['strictcrlpolicy']);
51
$pconfig['makebeforebreak'] = isset($config['ipsec']['makebeforebreak']);
52
$pconfig['noshuntlaninterfaces'] = isset($config['ipsec']['noshuntlaninterfaces']);
53
$pconfig['compression'] = isset($config['ipsec']['compression']);
54
$pconfig['enableinterfacesuse'] = isset($config['ipsec']['enableinterfacesuse']);
55
$pconfig['acceptunencryptedmainmode'] = isset($config['ipsec']['acceptunencryptedmainmode']);
56
$pconfig['maxmss_enable'] = isset($config['system']['maxmss_enable']);
57
$pconfig['maxmss'] = $config['system']['maxmss'];
58
$pconfig['uniqueids'] = $config['ipsec']['uniqueids'];
59

    
60
if ($_POST) {
61

    
62
	unset($input_errors);
63
	$pconfig = $_POST;
64

    
65
	if (!in_array($pconfig['ipsec_dmn'], array('0', '1', '2', '3', '4', '5'), true)) {
66
		$input_errors[] = "A valid value must be specified for Daemon debug.";
67
	}
68
	if (!in_array($pconfig['ipsec_mgr'], array('0', '1', '2', '3', '4', '5'), true)) {
69
		$input_errors[] = "A valid value must be specified for SA Manager debug.";
70
	}
71
	if (!in_array($pconfig['ipsec_ike'], array('0', '1', '2', '3', '4', '5'), true)) {
72
		$input_errors[] = "A valid value must be specified for IKE SA debug.";
73
	}
74
	if (!in_array($pconfig['ipsec_chd'], array('0', '1', '2', '3', '4', '5'), true)) {
75
		$input_errors[] = "A valid value must be specified for IKE Child SA debug.";
76
	}
77
	if (!in_array($pconfig['ipsec_job'], array('0', '1', '2', '3', '4', '5'), true)) {
78
		$input_errors[] = "A valid value must be specified for Job Processing debug.";
79
	}
80
	if (!in_array($pconfig['ipsec_cfg'], array('0', '1', '2', '3', '4', '5'), true)) {
81
		$input_errors[] = "A valid value must be specified for Configuration backend debug.";
82
	}
83
	if (!in_array($pconfig['ipsec_knl'], array('0', '1', '2', '3', '4', '5'), true)) {
84
		$input_errors[] = "A valid value must be specified for Kernel Interface debug.";
85
	}
86
	if (!in_array($pconfig['ipsec_net'], array('0', '1', '2', '3', '4', '5'), true)) {
87
		$input_errors[] = "A valid value must be specified for Networking debug.";
88
	}
89
	if (!in_array($pconfig['ipsec_asn'], array('0', '1', '2', '3', '4', '5'), true)) {
90
		$input_errors[] = "A valid value must be specified for ASN Encoding debug.";
91
	}
92
	if (!in_array($pconfig['ipsec_enc'], array('0', '1', '2', '3', '4', '5'), true)) {
93
		$input_errors[] = "A valid value must be specified for Message encoding debug.";
94
	}
95
	if (!in_array($pconfig['ipsec_imc'], array('0', '1', '2', '3', '4', '5'), true)) {
96
		$input_errors[] = "A valid value must be specified for Integrity checker debug.";
97
	}
98
	if (!in_array($pconfig['ipsec_imv'], array('0', '1', '2', '3', '4', '5'), true)) {
99
		$input_errors[] = "A valid value must be specified for Integrity Verifier debug.";
100
	}
101
	if (!in_array($pconfig['ipsec_pts'], array('0', '1', '2', '3', '4', '5'), true)) {
102
		$input_errors[] = "A valid value must be specified for Platform Trust Service debug.";
103
	}
104
	if (!in_array($pconfig['ipsec_tls'], array('0', '1', '2', '3', '4', '5'), true)) {
105
		$input_errors[] = "A valid value must be specified for TLS Handler debug.";
106
	}
107
	if (!in_array($pconfig['ipsec_esp'], array('0', '1', '2', '3', '4', '5'), true)) {
108
		$input_errors[] = "A valid value must be specified for IPsec Traffic debug.";
109
	}
110
	if (!in_array($pconfig['ipsec_lib'], array('0', '1', '2', '3', '4', '5'), true)) {
111
		$input_errors[] = "A valid value must be specified for StrongSwan Lib debug.";
112
	}
113
	if (isset($pconfig['maxmss'])) {
114
		if (!is_numericint($pconfig['maxmss']) && $pconfig['maxmss'] <> '') {
115
			$input_errors[] = "An integer must be specified for Maximum MSS.";
116
		}
117
		if ($pconfig['maxmss'] <> '' && $pconfig['maxmss'] < 576 || $pconfig['maxmss'] > 65535) {
118
			$input_errors[] = "An integer between 576 and 65535 must be specified for Maximum MSS";
119
		}
120
	}
121

    
122
	if (!$input_errors) {
123

    
124
		foreach ($ipsec_loglevels as $lkey => $ldescr) {
125
			if (empty($_POST["ipsec_{$lkey}"])) {
126
				if (isset($config['ipsec']["ipsec_{$lkey}"])) {
127
					unset($config['ipsec']["ipsec_{$lkey}"]);
128
				}
129
			} else {
130
				$config['ipsec']["ipsec_{$lkey}"] = $_POST["ipsec_{$lkey}"];
131
			}
132
		}
133

    
134
		$needsrestart = false;
135

    
136
		if ($_POST['compression'] == "yes") {
137
			if (!isset($config['ipsec']['compression'])) {
138
				$needsrestart = true;
139
			}
140
			$config['ipsec']['compression'] = true;
141
		} elseif (isset($config['ipsec']['compression'])) {
142
			$needsrestart = true;
143
			unset($config['ipsec']['compression']);
144
		}
145

    
146
		if ($_POST['enableinterfacesuse'] == "yes") {
147
			if (!isset($config['ipsec']['enableinterfacesuse'])) {
148
				$needsrestart = true;
149
			}
150
			$config['ipsec']['enableinterfacesuse'] = true;
151
		} elseif (isset($config['ipsec']['enableinterfacesuse'])) {
152
			$needsrestart = true;
153
			unset($config['ipsec']['enableinterfacesuse']);
154
		}
155

    
156
		if ($_POST['unityplugin'] == "yes") {
157
			if (!isset($config['ipsec']['unityplugin'])) {
158
				$needsrestart = true;
159
			}
160
			$config['ipsec']['unityplugin'] = true;
161
		} elseif (isset($config['ipsec']['unityplugin'])) {
162
			$needsrestart = true;
163
			unset($config['ipsec']['unityplugin']);
164
		}
165
		
166
		if ($_POST['strictcrlpolicy'] == "yes") {
167
			$config['ipsec']['strictcrlpolicy'] = true;
168
		} else {
169
			unset($config['ipsec']['strictcrlpolicy']);
170
		}
171

    
172
		if ($_POST['makebeforebreak'] == "yes") {
173
			$config['ipsec']['makebeforebreak'] = true;
174
		} elseif (isset($config['ipsec']['makebeforebreak'])) {
175
			unset($config['ipsec']['makebeforebreak']);
176
		}
177

    
178
		if ($_POST['noshuntlaninterfaces'] == "yes") {
179
			if (isset($config['ipsec']['noshuntlaninterfaces'])) {
180
				unset($config['ipsec']['noshuntlaninterfaces']);
181
			}
182
		} else {
183
			$config['ipsec']['noshuntlaninterfaces'] = true;
184
		}
185

    
186
		if ($_POST['acceptunencryptedmainmode'] == "yes") {
187
			if (!isset($config['ipsec']['acceptunencryptedmainmode'])) {
188
				$needsrestart = true;
189
			}
190
			$config['ipsec']['acceptunencryptedmainmode'] = true;
191
		} elseif (isset($config['ipsec']['acceptunencryptedmainmode'])) {
192
			$needsrestart = true;
193
			unset($config['ipsec']['acceptunencryptedmainmode']);
194
		}
195

    
196
		if (!empty($_POST['uniqueids'])) {
197
			$config['ipsec']['uniqueids'] = $_POST['uniqueids'];
198
		} else if (isset($config['ipsec']['uniqueids'])) {
199
			unset($config['ipsec']['uniqueids']);
200
		}
201

    
202
		if ($_POST['maxmss_enable'] == "yes") {
203
			$config['system']['maxmss_enable'] = true;
204
			$config['system']['maxmss'] = $_POST['maxmss'];
205
		} else {
206
			if (isset($config['system']['maxmss_enable'])) {
207
				unset($config['system']['maxmss_enable']);
208
			}
209
			if (isset($config['system']['maxmss'])) {
210
				unset($config['system']['maxmss']);
211
			}
212
		}
213

    
214
		write_config();
215

    
216
		$retval = 0;
217
		$retval = filter_configure();
218
		if (stristr($retval, "error") <> true) {
219
			$savemsg = get_std_save_message(gettext($retval));
220
		} else {
221
			$savemsg = gettext($retval);
222
		}
223

    
224
		vpn_ipsec_configure($needsrestart);
225
		vpn_ipsec_configure_loglevels();
226

    
227
		header("Location: vpn_ipsec_settings.php");
228
		return;
229
	}
230

    
231
	// The logic value sent by $POST is opposite to the way it is stored in the config.
232
	// Reset the $pconfig value so it reflects the opposite of what was $POSTed.
233
	if ($_POST['noshuntlaninterfaces'] == "yes") {
234
		$pconfig['noshuntlaninterfaces'] = false;
235
	} else {
236
		$pconfig['noshuntlaninterfaces'] = true;
237
	}
238
}
239

    
240
$pgtitle = array(gettext("VPN"), gettext("IPsec"), gettext("Settings"));
241
$shortcut_section = "ipsec";
242

    
243
include("head.inc");
244
?>
245

    
246
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
247
<?php include("fbegin.inc"); ?>
248

    
249
<script type="text/javascript">
250
//<![CDATA[
251

    
252
function maxmss_checked(obj) {
253
	if (obj.checked) {
254
		jQuery('#maxmss').attr('disabled', false);
255
	} else {
256
		jQuery('#maxmss').attr('disabled', 'true');
257
	}
258
}
259

    
260
//]]>
261
</script>
262

    
263
<form action="vpn_ipsec_settings.php" method="post" name="iform" id="iform">
264

    
265
<?php
266
	if ($savemsg) {
267
		print_info_box($savemsg);
268
	}
269
	if ($input_errors) {
270
		print_input_errors($input_errors);
271
	}
272
?>
273

    
274
<table width="100%" border="0" cellpadding="0" cellspacing="0" summary="vpn ipsec settings">
275
	<tr>
276
		<td class="tabnavtbl">
277
			<?php
278
				$tab_array = array();
279
				$tab_array[0] = array(gettext("Tunnels"), false, "vpn_ipsec.php");
280
				$tab_array[1] = array(gettext("Mobile clients"), false, "vpn_ipsec_mobile.php");
281
				$tab_array[2] = array(gettext("Pre-Shared Key"), false, "vpn_ipsec_keys.php");
282
				$tab_array[3] = array(gettext("Advanced Settings"), true, "vpn_ipsec_settings.php");
283
				display_top_tabs($tab_array);
284
			?>
285
		</td>
286
	</tr>
287
	<tr>
288
		<td id="mainarea">
289
			<div class="tabcont">
290
				<table width="100%" border="0" cellpadding="6" cellspacing="0" summary="main area">
291
					<tr>
292
						<td colspan="2" valign="top" class="listtopic"><?=gettext("IPsec Advanced Settings"); ?></td>
293
					</tr>
294
					<tr>
295
						<td width="22%" valign="top" class="vncell"><?=gettext("IPsec Debug"); ?></td>
296
						<td width="78%" class="vtable">
297
							<strong><?=gettext("Start IPsec in debug mode based on sections selected"); ?></strong>
298
							<br />
299
							<table summary="ipsec debug">
300
							<?php foreach ($ipsec_loglevels as $lkey => $ldescr): ?>
301
								<tr>
302
									<td width="22%" valign="top" class="vncell"><?=$ldescr;?></td>
303
									<td width="78%" valign="top" class="vncell">
304
										<?php
305
										echo "<select name=\"ipsec_{$lkey}\" id=\"ipsec_{$lkey}\">\n";
306
										foreach (array("Silent", "Audit", "Control", "Diag", "Raw", "Highest") as $lidx => $lvalue) {
307
											echo "<option value=\"{$lidx}\" ";
308
											if ($pconfig["ipsec_{$lkey}"] == $lidx) {
309
												echo "selected=\"selected\"";
310
											}
311
											echo ">{$lvalue}</option>\n";
312
										}
313
										?>
314
										</select>
315
									</td>
316
								</tr>
317
							<?php endforeach; ?>
318
								<tr style="display:none;">
319
									<td></td>
320
								</tr>
321
							</table>
322
							<br /><?=gettext("Launches IPsec in debug mode so that more verbose logs " .
323
							"will be generated to aid in troubleshooting."); ?>
324
						</td>
325
					</tr>
326
					<tr>
327
						<td width="22%" valign="top" class="vncell"><?=gettext("Unique IDs"); ?></td>
328
						<td width="78%" class="vtable">
329
							<strong><?=gettext("Configure Unique IDs as: "); ?></strong>
330
							<?php
331
								echo "<select name=\"uniqueids\" id=\"uniqueids\">\n";
332
								foreach ($ipsec_idhandling as $value => $lvalue) {
333
									echo "<option value=\"{$value}\" ";
334
									if ($pconfig['uniqueids'] == $value) {
335
										echo "selected=\"selected\"";
336
									}
337
									echo ">{$lvalue}</option>\n";
338
								}
339
							?>
340
							</select>
341
							<br />
342
							<?=gettext("whether a particular participant ID should be kept unique, with any new IKE_SA using an ID " .
343
								"deemed to replace all old ones using that ID. Participant IDs normally are unique, so a new " .
344
								"IKE_SA using the same ID is almost invariably intended to replace an old one. " .
345
								"The difference between <b>no</b> and <b>never</b> is that the old IKE_SAs will be replaced when receiving an " .
346
								"INITIAL_CONTACT notify if the option is no but will ignore these notifies if <b>never</b> is configured. " .
347
								"The daemon also accepts the value <b>keep</b> to reject " .
348
								"new IKE_SA setups and keep the duplicate established earlier. Defaults to Yes."); ?>
349
						</td>
350
					</tr>
351
					<tr>
352
						<td width="22%" valign="top" class="vncell"><?=gettext("IP Compression"); ?></td>
353
						<td width="78%" class="vtable">
354
							<input name="compression" type="checkbox" id="compression" value="yes" <?php if ($pconfig['compression']) echo "checked=\"checked\""; ?> />
355
							<strong><?=gettext("Enable IPCompression"); ?></strong>
356
							<br />
357
							<?=gettext("IPComp compression of content is proposed on the connection."); ?>
358
						</td>
359
					</tr>
360
					<tr>
361
						<td width="22%" valign="top" class="vncell"><?=gettext("Strict interface binding"); ?></td>
362
						<td width="78%" class="vtable">
363
							<input name="enableinterfacesuse" type="checkbox" id="enableinterfacesuse" value="yes" <?php if ($pconfig['enableinterfacesuse']) echo "checked=\"checked\""; ?> />
364
							<strong><?=gettext("Enable strict interface binding"); ?></strong>
365
							<br />
366
							<?=gettext("Enable strongSwan's interfaces_use option to bind specific interfaces only. This option is known to break IPsec with dynamic IP interfaces. This is not recommended at this time."); ?>
367
						</td>
368
					</tr>
369
					<tr>
370
						<td width="22%" valign="top" class="vncell"><?=gettext("Unencrypted payloads in IKEv1 Main Mode"); ?></td>
371
						<td width="78%" class="vtable">
372
							<input name="acceptunencryptedmainmode" type="checkbox" id="acceptunencryptedmainmode" value="yes" <?php if ($pconfig['acceptunencryptedmainmode']) echo "checked=\"checked\""; ?> />
373
							<strong><?=gettext("Accept unencrypted ID and HASH payloads in IKEv1 Main Mode"); ?></strong>
374
							<br />
375
							<?=gettext("Some implementations send the third Main Mode message unencrypted, probably to find the PSKs for the specified ID for authentication." .
376
							"This is very similar to Aggressive Mode, and has the same security implications: " .
377
							"A passive attacker can sniff the negotiated Identity, and start brute forcing the PSK using the HASH payload." .
378
							" It is recommended to keep this option to no, unless you know exactly what the implications are and require compatibility to such devices (for example, some SonicWall boxes).");?>
379
						</td>
380
					</tr>
381
					<tr>
382
						<td width="22%" valign="top" class="vncell"><?=gettext("Maximum MSS"); ?></td>
383
						<td width="78%" class="vtable">
384
							<input name="maxmss_enable" type="checkbox" id="maxmss_enable" value="yes" <?php if ($pconfig['maxmss_enable'] == true) echo "checked=\"checked\""; ?> onclick="maxmss_checked(this)" />
385
							<strong><?=gettext("Enable MSS clamping on VPN traffic"); ?></strong>
386
							<br />
387
							<input name="maxmss" id="maxmss" value="<?php if ($pconfig['maxmss'] <> "") echo htmlspecialchars($pconfig['maxmss']); else "1400"; ?>" class="formfld unknown" <?php if ($pconfig['maxmss_enable'] == false) echo "disabled=\"disabled\""; ?> />
388
							<br />
389
							<?=gettext("Enable MSS clamping on TCP flows over VPN. " .
390
							"This helps overcome problems with PMTUD on IPsec VPN links. If left blank, the default value is 1400 bytes. "); ?>
391
						</td>
392
					</tr>
393
					<tr>
394
						<td width="22%" valign="top" class="vncell"><?=gettext("Disable Cisco Extensions"); ?></td>
395
						<td width="78%" class="vtable">
396
							<input name="unityplugin" type="checkbox" id="unityplugin" value="yes" <?php if ($pconfig['unityplugin'] == true) echo "checked=\"checked\""; ?> />
397
							<strong><?=gettext("Disable Unity Plugin"); ?></strong>
398
							<br />
399
							<?=gettext("Disable Unity Plugin which provides Cisco Extension support as Split-Include, Split-Exclude, Split-Dns, ..."); ?>
400
						</td>
401
					</tr>
402
					<tr>
403
						<td width="22%" valign="top" class="vncell"><?=gettext("Strict CRL Checking"); ?></td>
404
						<td width="78%" class="vtable">
405
							<input name="strictcrlpolicy" type="checkbox" id="strictcrlpolicy" value="yes" <?php if ($pconfig['strictcrlpolicy'] == true) echo "checked=\"checked\""; ?> />
406
							<strong><?=gettext("Enable strict Certificate Revocation List checking"); ?></strong>
407
							<br />
408
							<?=gettext("Check this to require availability of a fresh CRL for peer authentication based on RSA signatures to succeed."); ?>
409
						</td>
410
					</tr>
411
					<tr>
412
						<td width="22%" valign="top" class="vncell"><?=gettext("Make before Break"); ?></td>
413
						<td width="78%" class="vtable">
414
							<input name="makebeforebreak" type="checkbox" id="makebeforebreak" value="yes" <?php if ($pconfig['makebeforebreak'] == true) echo "checked=\"checked\""; ?> />
415
							<strong><?=gettext("Initiate IKEv2 reauthentication with a make-before-break"); ?></strong>
416
							<br />
417
							<?=gettext("instead of a break-before-make scheme. Make-before-break uses overlapping IKE and CHILD_SA during reauthentication " .
418
								"by first recreating all new SAs before deleting the old ones. This behavior can be beneficial to avoid connectivity gaps " .
419
								"during reauthentication, but requires support for overlapping SAs by the peer.");?>
420
						</td>
421
					</tr>
422
					<tr>
423
						<td width="22%" valign="top" class="vncell"><?=gettext("Auto-exclude LAN address"); ?></td>
424
						<td width="78%" class="vtable">
425
							<input name="noshuntlaninterfaces" type="checkbox" id="noshuntlaninterfaces" value="yes" <?php if ($pconfig['noshuntlaninterfaces'] != true) echo "checked=\"checked\""; ?> />
426
							<strong><?=gettext("Enable bypass for LAN interface IP"); ?></strong>
427
							<br />
428
							<?=gettext("Exclude traffic from LAN subnet to LAN IP address from IPsec."); ?>
429
						</td>
430
					</tr>
431
					<tr>
432
						<td width="22%" valign="top">&nbsp;</td>
433
						<td width="78%">
434
							<input name="submit" type="submit" class="formbtn" value="<?=gettext("Save"); ?>" />
435
						</td>
436
					</tr>
437
				</table>
438
			</div>
439
		</td>
440
	</tr>
441
</table>
442
</form>
443
<?php include("fend.inc"); ?>
444
</body>
445
</html>
(239-239/252)