Project

General

Profile

Download (18.5 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
$pconfig['unityplugin'] = isset($config['ipsec']['unityplugin']);
49
$pconfig['strictcrlpolicy'] = isset($config['ipsec']['strictcrlpolicy']);
50
$pconfig['makebeforebreak'] = isset($config['ipsec']['makebeforebreak']);
51
$pconfig['noshuntlaninterfaces'] = isset($config['ipsec']['noshuntlaninterfaces']);
52
$pconfig['compression'] = isset($config['ipsec']['compression']);
53
$pconfig['enableinterfacesuse'] = isset($config['ipsec']['enableinterfacesuse']);
54
$pconfig['acceptunencryptedmainmode'] = isset($config['ipsec']['acceptunencryptedmainmode']);
55
$pconfig['maxmss_enable'] = isset($config['system']['maxmss_enable']);
56
$pconfig['maxmss'] = $config['system']['maxmss'];
57
$pconfig['uniqueids'] = $config['ipsec']['uniqueids'];
58

    
59
if ($_POST) {
60

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

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

    
132
		$needsrestart = false;
133

    
134
		if($_POST['compression'] == "yes") {
135
			if (!isset($config['ipsec']['compression']))
136
				$needsrestart = true;
137
			$config['ipsec']['compression'] = true;
138
		} elseif (isset($config['ipsec']['compression'])) {
139
			$needsrestart = true;
140
			unset($config['ipsec']['compression']);
141
		}
142
		
143
		if($_POST['enableinterfacesuse'] == "yes") {
144
			if (!isset($config['ipsec']['enableinterfacesuse']))
145
				$needsrestart = true;
146
			$config['ipsec']['enableinterfacesuse'] = true;
147
		} elseif (isset($config['ipsec']['enableinterfacesuse'])) {
148
			$needsrestart = true;
149
			unset($config['ipsec']['enableinterfacesuse']);
150
		}
151

    
152
		if($_POST['unityplugin'] == "yes") {
153
			if (!isset($config['ipsec']['unityplugin']))
154
				$needsrestart = true;
155
			$config['ipsec']['unityplugin'] = true;
156
		} elseif (isset($config['ipsec']['unityplugin'])) {
157
			$needsrestart = true;
158
			unset($config['ipsec']['unityplugin']);
159
		}
160
		
161
		if ($_POST['strictcrlpolicy'] == "yes") {
162
			$config['ipsec']['strictcrlpolicy'] = true;
163
		} elseif (isset($config['ipsec']['strictcrlpolicy'])) {
164
			unset($config['ipsec']['strictcrlpolicy']);
165
		}
166

    
167
		if($_POST['makebeforebreak'] == "yes") {
168
			$config['ipsec']['makebeforebreak'] = true;
169
		} elseif (isset($config['ipsec']['makebeforebreak'])) {
170
			unset($config['ipsec']['makebeforebreak']);
171
		}
172

    
173
		/* The weird logic here is to avoid negative policies when checked #4655 */
174
		if ($_POST['noshuntlaninterfaces'] == "yes") {
175
			if (isset($config['ipsec']['noshuntlaninterfaces'])) {
176
				unset($config['ipsec']['noshuntlaninterfaces']);
177
			}
178
		} else {
179
			$config['ipsec']['noshuntlaninterfaces'] = true;
180
		}
181

    
182
		if($_POST['acceptunencryptedmainmode'] == "yes") {
183
			if (!isset($config['ipsec']['acceptunencryptedmainmode']))
184
				$needsrestart = true;
185
			$config['ipsec']['acceptunencryptedmainmode'] = true;
186
		} elseif (isset($config['ipsec']['acceptunencryptedmainmode'])) {
187
			$needsrestart = true;
188
			unset($config['ipsec']['acceptunencryptedmainmode']);
189
		}
190

    
191
		if(!empty($_POST['uniqueids'])) {
192
			$config['ipsec']['uniqueids'] = $_POST['uniqueids'];
193
		} else if (isset($config['ipsec']['uniqueids'])) {
194
			unset($config['ipsec']['uniqueids']);
195
		}
196

    
197
		if($_POST['maxmss_enable'] == "yes") {
198
			$config['system']['maxmss_enable'] = true;
199
			$config['system']['maxmss'] = $_POST['maxmss'];
200
		} else {
201
			if (isset($config['system']['maxmss_enable'])) {
202
				unset($config['system']['maxmss_enable']);
203
			}
204
			if (isset($config['system']['maxmss'])) {
205
				unset($config['system']['maxmss']);
206
			}
207
		}
208

    
209
		write_config();
210

    
211
		$retval = 0;
212
		$retval = filter_configure();
213
		if(stristr($retval, "error") <> true)
214
			$savemsg = get_std_save_message(gettext($retval));
215
		else
216
			$savemsg = gettext($retval);
217

    
218
		vpn_ipsec_configure($needsrestart);
219
		vpn_ipsec_configure_loglevels();
220

    
221
		header("Location: vpn_ipsec_settings.php");
222
		return;
223
	}
224

    
225
	// The logic value sent by $POST is opposite to the way it is stored in the config.
226
	// Reset the $pconfig value so it reflects the opposite of what was $POSTed.
227
	if ($_POST['noshuntlaninterfaces'] == "yes") {
228
		$pconfig['noshuntlaninterfaces'] = false;
229
	} else {
230
		$pconfig['noshuntlaninterfaces'] = true;
231
	}
232
}
233

    
234
$pgtitle = array(gettext("VPN"),gettext("IPsec"),gettext("Settings"));
235
$shortcut_section = "ipsec";
236

    
237
include("head.inc");
238
?>
239

    
240
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
241
<?php include("fbegin.inc"); ?>
242

    
243
<script type="text/javascript">
244
//<![CDATA[
245

    
246
function maxmss_checked(obj) {
247
	if (obj.checked)
248
		jQuery('#maxmss').attr('disabled',false);
249
	else
250
		jQuery('#maxmss').attr('disabled','true');
251
}
252

    
253
//]]>
254
</script>
255

    
256
<form action="vpn_ipsec_settings.php" method="post" name="iform" id="iform">
257

    
258
<?php
259
	if ($savemsg)
260
		print_info_box($savemsg);
261
	if ($input_errors)
262
		print_input_errors($input_errors);
263
?>
264

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