]>
git.ipfire.org Git - ipfire-2.x.git/blob - html/cgi-bin/vpnmain.cgi
3 # This file is part of the IPCop Firewall.
5 # IPCop is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2 of the License, or
8 # (at your option) any later version.
10 # IPCop is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with IPCop; if not, write to the Free Software
17 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 # Copyright (C) 2003-05-25 Mark Wormgoor <mark@wormgoor.com>
21 # $Id: vpnmain.cgi,v 1.10.2.104 2006/11/30 12:43:10 franck78 Exp $
26 use File
:: Temp qw
/ tempfile tempdir / ;
29 # enable only the following on debugging purpose
31 #use CGI::Carp 'fatalsToBrowser';
33 require '/var/ipfire/general-functions.pl' ;
34 require "${General::swroot}/lang.pl" ;
35 require "${General::swroot}/header.pl" ;
36 require "${General::swroot}/countries.pl" ;
38 #workaround to suppress a warning when a variable is used only once
39 my @dummy = ( ${ Header
:: colourgreen
}, ${ Header
:: colourblue
} );
43 ### Initialize variables
45 my $sleepDelay = 4 ; # after a call to ipsecctrl S or R, wait this delay (seconds) before reading status
46 # (let the ipsec do its job)
55 my $errormessage = '' ;
57 & General
:: readhash
( "${General::swroot}/ethernet/settings" , \
%netsettings );
58 $cgiparams { 'ENABLED' } = 'off' ;
59 $cgiparams { 'ENABLED_GREEN' } = 'off' ;
60 $cgiparams { 'ENABLED_ORANGE' } = 'off' ;
61 $cgiparams { 'ENABLED_BLUE' } = 'off' ;
62 $cgiparams { 'EDIT_ADVANCED' } = 'off' ;
63 $cgiparams { 'ACTION' } = '' ;
64 $cgiparams { 'CA_NAME' } = '' ;
65 $cgiparams { 'DBG_CRYPT' } = '' ;
66 $cgiparams { 'DBG_PARSING' } = '' ;
67 $cgiparams { 'DBG_EMITTING' } = '' ;
68 $cgiparams { 'DBG_CONTROL' } = '' ;
69 $cgiparams { 'DBG_KLIPS' } = '' ;
70 $cgiparams { 'DBG_DNS' } = '' ;
71 $cgiparams { 'DBG_NAT_T' } = '' ;
72 $cgiparams { 'KEY' } = '' ;
73 $cgiparams { 'TYPE' } = '' ;
74 $cgiparams { 'ADVANCED' } = '' ;
75 $cgiparams { 'INTERFACE' } = '' ;
76 $cgiparams { 'NAME' } = '' ;
77 $cgiparams { 'LOCAL_SUBNET' } = '' ;
78 $cgiparams { 'REMOTE_SUBNET' } = '' ;
79 $cgiparams { 'REMOTE' } = '' ;
80 $cgiparams { 'LOCAL_ID' } = '' ;
81 $cgiparams { 'REMOTE_ID' } = '' ;
82 $cgiparams { 'REMARK' } = '' ;
83 $cgiparams { 'PSK' } = '' ;
84 $cgiparams { 'CERT_NAME' } = '' ;
85 $cgiparams { 'CERT_EMAIL' } = '' ;
86 $cgiparams { 'CERT_OU' } = '' ;
87 $cgiparams { 'CERT_ORGANIZATION' } = '' ;
88 $cgiparams { 'CERT_CITY' } = '' ;
89 $cgiparams { 'CERT_STATE' } = '' ;
90 $cgiparams { 'CERT_COUNTRY' } = '' ;
91 $cgiparams { 'SUBJECTALTNAME' } = '' ;
92 $cgiparams { 'CERT_PASS1' } = '' ;
93 $cgiparams { 'CERT_PASS2' } = '' ;
94 $cgiparams { 'ROOTCERT_HOSTNAME' } = '' ;
95 $cgiparams { 'ROOTCERT_COUNTRY' } = '' ;
96 $cgiparams { 'P12_PASS' } = '' ;
97 $cgiparams { 'ROOTCERT_ORGANIZATION' } = '' ;
98 $cgiparams { 'ROOTCERT_HOSTNAME' } = '' ;
99 $cgiparams { 'ROOTCERT_EMAIL' } = '' ;
100 $cgiparams { 'ROOTCERT_OU' } = '' ;
101 $cgiparams { 'ROOTCERT_CITY' } = '' ;
102 $cgiparams { 'ROOTCERT_STATE' } = '' ;
104 & Header
:: getcgihash
( \
%cgiparams , { 'wantfile' => 1 , 'filevar' => 'FH' });
110 my $hostname = $_ [ 0 ];
111 unless ( $hostname ) { return "No hostname" };
112 my $res = new Net
:: DNS
:: Resolver
;
113 my $query = $res -> search ( " $hostname " );
115 foreach my $rr ( $query -> answer ) {
116 ## Potential bug - we are only looking at A records:
117 return 0 if $rr -> type eq "A" ;
120 return $res -> errorstring ;
124 ### Just return true is one interface is vpn enabled
127 return ( $vpnsettings { 'ENABLED' } eq 'on' ||
128 $vpnsettings { 'ENABLED_GREEN' } eq 'on' ||
129 $vpnsettings { 'ENABLED_ORANGE' } eq 'on' ||
130 $vpnsettings { 'ENABLED_BLUE' } eq 'on' );
133 ### old version: maintain serial number to one, without explication.
134 ### this : let the counter go, so that each cert is numbered.
138 if ( open ( FILE
, ">${General::swroot}/certs/serial" )) {
142 if ( open ( FILE
, ">${General::swroot}/certs/index.txt" )) {
146 unlink ( "${General::swroot}/certs/index.txt.old" );
147 unlink ( "${General::swroot}/certs/serial.old" );
148 unlink ( "${General::swroot}/certs/01.pem" );
150 sub newcleanssldatabase
152 if (! - s
"${General::swroot}/certs/serial" ) {
153 open ( FILE
, ">${General::swroot}/certs/serial" );
157 if (! - s
">${General::swroot}/certs/index.txt" ) {
158 system ( "touch ${General::swroot}/certs/index.txt" );
160 unlink ( "${General::swroot}/certs/index.txt.old" );
161 unlink ( "${General::swroot}/certs/serial.old" );
162 # unlink ("${General::swroot}/certs/01.pem"); numbering evolves. Wrong place to delete
166 ### Call openssl and return errormessage if any
170 my $retssl = `/usr/bin/openssl $opt 2>&1` ; #redirect stderr
172 foreach my $line ( split ( /\n/ , $retssl )) {
173 & General
:: log ( "ipsec" , " $line " ) if ( 0 ); # 1 for verbose logging
174 $ret .= '<br>' . $line if ( $line =~ /error|unknown/ );
177 $ret = & Header
:: cleanhtml
( $ret );
179 return $ret ?
" $Lang ::tr{'openssl produced an error'}: $ret " : '' ;
182 ### Obtain a CN from given cert
184 sub getCNfromcert
($) {
185 #&General::log("ipsec", "Extracting name from $_[0]...");
186 my $temp = `/usr/bin/openssl x509 -text -in $_ [0]` ;
187 $temp =~ /Subject:.*CN=(.*)[\n]/ ;
189 $temp =~ s
+/ Email
+, E
+;
190 $temp =~ s/ ST=/ S=/ ;
196 ### Obtain Subject from given cert
198 sub getsubjectfromcert
($) {
199 #&General::log("ipsec", "Extracting subject from $_[0]...");
200 my $temp = `/usr/bin/openssl x509 -text -in $_ [0]` ;
201 $temp =~ /Subject: (.*)[\n]/ ;
203 $temp =~ s
+/ Email
+, E
+;
204 $temp =~ s/ ST=/ S=/ ;
208 ### Combine local subnet and connection name to make a unique name for each connection section
209 ### (this sub is not used now)
211 sub makeconnname
($) {
215 $subnet =~ /^(.*?)\/ (.* ?
)$/; # $1=IP $2=mask
216 my $ip = unpack ( 'N' , & Socket
:: inet_aton
( $1 ));
217 if ( length ( $2 ) > 2 ) {
218 my $mm = unpack ( 'N' , & Socket
:: inet_aton
( $2 ));
219 while ( ( $mm & 1 )== 0 ) {
226 return sprintf ( " %s - %X " , $conn , $ip );
229 ### Write a config file.
231 ###Type=Host : GUI can choose the interface used (RED,GREEN,BLUE) and
232 ### the side is always defined as 'left'.
233 ### configihash[14]: 'VHOST' is allowed
235 ###Type=Net : GUI can choose to be left or right. This serve nothing in the conf!
236 ### interface is fixed to RED only. No special reason for this also.
239 sub writeipsecfiles
{
240 my %lconfighash = ();
241 my %lvpnsettings = ();
242 & General
:: readhasharray
( "${General::swroot}/vpn/config" , \
%lconfighash );
243 & General
:: readhash
( "${General::swroot}/vpn/settings" , \
%lvpnsettings );
245 open ( CONF
, ">${General::swroot}/vpn/ipsec.conf" ) or die "Unable to open ${General::swroot}/vpn/ipsec.conf: $!" ;
246 open ( SECRETS
, ">${General::swroot}/vpn/ipsec.secrets" ) or die "Unable to open ${General::swroot}/vpn/ipsec.secrets: $!" ;
249 print CONF
"version 2 \n\n " ;
250 print CONF
"config setup \n " ;
251 #create an ipsec Interface for each 'enabled' ones
252 my $interfaces = " \t interfaces= \" " ;
253 $interfaces .= " %defaultroute " if ( $lvpnsettings { 'ENABLED' } eq 'on' );
254 $interfaces .= "ipsec1= $netsettings {'GREEN_DEV'} " if ( $lvpnsettings { 'ENABLED_GREEN' } eq 'on' );
255 $interfaces .= "ipsec2= $netsettings {'BLUE_DEV'} " if ( $lvpnsettings { 'ENABLED_BLUE' } eq 'on' );
256 $interfaces .= "ipsec3= $netsettings {'ORANGE_DEV'} " if ( $lvpnsettings { 'ENABLED_ORANGE' } eq 'on' );
257 print CONF
$interfaces . " \"\n " ;
259 my $plutodebug = '' ; # build debug list
260 map ( $plutodebug .= $lvpnsettings { $_ } eq 'on' ?
lc ( substr ( $_ , 4 )). ' ' : '' ,
261 ( 'DBG_CRYPT' , 'DBG_PARSING' , 'DBG_EMITTING' , 'DBG_CONTROL' ,
262 'DBG_KLIPS' , 'DBG_DNS' , 'DBG_NAT_T' ));
263 $plutodebug = 'none' if $plutodebug eq '' ; # if nothing selected, use 'none'.
264 print CONF
" \t klipsdebug= \" none \"\n " ;
265 print CONF
" \t plutodebug= \" $plutodebug \"\n " ;
266 # deprecated in ipsec.conf version 2
267 #print CONF "\tplutoload=%search\n";
268 #print CONF "\tplutostart=%search\n";
269 print CONF
" \t plutoload= %search \n " ;
270 print CONF
" \t plutostart= %search \n " ;
271 print CONF
" \t uniqueids=yes \n " ;
272 print CONF
" \t nat_traversal=yes \n " ;
273 print CONF
" \t overridemtu= $lvpnsettings {'VPN_OVERRIDE_MTU'} \n " if ( $lvpnsettings { 'VPN_OVERRIDE_MTU' } ne '' );
274 print CONF
" \t virtual_private= %v4 :10.0.0.0/8, %v4 :172.16.0.0/12, %v4 :192.168.0.0/16" ;
275 print CONF
", %v4 :! $netsettings {'GREEN_NETADDRESS'}/ $netsettings {'GREEN_NETMASK'}" ;
276 if ( length ( $netsettings { 'ORANGE_DEV' }) > 2 ) {
277 print CONF
", %v4 :! $netsettings {'ORANGE_NETADDRESS'}/ $netsettings {'ORANGE_NETMASK'}" ;
279 if ( length ( $netsettings { 'BLUE_DEV' }) > 2 ) {
280 print CONF
", %v4 :! $netsettings {'BLUE_NETADDRESS'}/ $netsettings {'BLUE_NETMASK'}" ;
282 foreach my $key ( keys %lconfighash ) {
283 if ( $lconfighash { $key }[ 3 ] eq 'net' ) {
284 print CONF
", %v4 :! $lconfighash { $key }[11]" ;
288 print CONF
"conn %default \n " ;
289 print CONF
" \t keyingtries=0 \n " ;
290 print CONF
" \t disablearrivalcheck=no \n " ;
293 if (- f
"${General::swroot}/certs/hostkey.pem" ) {
294 print SECRETS
": RSA ${General::swroot}/certs/hostkey.pem \n "
296 my $last_secrets = '' ; # old the less specifics connections
298 foreach my $key ( keys %lconfighash ) {
299 next if ( $lconfighash { $key }[ 0 ] ne 'on' );
301 #remote peer is not set? => use '%any'
302 $lconfighash { $key }[ 10 ] = ' %any ' if ( $lconfighash { $key }[ 10 ] eq '' );
304 my ( $L , $R ); #Local & Remote sides
306 print CONF
"conn $lconfighash { $key }[1] \n " ;
307 #always choose LEFT localside for roadwarrior
308 if ( $lconfighash { $key }[ 3 ] eq 'host' || $lconfighash { $key }[ 6 ] eq 'left' ) {
315 print CONF
" \t ${L}=" ;
316 if ( $lconfighash { $key }[ 26 ] eq 'BLUE' ) {
317 print CONF
" $netsettings {'BLUE_ADDRESS'} \n " ;
318 } elsif ( $lconfighash { $key }[ 26 ] eq 'ORANGE' ) {
319 print CONF
" $netsettings {'ORANGE_ADDRESS'} \n " ;
320 } elsif ( $lconfighash { $key }[ 26 ] eq 'GREEN' ) {
321 print CONF
" $netsettings {'GREEN_ADDRESS'} \n " ;
322 } elsif ( $lconfighash { $key }[ 26 ] eq 'RED' ) {
323 print CONF
" $lvpnsettings {'VPN_IP'} \n " ;
324 print CONF
" \t ${L}nexthop= %defaultroute \n " if ( $lvpnsettings { 'VPN_IP' } ne ' %defaultroute ' );
326 print CONF
" \t ${L}subnet= $lconfighash { $key }[8] \n " ;
327 print CONF
" \t ${R}= $lconfighash { $key }[10] \n " ;
329 if ( $lconfighash { $key }[ 3 ] eq 'net' ) {
330 print CONF
" \t ${R}subnet= $lconfighash { $key }[11] \n " ;
331 print CONF
" \t ${R}nexthop= %defaultroute \n " ;
332 } elsif ( $lconfighash { $key }[ 10 ] eq ' %any ' && $lconfighash { $key }[ 14 ] eq 'on' ) { #vhost allowed?
333 print CONF
" \t rightsubnet=vhost: %no , %priv \n " ;
336 # Local Cert and Remote Cert (unless auth is DN dn-auth)
337 if ( $lconfighash { $key }[ 4 ] eq 'cert' ) {
338 print CONF
" \t ${L}cert=${General::swroot}/certs/hostcert.pem \n " ;
339 print CONF
" \t ${R}cert=${General::swroot}/certs/ $lconfighash { $key }[1]cert.pem \n " if ( $lconfighash { $key }[ 2 ] ne ' %auth -dn' );
342 # Local and Remote IDs
343 print CONF
" \t ${L}id= \" $lconfighash { $key }[7] \"\n " if ( $lconfighash { $key }[ 7 ]);
344 print CONF
" \t ${R}id= \" $lconfighash { $key }[9] \"\n " if ( $lconfighash { $key }[ 9 ]);
347 if ( $lconfighash { $key }[ 18 ] && $lconfighash { $key }[ 19 ] && $lconfighash { $key }[ 20 ]) {
349 my @encs = split ( '\|' , $lconfighash { $key }[ 18 ]);
350 my @ints = split ( '\|' , $lconfighash { $key }[ 19 ]);
351 my @groups = split ( '\|' , $lconfighash { $key }[ 20 ]);
353 foreach my $i ( @encs ) {
354 foreach my $j ( @ints ) {
355 foreach my $k ( @groups ) {
356 if ( $comma != 0 ) { print CONF
"," ; } else { $comma = 1 ; }
357 print CONF
" $i - $j -modp $k " ;
361 if ( $lconfighash { $key }[ 24 ] eq 'on' ) { #only proposed algorythms?
367 if ( $lconfighash { $key }[ 21 ] && $lconfighash { $key }[ 22 ]) {
369 my @encs = split ( '\|' , $lconfighash { $key }[ 21 ]);
370 my @ints = split ( '\|' , $lconfighash { $key }[ 22 ]);
372 foreach my $i ( @encs ) {
373 foreach my $j ( @ints ) {
374 if ( $comma != 0 ) { print CONF
"," ; } else { $comma = 1 ; }
378 if ( $lconfighash { $key }[ 24 ] eq 'on' ) { #only proposed algorythms?
384 if ( $lconfighash { $key }[ 23 ]) {
385 print CONF
" \t pfsgroup= $lconfighash { $key }[23] \n " ;
389 print CONF
" \t ikelifetime= $lconfighash { $key }[16]h \n " if ( $lconfighash { $key }[ 16 ]);
390 print CONF
" \t keylife= $lconfighash { $key }[17]h \n " if ( $lconfighash { $key }[ 17 ]);
393 print CONF
" \t aggrmode=yes \n " if ( $lconfighash { $key }[ 12 ] eq 'on' );
396 print CONF
" \t compress=yes \n " if ( $lconfighash { $key }[ 13 ] eq 'on' );
398 # Dead Peer Detection
399 print CONF
" \t dpddelay=30 \n " ;
400 print CONF
" \t dpdtimeout=120 \n " ;
401 print CONF
" \t dpdaction= $lconfighash { $key }[27] \n " ;
404 print CONF
" \t pfs=" . ( $lconfighash { $key }[ 28 ] eq 'on' ?
"yes \n " : "no \n " );
406 # Build Authentication details: LEFTid RIGHTid : PSK psk
408 if ( $lconfighash { $key }[ 4 ] eq 'psk' ) {
410 if ( $lconfighash { $key }[ 26 ] eq 'BLUE' ) {
411 $localside = $netsettings { 'BLUE_ADDRESS' };
412 } elsif ( $lconfighash { $key }[ 26 ] eq 'GREEN' ) {
413 $localside = $netsettings { 'GREEN_ADDRESS' };
414 } elsif ( $lconfighash { $key }[ 26 ] eq 'ORANGE' ) {
415 $localside = $netsettings { 'ORANGE_ADDRESS' };
417 $localside = $lvpnsettings { 'VPN_IP' };
419 $psk_line = ( $lconfighash { $key }[ 7 ] ?
$lconfighash { $key }[ 7 ] : $localside ) . " " ;
420 $psk_line .= $lconfighash { $key }[ 9 ] ?
$lconfighash { $key }[ 9 ] : $lconfighash { $key }[ 10 ]; #remoteid or remote address?
421 $psk_line .= " : PSK ' $lconfighash { $key }[5]' \n " ;
422 # if the line contains %any, it is less specific than two IP or ID, so move it at end of file.
423 if ( $psk_line =~ /%any/ ) {
424 $last_secrets .= $psk_line ;
426 print SECRETS
$psk_line ;
428 print CONF
" \t authby=secret \n " ;
430 print CONF
" \t authby=rsasig \n " ;
431 print CONF
" \t leftrsasigkey= %cert \n " ;
432 print CONF
" \t rightrsasigkey= %cert \n " ;
435 # Automatically start only if a net-to-net connection
436 if ( $lconfighash { $key }[ 3 ] eq 'host' ) {
437 print CONF
" \t auto=add \n " ;
439 print CONF
" \t auto=start \n " ;
443 print SECRETS
$last_secrets if ( $last_secrets );
449 ### Save main settings
451 if ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'save' } && $cgiparams { 'TYPE' } eq '' && $cgiparams { 'KEY' } eq '' ) {
452 & General
:: readhash
( "${General::swroot}/vpn/settings" , \
%vpnsettings );
453 unless (& General
:: validfqdn
( $cgiparams { 'VPN_IP' }) || & General
:: validip
( $cgiparams { 'VPN_IP' })
454 || $cgiparams { 'VPN_IP' } eq ' %defaultroute ' ) {
455 $errormessage = $Lang :: tr
{ 'invalid input for hostname' };
459 unless ( $cgiparams { 'VPN_DELAYED_START' } =~ /^[0-9]{1,3}$/ ) { #allow 0-999 seconds !
460 $errormessage = $Lang :: tr
{ 'invalid time period' };
464 unless ( $cgiparams { 'VPN_OVERRIDE_MTU' } =~ /^(|[0-9]{1,5})$/ ) { #allow 0-99999
465 $errormessage = $Lang :: tr
{ 'vpn mtu invalid' };
469 unless ( $cgiparams { 'VPN_WATCH' } =~ /^(|off|on)$/ ) {
470 $errormessage = $Lang :: tr
{ 'invalid input' };
474 map ( $vpnsettings { $_ } = $cgiparams { $_ },
475 ( 'ENABLED' , 'ENABLED_GREEN' , 'ENABLED_ORANGE' , 'ENABLED_BLUE' , 'DBG_CRYPT' , 'DBG_PARSING' , 'DBG_EMITTING' , 'DBG_CONTROL' ,
476 'DBG_KLIPS' , 'DBG_DNS' , 'DBG_NAT_T' ));
478 $vpnsettings { 'VPN_IP' } = $cgiparams { 'VPN_IP' };
479 $vpnsettings { 'VPN_DELAYED_START' } = $cgiparams { 'VPN_DELAYED_START' };
480 $vpnsettings { 'VPN_OVERRIDE_MTU' } = $cgiparams { 'VPN_OVERRIDE_MTU' };
481 $vpnsettings { 'VPN_WATCH' } = $cgiparams { 'VPN_WATCH' };
482 & General
:: writehash
( "${General::swroot}/vpn/settings" , \
%vpnsettings );
485 system ( '/usr/local/bin/ipsecctrl' , 'S' );
487 system ( '/usr/local/bin/ipsecctrl' , 'D' );
494 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'remove x509' } && $cgiparams { 'AREUSURE' } eq 'yes' ) {
495 & General
:: readhasharray
( "${General::swroot}/vpn/config" , \
%confighash );
497 foreach my $key ( keys %confighash ) {
498 if ( $confighash { $key }[ 4 ] eq 'cert' ) {
499 delete $confighash { $key };
502 while ( my $file = glob ( "${General::swroot}/{ca,certs,crls,private}/*" )) {
506 if ( open ( FILE
, ">${General::swroot}/vpn/caconfig" )) {
510 & General
:: writehasharray
( "${General::swroot}/vpn/config" , \
%confighash );
512 system ( '/usr/local/bin/ipsecctrl' , 'R' );
518 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'remove x509' }) {
519 & Header
:: showhttpheaders
();
520 & Header
:: openpage
( $Lang :: tr
{ 'vpn configuration main' }, 1 , '' );
521 & Header
:: openbigbox
( '100%' , 'left' , '' , '' );
522 & Header
:: openbox
( '100%' , 'left' , $Lang :: tr
{ 'are you sure' });
524 <form method='post' action=' $ENV {'SCRIPT_NAME'}'>
528 <input type='hidden' name='AREUSURE' value='yes' />
529 <b><font color='${Header::colourred}'> $Lang ::tr{'capswarning'}</font></b>:
530 $Lang ::tr{'resetting the vpn configuration will remove the root ca, the host certificate and all certificate based connections'}</td>
533 <input type='submit' name='ACTION' value=' $Lang ::tr{'remove x509'}' />
534 <input type='submit' name='ACTION' value=' $Lang ::tr{'cancel'}' /></td>
541 & Header
:: closebigbox
();
542 & Header
:: closepage
();
546 ### Upload CA Certificate
548 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'upload ca certificate' }) {
549 & General
:: readhasharray
( "${General::swroot}/vpn/caconfig" , \
%cahash );
551 if ( $cgiparams { 'CA_NAME' } !~ /^[a-zA-Z0-9]+$/ ) {
552 $errormessage = $Lang :: tr
{ 'name must only contain characters' };
556 if ( length ( $cgiparams { 'CA_NAME' }) > 60 ) {
557 $errormessage = $Lang :: tr
{ 'name too long' };
561 if ( $cgiparams { 'CA_NAME' } eq 'ca' ) {
562 $errormessage = $Lang :: tr
{ 'name is invalid' };
563 goto UPLOAD_CA_ERROR
;
566 # Check if there is no other entry with this name
567 foreach my $key ( keys %cahash ) {
568 if ( $cahash { $key }[ 0 ] eq $cgiparams { 'CA_NAME' }) {
569 $errormessage = $Lang :: tr
{ 'a ca certificate with this name already exists' };
574 if ( ref ( $cgiparams { 'FH' }) ne 'Fh' ) {
575 $errormessage = $Lang :: tr
{ 'there was no file upload' };
578 # Move uploaded ca to a temporary file
579 ( my $fh , my $filename ) = tempfile
( );
580 if ( copy
( $cgiparams { 'FH' }, $fh ) != 1 ) {
584 my $temp = `/usr/bin/openssl x509 -text -in $filename ` ;
585 if ( $temp !~ /CA:TRUE/i ) {
586 $errormessage = $Lang :: tr
{ 'not a valid ca certificate' };
590 move
( $filename , "${General::swroot}/ca/ $cgiparams {'CA_NAME'}cert.pem" );
592 $errormessage = " $Lang ::tr{'certificate file move failed'}: $!" ;
598 my $key = & General
:: findhasharraykey
( \
%cahash );
599 $cahash { $key }[ 0 ] = $cgiparams { 'CA_NAME' };
600 $cahash { $key }[ 1 ] = & Header
:: cleanhtml
( getsubjectfromcert
( "${General::swroot}/ca/ $cgiparams {'CA_NAME'}cert.pem" ));
601 & General
:: writehasharray
( "${General::swroot}/vpn/caconfig" , \
%cahash );
602 system ( '/usr/local/bin/ipsecctrl' , 'R' );
608 ### Display ca certificate
610 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'show ca certificate' }) {
611 & General
:: readhasharray
( "${General::swroot}/vpn/caconfig" , \
%cahash );
613 if ( - f
"${General::swroot}/ca/ $cahash { $cgiparams {'KEY'}}[0]cert.pem" ) {
614 & Header
:: showhttpheaders
();
615 & Header
:: openpage
( $Lang :: tr
{ 'vpn configuration main' }, 1 , '' );
616 & Header
:: openbigbox
( '100%' , 'left' , '' , '' );
617 & Header
:: openbox
( '100%' , 'left' , " $Lang ::tr{'ca certificate'}:" );
618 my $output = `/usr/bin/openssl x509 -text -in ${General::swroot}/ca/ $cahash { $cgiparams {'KEY'}}[0]cert.pem` ;
619 $output = & Header
:: cleanhtml
( $output , "y" );
620 print "<pre> $output </pre> \n " ;
622 print "<div align='center'><a href='/cgi-bin/vpnmain.cgi'> $Lang ::tr{'back'}</a></div>" ;
623 & Header
:: closebigbox
();
624 & Header
:: closepage
();
627 $errormessage = $Lang :: tr
{ 'invalid key' };
631 ### Export ca certificate to browser
633 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'download ca certificate' }) {
634 & General
:: readhasharray
( "${General::swroot}/vpn/caconfig" , \
%cahash );
636 if ( - f
"${General::swroot}/ca/ $cahash { $cgiparams {'KEY'}}[0]cert.pem" ) {
637 print "Content-Type: application/force-download \n " ;
638 print "Content-Type: application/octet-stream \r\n " ;
639 print "Content-Disposition: attachment; filename= $cahash { $cgiparams {'KEY'}}[0]cert.pem \r\n\r\n " ;
640 print `/usr/bin/openssl x509 -in ${General::swroot}/ca/ $cahash { $cgiparams {'KEY'}}[0]cert.pem` ;
643 $errormessage = $Lang :: tr
{ 'invalid key' };
647 ### Remove ca certificate (step 2)
649 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'remove ca certificate' } && $cgiparams { 'AREUSURE' } eq 'yes' ) {
650 & General
:: readhasharray
( "${General::swroot}/vpn/config" , \
%confighash );
651 & General
:: readhasharray
( "${General::swroot}/vpn/caconfig" , \
%cahash );
653 if ( - f
"${General::swroot}/ca/ $cahash { $cgiparams {'KEY'}}[0]cert.pem" ) {
654 foreach my $key ( keys %confighash ) {
655 my $test = `/usr/bin/openssl verify -CAfile ${General::swroot}/ca/ $cahash { $cgiparams {'KEY'}}[0]cert.pem ${General::swroot}/certs/ $confighash { $key }[1]cert.pem` ;
656 if ( $test =~ /: OK/ ) {
658 system ( '/usr/local/bin/ipsecctrl' , 'D' , $key ) if (& vpnenabled
);
659 unlink ( "${General::swroot}/certs/ $confighash { $key }[1]cert.pem" );
660 unlink ( "${General::swroot}/certs/ $confighash { $key }[1].p12" );
661 delete $confighash { $key };
662 & General
:: writehasharray
( "${General::swroot}/vpn/config" , \
%confighash );
666 unlink ( "${General::swroot}/ca/ $cahash { $cgiparams {'KEY'}}[0]cert.pem" );
667 delete $cahash { $cgiparams { 'KEY' }};
668 & General
:: writehasharray
( "${General::swroot}/vpn/caconfig" , \
%cahash );
669 system ( '/usr/local/bin/ipsecctrl' , 'R' );
672 $errormessage = $Lang :: tr
{ 'invalid key' };
675 ### Remove ca certificate (step 1)
677 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'remove ca certificate' }) {
678 & General
:: readhasharray
( "${General::swroot}/vpn/config" , \
%confighash );
679 & General
:: readhasharray
( "${General::swroot}/vpn/caconfig" , \
%cahash );
681 my $assignedcerts = 0 ;
682 if ( - f
"${General::swroot}/ca/ $cahash { $cgiparams {'KEY'}}[0]cert.pem" ) {
683 foreach my $key ( keys %confighash ) {
684 my $test = `/usr/bin/openssl verify -CAfile ${General::swroot}/ca/ $cahash { $cgiparams {'KEY'}}[0]cert.pem ${General::swroot}/certs/ $confighash { $key }[1]cert.pem` ;
685 if ( $test =~ /: OK/ ) {
689 if ( $assignedcerts ) {
690 & Header
:: showhttpheaders
();
691 & Header
:: openpage
( $Lang :: tr
{ 'vpn configuration main' }, 1 , '' );
692 & Header
:: openbigbox
( '100%' , 'left' , '' , '' );
693 & Header
:: openbox
( '100%' , 'left' , $Lang :: tr
{ 'are you sure' });
695 <form method='post' action=' $ENV {'SCRIPT_NAME'}'>
699 <input type='hidden' name='KEY' value=' $cgiparams {'KEY'}' />
700 <input type='hidden' name='AREUSURE' value='yes' /></td>
703 <b><font color='${Header::colourred}'> $Lang ::tr{'capswarning'}</font></b>
704 $Lang ::tr{'connections are associated with this ca. deleting the ca will delete these connections as well.'}</td>
707 <input type='submit' name='ACTION' value=' $Lang ::tr{'remove ca certificate'}' />
708 <input type='submit' name='ACTION' value=' $Lang ::tr{'cancel'}' /></td>
715 & Header
:: closebigbox
();
716 & Header
:: closepage
();
719 unlink ( "${General::swroot}/ca/ $cahash { $cgiparams {'KEY'}}[0]cert.pem" );
720 delete $cahash { $cgiparams { 'KEY' }};
721 & General
:: writehasharray
( "${General::swroot}/vpn/caconfig" , \
%cahash );
722 system ( '/usr/local/bin/ipsecctrl' , 'R' );
726 $errormessage = $Lang :: tr
{ 'invalid key' };
730 ### Display root certificate
732 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'show root certificate' } ||
733 $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'show host certificate' }) {
735 & Header
:: showhttpheaders
();
736 & Header
:: openpage
( $Lang :: tr
{ 'vpn configuration main' }, 1 , '' );
737 & Header
:: openbigbox
( '100%' , 'left' , '' , '' );
738 if ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'show root certificate' }) {
739 & Header
:: openbox
( '100%' , 'left' , " $Lang ::tr{'root certificate'}:" );
740 $output = `/usr/bin/openssl x509 -text -in ${General::swroot}/ca/cacert.pem` ;
742 & Header
:: openbox
( '100%' , 'left' , " $Lang ::tr{'host certificate'}:" );
743 $output = `/usr/bin/openssl x509 -text -in ${General::swroot}/certs/hostcert.pem` ;
745 $output = & Header
:: cleanhtml
( $output , "y" );
746 print "<pre> $output </pre> \n " ;
748 print "<div align='center'><a href='/cgi-bin/vpnmain.cgi'> $Lang ::tr{'back'}</a></div>" ;
749 & Header
:: closebigbox
();
750 & Header
:: closepage
();
754 ### Export root certificate to browser
756 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'download root certificate' }) {
757 if ( - f
"${General::swroot}/ca/cacert.pem" ) {
758 print "Content-Type: application/force-download \n " ;
759 print "Content-Disposition: attachment; filename=cacert.pem \r\n\r\n " ;
760 print `/usr/bin/openssl x509 -in ${General::swroot}/ca/cacert.pem` ;
764 ### Export host certificate to browser
766 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'download host certificate' }) {
767 if ( - f
"${General::swroot}/certs/hostcert.pem" ) {
768 print "Content-Type: application/force-download \n " ;
769 print "Content-Disposition: attachment; filename=hostcert.pem \r\n\r\n " ;
770 print `/usr/bin/openssl x509 -in ${General::swroot}/certs/hostcert.pem` ;
774 ### Form for generating/importing the caroot+host certificate
776 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'generate root/host certificates' } ||
777 $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'upload p12 file' }) {
779 if (- f
"${General::swroot}/ca/cacert.pem" ) {
780 $errormessage = $Lang :: tr
{ 'valid root certificate already exists' };
784 & General
:: readhash
( "${General::swroot}/vpn/settings" , \
%vpnsettings );
785 # fill in initial values
786 if ( $cgiparams { 'ROOTCERT_HOSTNAME' } eq '' ) {
787 if (- e
"${General::swroot}/red/active" && open ( IPADDR
, "${General::swroot}/red/local-ipaddress" )) {
788 my $ipaddr = < IPADDR
>;
791 $cgiparams { 'ROOTCERT_HOSTNAME' } = ( gethostbyaddr ( pack ( "C4" , split ( /\./ , $ipaddr )), 2 ))[ 0 ];
792 if ( $cgiparams { 'ROOTCERT_HOSTNAME' } eq '' ) {
793 $cgiparams { 'ROOTCERT_HOSTNAME' } = $ipaddr ;
796 $cgiparams { 'ROOTCERT_COUNTRY' } = $vpnsettings { 'ROOTCERT_COUNTRY' } if (! $cgiparams { 'ROOTCERT_COUNTRY' });
797 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'upload p12 file' }) {
798 & General
:: log ( "ipsec" , "Importing from p12..." );
800 if ( ref ( $cgiparams { 'FH' }) ne 'Fh' ) {
801 $errormessage = $Lang :: tr
{ 'there was no file upload' };
805 # Move uploaded certificate request to a temporary file
806 ( my $fh , my $filename ) = tempfile
( );
807 if ( copy
( $cgiparams { 'FH' }, $fh ) != 1 ) {
812 # Extract the CA certificate from the file
813 & General
:: log ( "ipsec" , "Extracting caroot from p12..." );
814 if ( open ( STDIN
, "-|" )) {
815 my $opt = " pkcs12 -cacerts -nokeys" ;
816 $opt .= " -in $filename " ;
817 $opt .= " -out /tmp/newcacert" ;
818 $errormessage = & callssl
( $opt );
820 print " $cgiparams {'P12_PASS'} \n " ;
824 # Extract the Host certificate from the file
825 if (! $errormessage ) {
826 & General
:: log ( "ipsec" , "Extracting host cert from p12..." );
827 if ( open ( STDIN
, "-|" )) {
828 my $opt = " pkcs12 -clcerts -nokeys" ;
829 $opt .= " -in $filename " ;
830 $opt .= " -out /tmp/newhostcert" ;
831 $errormessage = & callssl
( $opt );
833 print " $cgiparams {'P12_PASS'} \n " ;
838 # Extract the Host key from the file
839 if (! $errormessage ) {
840 & General
:: log ( "ipsec" , "Extracting private key from p12..." );
841 if ( open ( STDIN
, "-|" )) {
842 my $opt = " pkcs12 -nocerts -nodes" ;
843 $opt .= " -in $filename " ;
844 $opt .= " -out /tmp/newhostkey" ;
845 $errormessage = & callssl
( $opt );
847 print " $cgiparams {'P12_PASS'} \n " ;
852 if (! $errormessage ) {
853 & General
:: log ( "ipsec" , "Moving cacert..." );
854 move
( "/tmp/newcacert" , "${General::swroot}/ca/cacert.pem" );
855 $errormessage = " $Lang ::tr{'certificate file move failed'}: $!" if ($ ?
ne 0 );
858 if (! $errormessage ) {
859 & General
:: log ( "ipsec" , "Moving host cert..." );
860 move
( "/tmp/newhostcert" , "${General::swroot}/certs/hostcert.pem" );
861 $errormessage = " $Lang ::tr{'certificate file move failed'}: $!" if ($ ?
ne 0 );
864 if (! $errormessage ) {
865 & General
:: log ( "ipsec" , "Moving private key..." );
866 move
( "/tmp/newhostkey" , "${General::swroot}/certs/hostkey.pem" );
867 $errormessage = " $Lang ::tr{'certificate file move failed'}: $!" if ($ ?
ne 0 );
872 unlink ( '/tmp/newcacert' );
873 unlink ( '/tmp/newhostcert' );
874 unlink ( '/tmp/newhostkey' );
876 unlink ( "${General::swroot}/ca/cacert.pem" );
877 unlink ( "${General::swroot}/certs/hostcert.pem" );
878 unlink ( "${General::swroot}/certs/hostkey.pem" );
882 # Create empty CRL cannot be done because we don't have
883 # the private key for this CAROOT
884 # Ipcop can only import certificates
886 & General
:: log ( "ipsec" , "p12 import completed!" );
888 goto ROOTCERT_SUCCESS
;
890 } elsif ( $cgiparams { 'ROOTCERT_COUNTRY' } ne '' ) {
892 # Validate input since the form was submitted
893 if ( $cgiparams { 'ROOTCERT_ORGANIZATION' } eq '' ){
894 $errormessage = $Lang :: tr
{ 'organization cant be empty' };
897 if ( length ( $cgiparams { 'ROOTCERT_ORGANIZATION' }) > 60 ) {
898 $errormessage = $Lang :: tr
{ 'organization too long' };
901 if ( $cgiparams { 'ROOTCERT_ORGANIZATION' } !~ /^[a-zA-Z0-9 ,\.\-_]*$/ ) {
902 $errormessage = $Lang :: tr
{ 'invalid input for organization' };
905 if ( $cgiparams { 'ROOTCERT_HOSTNAME' } eq '' ){
906 $errormessage = $Lang :: tr
{ 'hostname cant be empty' };
909 unless (& General
:: validfqdn
( $cgiparams { 'ROOTCERT_HOSTNAME' }) || & General
:: validip
( $cgiparams { 'ROOTCERT_HOSTNAME' })) {
910 $errormessage = $Lang :: tr
{ 'invalid input for hostname' };
913 if ( $cgiparams { 'ROOTCERT_EMAIL' } ne '' && (! & General
:: validemail
( $cgiparams { 'ROOTCERT_EMAIL' }))) {
914 $errormessage = $Lang :: tr
{ 'invalid input for e-mail address' };
917 if ( length ( $cgiparams { 'ROOTCERT_EMAIL' }) > 40 ) {
918 $errormessage = $Lang :: tr
{ 'e-mail address too long' };
921 if ( $cgiparams { 'ROOTCERT_OU' } ne '' && $cgiparams { 'ROOTCERT_OU' } !~ /^[a-zA-Z0-9 ,\.\-_]*$/ ) {
922 $errormessage = $Lang :: tr
{ 'invalid input for department' };
925 if ( $cgiparams { 'ROOTCERT_CITY' } ne '' && $cgiparams { 'ROOTCERT_CITY' } !~ /^[a-zA-Z0-9 ,\.\-_]*$/ ) {
926 $errormessage = $Lang :: tr
{ 'invalid input for city' };
929 if ( $cgiparams { 'ROOTCERT_STATE' } ne '' && $cgiparams { 'ROOTCERT_STATE' } !~ /^[a-zA-Z0-9 ,\.\-_]*$/ ) {
930 $errormessage = $Lang :: tr
{ 'invalid input for state or province' };
933 if ( $cgiparams { 'ROOTCERT_COUNTRY' } !~ /^[A-Z]*$/ ) {
934 $errormessage = $Lang :: tr
{ 'invalid input for country' };
937 #the exact syntax is a list comma separated of
938 # email:any-validemail
939 # URI: a uniform resource indicator
940 # DNS: a DNS domain name
941 # RID: a registered OBJECT IDENTIFIER
943 # example: email:franck@foo.com,IP:10.0.0.10,DNS:franck.foo.com
945 if ( $cgiparams { 'SUBJECTALTNAME' } ne '' && $cgiparams { 'SUBJECTALTNAME' } !~ /^(email|URI|DNS|RID|IP):[a-zA-Z0-9 :\/ , \
. \
- _@
]*$/) {
946 $errormessage = $Lang :: tr
{ 'vpn altname syntax' };
950 # Copy the cgisettings to vpnsettings and save the configfile
951 $vpnsettings { 'ROOTCERT_ORGANIZATION' } = $cgiparams { 'ROOTCERT_ORGANIZATION' };
952 $vpnsettings { 'ROOTCERT_HOSTNAME' } = $cgiparams { 'ROOTCERT_HOSTNAME' };
953 $vpnsettings { 'ROOTCERT_EMAIL' } = $cgiparams { 'ROOTCERT_EMAIL' };
954 $vpnsettings { 'ROOTCERT_OU' } = $cgiparams { 'ROOTCERT_OU' };
955 $vpnsettings { 'ROOTCERT_CITY' } = $cgiparams { 'ROOTCERT_CITY' };
956 $vpnsettings { 'ROOTCERT_STATE' } = $cgiparams { 'ROOTCERT_STATE' };
957 $vpnsettings { 'ROOTCERT_COUNTRY' } = $cgiparams { 'ROOTCERT_COUNTRY' };
958 & General
:: writehash
( "${General::swroot}/vpn/settings" , \
%vpnsettings );
960 # Replace empty strings with a .
961 ( my $ou = $cgiparams { 'ROOTCERT_OU' }) =~ s/^\s*$/\./ ;
962 ( my $city = $cgiparams { 'ROOTCERT_CITY' }) =~ s/^\s*$/\./ ;
963 ( my $state = $cgiparams { 'ROOTCERT_STATE' }) =~ s/^\s*$/\./ ;
965 # Create the CA certificate
966 if (! $errormessage ) {
967 & General
:: log ( "ipsec" , "Creating cacert..." );
968 if ( open ( STDIN
, "-|" )) {
969 my $opt = " req -x509 -nodes -rand /proc/interrupts:/proc/net/rt_cache" ;
970 $opt .= " -days 999999" ;
971 $opt .= " -newkey rsa:2048" ;
972 $opt .= " -keyout ${General::swroot}/private/cakey.pem" ;
973 $opt .= " -out ${General::swroot}/ca/cacert.pem" ;
975 $errormessage = & callssl
( $opt );
977 print " $cgiparams {'ROOTCERT_COUNTRY'} \n " ;
980 print " $cgiparams {'ROOTCERT_ORGANIZATION'} \n " ;
982 print " $cgiparams {'ROOTCERT_ORGANIZATION'} CA \n " ;
983 print " $cgiparams {'ROOTCERT_EMAIL'} \n " ;
988 # Create the Host certificate request
989 if (! $errormessage ) {
990 & General
:: log ( "ipsec" , "Creating host cert..." );
991 if ( open ( STDIN
, "-|" )) {
992 my $opt = " req -nodes -rand /proc/interrupts:/proc/net/rt_cache" ;
993 $opt .= " -newkey rsa:1024" ;
994 $opt .= " -keyout ${General::swroot}/certs/hostkey.pem" ;
995 $opt .= " -out ${General::swroot}/certs/hostreq.pem" ;
996 $errormessage = & callssl
( $opt );
998 print " $cgiparams {'ROOTCERT_COUNTRY'} \n " ;
1001 print " $cgiparams {'ROOTCERT_ORGANIZATION'} \n " ;
1003 print " $cgiparams {'ROOTCERT_HOSTNAME'} \n " ;
1004 print " $cgiparams {'ROOTCERT_EMAIL'} \n " ;
1011 # Sign the host certificate request
1012 if (! $errormessage ) {
1013 & General
:: log ( "ipsec" , "Self signing host cert..." );
1015 #No easy way for specifying the contain of subjectAltName without writing a config file...
1016 my ( $fh , $v3extname ) = tempfile
( '/tmp/XXXXXXXX' );
1018 basicConstraints=CA:FALSE
1019 nsComment="OpenSSL Generated Certificate"
1020 subjectKeyIdentifier=hash
1021 authorityKeyIdentifier=keyid,issuer:always
1024 print $fh "subjectAltName= $cgiparams {'SUBJECTALTNAME'}" if ( $cgiparams { 'SUBJECTALTNAME' });
1027 my $opt = " ca -days 999999" ;
1028 $opt .= " -batch -notext" ;
1029 $opt .= " -in ${General::swroot}/certs/hostreq.pem" ;
1030 $opt .= " -out ${General::swroot}/certs/hostcert.pem" ;
1031 $opt .= " -extfile $v3extname " ;
1032 $errormessage = & callssl
( $opt );
1033 unlink ( "${General::swroot}/certs/hostreq.pem" ); #no more needed
1034 unlink ( $v3extname );
1037 # Create an empty CRL
1038 if (! $errormessage ) {
1039 & General
:: log ( "ipsec" , "Creating emptycrl..." );
1040 my $opt = " ca -gencrl" ;
1041 $opt .= " -out ${General::swroot}/crls/cacrl.pem" ;
1042 $errormessage = & callssl
( $opt );
1045 # Successfully build CA / CERT!
1046 if (! $errormessage ) {
1047 & cleanssldatabase
();
1048 goto ROOTCERT_SUCCESS
;
1052 unlink ( "${General::swroot}/ca/cacert.pem" );
1053 unlink ( "${General::swroot}/certs/hostkey.pem" );
1054 unlink ( "${General::swroot}/certs/hostcert.pem" );
1055 unlink ( "${General::swroot}/crls/cacrl.pem" );
1056 & cleanssldatabase
();
1060 & Header
:: showhttpheaders
();
1061 & Header
:: openpage
( $Lang :: tr
{ 'vpn configuration main' }, 1 , '' );
1062 & Header
:: openbigbox
( '100%' , 'left' , '' , $errormessage );
1063 if ( $errormessage ) {
1064 & Header
:: openbox
( '100%' , 'left' , $Lang :: tr
{ 'error messages' });
1065 print "<class name='base'> $errormessage " ;
1066 print " </class>" ;
1067 & Header
:: closebox
();
1069 & Header
:: openbox
( '100%' , 'left' , " $Lang ::tr{'generate root/host certificates'}:" );
1071 <form method='post' enctype='multipart/form-data' action=' $ENV {'SCRIPT_NAME'}'>
1072 <table width='100%' border='0' cellspacing='1' cellpadding='0'>
1073 <tr><td width='40%' class='base'> $Lang ::tr{'organization name'}:</td>
1074 <td width='60%' class='base' nowrap='nowrap'><input type='text' name='ROOTCERT_ORGANIZATION' value=' $cgiparams {'ROOTCERT_ORGANIZATION'}' size='32' /></td></tr>
1075 <tr><td class='base'> $Lang ::tr{'ipcops hostname'}:</td>
1076 <td class='base' nowrap='nowrap'><input type='text' name='ROOTCERT_HOSTNAME' value=' $cgiparams {'ROOTCERT_HOSTNAME'}' size='32' /></td></tr>
1077 <tr><td class='base'> $Lang ::tr{'your e-mail'}: <img src='/blob.gif' alt='*' /></td>
1078 <td class='base' nowrap='nowrap'><input type='text' name='ROOTCERT_EMAIL' value=' $cgiparams {'ROOTCERT_EMAIL'}' size='32' /></td></tr>
1079 <tr><td class='base'> $Lang ::tr{'your department'}: <img src='/blob.gif' alt='*' /></td>
1080 <td class='base' nowrap='nowrap'><input type='text' name='ROOTCERT_OU' value=' $cgiparams {'ROOTCERT_OU'}' size='32' /></td></tr>
1081 <tr><td class='base'> $Lang ::tr{'city'}: <img src='/blob.gif' alt='*' /></td>
1082 <td class='base' nowrap='nowrap'><input type='text' name='ROOTCERT_CITY' value=' $cgiparams {'ROOTCERT_CITY'}' size='32' /></td></tr>
1083 <tr><td class='base'> $Lang ::tr{'state or province'}: <img src='/blob.gif' alt='*' /></td>
1084 <td class='base' nowrap='nowrap'><input type='text' name='ROOTCERT_STATE' value=' $cgiparams {'ROOTCERT_STATE'}' size='32' /></td></tr>
1085 <tr><td class='base'> $Lang ::tr{'country'}:</td>
1086 <td class='base'><select name='ROOTCERT_COUNTRY'>
1089 foreach my $country ( sort keys %{ Countries
:: countries
}) {
1090 print "<option value=' $Countries ::countries{ $country }'" ;
1091 if ( $Countries :: countries
{ $country } eq $cgiparams { 'ROOTCERT_COUNTRY' } ) {
1092 print " selected='selected'" ;
1094 print "> $country </option>" ;
1098 <tr><td class='base'> $Lang ::tr{'vpn subjectaltname'} (subjectAltName=email:*,URI:*,DNS:*,RID:*) <img src='/blob.gif' alt='*' /></td>
1099 <td class='base' nowrap='nowrap'><input type='text' name='SUBJECTALTNAME' value=' $cgiparams {'SUBJECTALTNAME'}' size='32' /></td></tr>
1101 <td><br /><input type='submit' name='ACTION' value=' $Lang ::tr{'generate root/host certificates'}' /><br /><br /></td></tr>
1102 <tr><td class='base' colspan='2' align='left'>
1103 <b><font color='${Header::colourred}'> $Lang ::tr{'capswarning'}</font></b>:
1104 $Lang ::tr{'generating the root and host certificates may take a long time. it can take up to several minutes on older hardware. please be patient'}
1106 <tr><td colspan='2'><hr /></td></tr>
1107 <tr><td class='base' nowrap='nowrap'> $Lang ::tr{'upload p12 file'}:</td>
1108 <td nowrap='nowrap'><input type='file' name='FH' size='32' /></td></tr>
1109 <tr><td class='base'> $Lang ::tr{'pkcs12 file password'}: <img src='/blob.gif' alt='*' /></td>
1110 <td class='base' nowrap='nowrap'><input type='password' name='P12_PASS' value=' $cgiparams {'P12_PASS'}' size='32' /></td></tr>
1112 <td><input type='submit' name='ACTION' value=' $Lang ::tr{'upload p12 file'}' /></td></tr>
1113 <tr><td class='base' colspan='2' align='left'>
1114 <img src='/blob.gif' alt='*' /> $Lang ::tr{'this field may be blank'}</td></tr>
1118 & Header
:: closebox
();
1119 & Header
:: closebigbox
();
1120 & Header
:: closepage
();
1125 system ( '/usr/local/bin/ipsecctrl' , 'S' );
1130 ### Export PKCS12 file to browser
1132 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'download pkcs12 file' }) {
1133 & General
:: readhasharray
( "${General::swroot}/vpn/config" , \
%confighash );
1134 print "Content-Type: application/force-download \n " ;
1135 print "Content-Disposition: attachment; filename=" . $confighash { $cgiparams { 'KEY' }}[ 1 ] . ".p12 \r\n " ;
1136 print "Content-Type: application/octet-stream \r\n\r\n " ;
1137 print `/bin/cat ${General::swroot}/certs/ $confighash { $cgiparams {'KEY'}}[1].p12` ;
1141 ### Display certificate
1143 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'show certificate' }) {
1144 & General
:: readhasharray
( "${General::swroot}/vpn/config" , \
%confighash );
1146 if ( - f
"${General::swroot}/certs/ $confighash { $cgiparams {'KEY'}}[1]cert.pem" ) {
1147 & Header
:: showhttpheaders
();
1148 & Header
:: openpage
( $Lang :: tr
{ 'vpn configuration main' }, 1 , '' );
1149 & Header
:: openbigbox
( '100%' , 'left' , '' , '' );
1150 & Header
:: openbox
( '100%' , 'left' , " $Lang ::tr{'cert'}:" );
1151 my $output = `/usr/bin/openssl x509 -text -in ${General::swroot}/certs/ $confighash { $cgiparams {'KEY'}}[1]cert.pem` ;
1152 $output = & Header
:: cleanhtml
( $output , "y" );
1153 print "<pre> $output </pre> \n " ;
1154 & Header
:: closebox
();
1155 print "<div align='center'><a href='/cgi-bin/vpnmain.cgi'> $Lang ::tr{'back'}</a></div>" ;
1156 & Header
:: closebigbox
();
1157 & Header
:: closepage
();
1162 ### Export Certificate to browser
1164 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'download certificate' }) {
1165 & General
:: readhasharray
( "${General::swroot}/vpn/config" , \
%confighash );
1167 if ( - f
"${General::swroot}/certs/ $confighash { $cgiparams {'KEY'}}[1]cert.pem" ) {
1168 print "Content-Type: application/force-download \n " ;
1169 print "Content-Disposition: attachment; filename=" . $confighash { $cgiparams { 'KEY' }}[ 1 ] . "cert.pem \n\n " ;
1170 print `/bin/cat ${General::swroot}/certs/ $confighash { $cgiparams {'KEY'}}[1]cert.pem` ;
1175 ### Enable/Disable connection
1177 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'toggle enable disable' }) {
1179 & General
:: readhash
( "${General::swroot}/vpn/settings" , \
%vpnsettings );
1180 & General
:: readhasharray
( "${General::swroot}/vpn/config" , \
%confighash );
1182 if ( $confighash { $cgiparams { 'KEY' }}) {
1183 if ( $confighash { $cgiparams { 'KEY' }}[ 0 ] eq 'off' ) {
1184 $confighash { $cgiparams { 'KEY' }}[ 0 ] = 'on' ;
1185 & General
:: writehasharray
( "${General::swroot}/vpn/config" , \
%confighash );
1187 system ( '/usr/local/bin/ipsecctrl' , 'S' , $cgiparams { 'KEY' }) if (& vpnenabled
);
1189 $confighash { $cgiparams { 'KEY' }}[ 0 ] = 'off' ;
1190 & General
:: writehasharray
( "${General::swroot}/vpn/config" , \
%confighash );
1192 system ( '/usr/local/bin/ipsecctrl' , 'D' , $cgiparams { 'KEY' }) if (& vpnenabled
);
1196 $errormessage = $Lang :: tr
{ 'invalid key' };
1200 ### Restart connection
1202 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'restart' }) {
1203 & General
:: readhash
( "${General::swroot}/vpn/settings" , \
%vpnsettings );
1204 & General
:: readhasharray
( "${General::swroot}/vpn/config" , \
%confighash );
1206 if ( $confighash { $cgiparams { 'KEY' }}) {
1208 system ( '/usr/local/bin/ipsecctrl' , 'S' , $cgiparams { 'KEY' });
1212 $errormessage = $Lang :: tr
{ 'invalid key' };
1216 ### Remove connection
1218 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'remove' }) {
1219 & General
:: readhash
( "${General::swroot}/vpn/settings" , \
%vpnsettings );
1220 & General
:: readhasharray
( "${General::swroot}/vpn/config" , \
%confighash );
1222 if ( $confighash { $cgiparams { 'KEY' }}) {
1223 system ( '/usr/local/bin/ipsecctrl' , 'D' , $cgiparams { 'KEY' }) if (& vpnenabled
);
1224 unlink ( "${General::swroot}/certs/ $confighash { $cgiparams {'KEY'}}[1]cert.pem" );
1225 unlink ( "${General::swroot}/certs/ $confighash { $cgiparams {'KEY'}}[1].p12" );
1226 delete $confighash { $cgiparams { 'KEY' }};
1227 & General
:: writehasharray
( "${General::swroot}/vpn/config" , \
%confighash );
1230 $errormessage = $Lang :: tr
{ 'invalid key' };
1234 ### Choose between adding a host-net or net-net connection
1236 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'add' } && $cgiparams { 'TYPE' } eq '' ) {
1237 & Header
:: showhttpheaders
();
1238 & Header
:: openpage
( $Lang :: tr
{ 'vpn configuration main' }, 1 , '' );
1239 & Header
:: openbigbox
( '100%' , 'left' , '' , '' );
1240 & Header
:: openbox
( '100%' , 'left' , $Lang :: tr
{ 'connection type' });
1242 <form method='post' action=' $ENV {'SCRIPT_NAME'}'>
1243 <b> $Lang ::tr{'connection type'}:</b><br />
1245 <tr><td><input type='radio' name='TYPE' value='host' checked='checked' /></td>
1246 <td class='base'> $Lang ::tr{'host to net vpn'}</td>
1248 <td><input type='radio' name='TYPE' value='net' /></td>
1249 <td class='base'> $Lang ::tr{'net to net vpn'}</td>
1251 <td align='center' colspan='2'><input type='submit' name='ACTION' value=' $Lang ::tr{'add'}' /></td>
1256 & Header
:: closebox
();
1257 & Header
:: closebigbox
();
1258 & Header
:: closepage
();
1261 ### Adding/Editing/Saving a connection
1263 } elsif (( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'add' }) ||
1264 ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'edit' }) ||
1265 ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'save' } && $cgiparams { 'ADVANCED' } eq '' )) {
1267 & General
:: readhash
( "${General::swroot}/vpn/settings" , \
%vpnsettings );
1268 & General
:: readhasharray
( "${General::swroot}/vpn/caconfig" , \
%cahash );
1269 & General
:: readhasharray
( "${General::swroot}/vpn/config" , \
%confighash );
1271 if ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'edit' }) {
1272 if (! $confighash { $cgiparams { 'KEY' }}[ 0 ]) {
1273 $errormessage = $Lang :: tr
{ 'invalid key' };
1276 $cgiparams { 'ENABLED' } = $confighash { $cgiparams { 'KEY' }}[ 0 ];
1277 $cgiparams { 'NAME' } = $confighash { $cgiparams { 'KEY' }}[ 1 ];
1278 $cgiparams { 'TYPE' } = $confighash { $cgiparams { 'KEY' }}[ 3 ];
1279 $cgiparams { 'AUTH' } = $confighash { $cgiparams { 'KEY' }}[ 4 ];
1280 $cgiparams { 'PSK' } = $confighash { $cgiparams { 'KEY' }}[ 5 ];
1281 $cgiparams { 'SIDE' } = $confighash { $cgiparams { 'KEY' }}[ 6 ];
1282 $cgiparams { 'LOCAL_ID' } = $confighash { $cgiparams { 'KEY' }}[ 7 ];
1283 $cgiparams { 'LOCAL_SUBNET' } = $confighash { $cgiparams { 'KEY' }}[ 8 ];
1284 $cgiparams { 'REMOTE_ID' } = $confighash { $cgiparams { 'KEY' }}[ 9 ];
1285 $cgiparams { 'REMOTE' } = $confighash { $cgiparams { 'KEY' }}[ 10 ];
1286 $cgiparams { 'REMOTE_SUBNET' } = $confighash { $cgiparams { 'KEY' }}[ 11 ];
1287 $cgiparams { 'REMARK' } = $confighash { $cgiparams { 'KEY' }}[ 25 ];
1288 $cgiparams { 'INTERFACE' } = $confighash { $cgiparams { 'KEY' }}[ 26 ];
1289 $cgiparams { 'DPD_ACTION' } = $confighash { $cgiparams { 'KEY' }}[ 27 ];
1290 $cgiparams { 'IKE_ENCRYPTION' } = $confighash { $cgiparams { 'KEY' }}[ 18 ];
1291 $cgiparams { 'IKE_INTEGRITY' } = $confighash { $cgiparams { 'KEY' }}[ 19 ];
1292 $cgiparams { 'IKE_GROUPTYPE' } = $confighash { $cgiparams { 'KEY' }}[ 20 ];
1293 $cgiparams { 'IKE_LIFETIME' } = $confighash { $cgiparams { 'KEY' }}[ 16 ];
1294 $cgiparams { 'ESP_ENCRYPTION' } = $confighash { $cgiparams { 'KEY' }}[ 21 ];
1295 $cgiparams { 'ESP_INTEGRITY' } = $confighash { $cgiparams { 'KEY' }}[ 22 ];
1296 $cgiparams { 'ESP_GROUPTYPE' } = $confighash { $cgiparams { 'KEY' }}[ 23 ];
1297 $cgiparams { 'ESP_KEYLIFE' } = $confighash { $cgiparams { 'KEY' }}[ 17 ];
1298 $cgiparams { 'AGGRMODE' } = $confighash { $cgiparams { 'KEY' }}[ 12 ];
1299 $cgiparams { 'COMPRESSION' } = $confighash { $cgiparams { 'KEY' }}[ 13 ];
1300 $cgiparams { 'ONLY_PROPOSED' } = $confighash { $cgiparams { 'KEY' }}[ 24 ];
1301 $cgiparams { 'PFS' } = $confighash { $cgiparams { 'KEY' }}[ 28 ];
1302 $cgiparams { 'VHOST' } = $confighash { $cgiparams { 'KEY' }}[ 14 ];
1304 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'save' }) {
1305 $cgiparams { 'REMARK' } = & Header
:: cleanhtml
( $cgiparams { 'REMARK' });
1306 if ( $cgiparams { 'TYPE' } !~ /^(host|net)$/ ) {
1307 $errormessage = $Lang :: tr
{ 'connection type is invalid' };
1311 if ( $cgiparams { 'NAME' } !~ /^[a-zA-Z0-9]+$/ ) {
1312 $errormessage = $Lang :: tr
{ 'name must only contain characters' };
1316 if ( $cgiparams { 'NAME' } =~ /^(host|01|block|private|clear|packetdefault)$/ ) {
1317 $errormessage = $Lang :: tr
{ 'name is invalid' };
1321 if ( length ( $cgiparams { 'NAME' }) > 60 ) {
1322 $errormessage = $Lang :: tr
{ 'name too long' };
1326 if (( $cgiparams { 'TYPE' } eq 'net' ) && ( $cgiparams { 'SIDE' } !~ /^(left|right)$/ )) {
1327 $errormessage = $Lang :: tr
{ 'ipcop side is invalid' };
1331 # Check if there is no other entry with this name
1332 if (! $cgiparams { 'KEY' }) { #only for add
1333 foreach my $key ( keys %confighash ) {
1334 if ( $confighash { $key }[ 1 ] eq $cgiparams { 'NAME' }) {
1335 $errormessage = $Lang :: tr
{ 'a connection with this name already exists' };
1341 if (( $cgiparams { 'TYPE' } eq 'net' ) && (! $cgiparams { 'REMOTE' })) {
1342 $errormessage = $Lang :: tr
{ 'invalid input for remote host/ip' };
1346 if ( $cgiparams { 'REMOTE' }) {
1347 if (! & General
:: validip
( $cgiparams { 'REMOTE' })) {
1348 if (! & General
:: validfqdn
( $cgiparams { 'REMOTE' })) {
1349 $errormessage = $Lang :: tr
{ 'invalid input for remote host/ip' };
1352 if (& valid_dns_host
( $cgiparams { 'REMOTE' })) {
1353 $warnmessage = " $Lang ::tr{'check vpn lr'} $cgiparams {'REMOTE'}. $Lang ::tr{'dns check failed'}" ;
1359 unless (& General
:: validipandmask
( $cgiparams { 'LOCAL_SUBNET' })) {
1360 $errormessage = $Lang :: tr
{ 'local subnet is invalid' };
1364 # Allow only one roadwarrior/psk without remote IP-address
1365 if ( $cgiparams { 'REMOTE' } eq '' && $cgiparams { 'AUTH' } eq 'psk' ) {
1366 foreach my $key ( keys %confighash ) {
1367 if ( ( $cgiparams { 'KEY' } ne $key ) &&
1368 ( $confighash { $key }[ 4 ] eq 'psk' ) &&
1369 ( $confighash { $key }[ 10 ] eq '' ) ) {
1370 $errormessage = $Lang :: tr
{ 'you can only define one roadwarrior connection when using pre-shared key authentication' };
1375 if (( $cgiparams { 'TYPE' } eq 'net' ) && (! & General
:: validipandmask
( $cgiparams { 'REMOTE_SUBNET' }))) {
1376 $errormessage = $Lang :: tr
{ 'remote subnet is invalid' };
1380 if ( $cgiparams { 'ENABLED' } !~ /^(on|off)$/ ) {
1381 $errormessage = $Lang :: tr
{ 'invalid input' };
1384 if ( $cgiparams { 'EDIT_ADVANCED' } !~ /^(on|off)$/ ) {
1385 $errormessage = $Lang :: tr
{ 'invalid input' };
1389 # Allow nothing or a string (DN,FDQN,) beginning with @
1390 # with no comma but slashes between RID eg @O=FR/C=Paris/OU=myhome/CN=franck
1391 if ( ( $cgiparams { 'LOCAL_ID' } !~ /^(|[\w.-]*@[\w. =*\/ -]+| \d\
. \d\
. \d\
. \d
)$/) ||
1392 ( $cgiparams { 'REMOTE_ID' } !~ /^(|[\w.-]*@[\w. =*\/ -]+| \d\
. \d\
. \d\
. \d
)$/) ||
1393 (( $cgiparams { 'REMOTE_ID' } eq $cgiparams { 'LOCAL_ID' }) && ( $cgiparams { 'LOCAL_ID' } ne '' ))
1395 $errormessage = $Lang :: tr
{ 'invalid local-remote id' } . '<br />' .
1396 'DER_ASN1_DN: @c =FR/ou=Paris/ou=Home/cn=*<br />' .
1397 'FQDN: @ipcop .org<br />' .
1398 'USER_FQDN: franck @ipcop .org<br />' .
1399 'IPV4_ADDR: @123 .123.123.123' ;
1402 # If Auth is DN, verify existance of Remote ID.
1403 if ( $cgiparams { 'REMOTE_ID' } eq '' && (
1404 $cgiparams { 'AUTH' } eq 'auth-dn' || # while creation
1405 $confighash { $cgiparams { 'KEY' }}[ 2 ] eq ' %auth -dn' )){ # while editing
1406 $errormessage = $Lang :: tr
{ 'vpn missing remote id' };
1410 if ( $cgiparams { 'AUTH' } eq 'psk' ) {
1411 if (! length ( $cgiparams { 'PSK' }) ) {
1412 $errormessage = $Lang :: tr
{ 'pre-shared key is too short' };
1415 if ( $cgiparams { 'PSK' } =~ /'/ ) {
1416 $cgiparams { 'PSK' } =~ tr/'/ / ;
1417 $errormessage = $Lang :: tr
{ 'invalid characters found in pre-shared key' };
1420 } elsif ( $cgiparams { 'AUTH' } eq 'certreq' ) {
1421 if ( $cgiparams { 'KEY' }) {
1422 $errormessage = $Lang :: tr
{ 'cant change certificates' };
1425 if ( ref ( $cgiparams { 'FH' }) ne 'Fh' ) {
1426 $errormessage = $Lang :: tr
{ 'there was no file upload' };
1430 # Move uploaded certificate request to a temporary file
1431 ( my $fh , my $filename ) = tempfile
( );
1432 if ( copy
( $cgiparams { 'FH' }, $fh ) != 1 ) {
1437 # Sign the certificate request
1438 & General
:: log ( "ipsec" , "Signing your cert $cgiparams {'NAME'}..." );
1439 my $opt = " ca -days 999999" ;
1440 $opt .= " -batch -notext" ;
1441 $opt .= " -in $filename " ;
1442 $opt .= " -out ${General::swroot}/certs/ $cgiparams {'NAME'}cert.pem" ;
1444 if ( $errormessage = & callssl
( $opt ) ) {
1446 unlink ( "${General::swroot}/certs/ $cgiparams {'NAME'}cert.pem" );
1447 & cleanssldatabase
();
1451 & cleanssldatabase
();
1454 $cgiparams { 'CERT_NAME' } = getCNfromcert
( "${General::swroot}/certs/ $cgiparams {'NAME'}cert.pem" );
1455 if ( $cgiparams { 'CERT_NAME' } eq '' ) {
1456 $errormessage = $Lang :: tr
{ 'could not retrieve common name from certificate' };
1459 } elsif ( $cgiparams { 'AUTH' } eq 'pkcs12' ) {
1460 & General
:: log ( "ipsec" , "Importing from p12..." );
1462 if ( ref ( $cgiparams { 'FH' }) ne 'Fh' ) {
1463 $errormessage = $Lang :: tr
{ 'there was no file upload' };
1464 goto ROOTCERT_ERROR
;
1467 # Move uploaded certificate request to a temporary file
1468 ( my $fh , my $filename ) = tempfile
( );
1469 if ( copy
( $cgiparams { 'FH' }, $fh ) != 1 ) {
1471 goto ROOTCERT_ERROR
;
1474 # Extract the CA certificate from the file
1475 & General
:: log ( "ipsec" , "Extracting caroot from p12..." );
1476 if ( open ( STDIN
, "-|" )) {
1477 my $opt = " pkcs12 -cacerts -nokeys" ;
1478 $opt .= " -in $filename " ;
1479 $opt .= " -out /tmp/newcacert" ;
1480 $errormessage = & callssl
( $opt );
1482 print " $cgiparams {'P12_PASS'} \n " ;
1486 # Extract the Host certificate from the file
1487 if (! $errormessage ) {
1488 & General
:: log ( "ipsec" , "Extracting host cert from p12..." );
1489 if ( open ( STDIN
, "-|" )) {
1490 my $opt = " pkcs12 -clcerts -nokeys" ;
1491 $opt .= " -in $filename " ;
1492 $opt .= " -out /tmp/newhostcert" ;
1493 $errormessage = & callssl
( $opt );
1495 print " $cgiparams {'P12_PASS'} \n " ;
1500 if (! $errormessage ) {
1501 & General
:: log ( "ipsec" , "Moving cacert..." );
1502 #If CA have new subject, add it to our list of CA
1503 my $casubject = & Header
:: cleanhtml
( getsubjectfromcert
( '/tmp/newcacert' ));
1505 foreach my $x ( keys %cahash ) {
1506 $casubject = '' if ( $cahash { $x }[ 1 ] eq $casubject );
1507 unshift ( @names , $cahash { $x }[ 0 ]);
1509 if ( $casubject ) { # a new one!
1510 my $temp = `/usr/bin/openssl x509 -text -in /tmp/newcacert` ;
1511 if ( $temp !~ /CA:TRUE/i ) {
1512 $errormessage = $Lang :: tr
{ 'not a valid ca certificate' };
1514 #compute a name for it
1516 while ( grep ( /Imported-$idx/ , @names ) ) { $idx ++};
1517 $cgiparams { 'CA_NAME' }= "Imported- $idx " ;
1518 $cgiparams { 'CERT_NAME' }=& Header
:: cleanhtml
( getCNfromcert
( '/tmp/newhostcert' ));
1519 move
( "/tmp/newcacert" , "${General::swroot}/ca/ $cgiparams {'CA_NAME'}cert.pem" );
1520 $errormessage = " $Lang ::tr{'certificate file move failed'}: $!" if ($ ?
ne 0 );
1521 if (! $errormessage ) {
1522 my $key = & General
:: findhasharraykey
( \
%cahash );
1523 $cahash { $key }[ 0 ] = $cgiparams { 'CA_NAME' };
1524 $cahash { $key }[ 1 ] = $casubject ;
1525 & General
:: writehasharray
( "${General::swroot}/vpn/caconfig" , \
%cahash );
1526 system ( '/usr/local/bin/ipsecctrl' , 'R' );
1531 if (! $errormessage ) {
1532 & General
:: log ( "ipsec" , "Moving host cert..." );
1533 move
( "/tmp/newhostcert" , "${General::swroot}/certs/ $cgiparams {'NAME'}cert.pem" );
1534 $errormessage = " $Lang ::tr{'certificate file move failed'}: $!" if ($ ?
ne 0 );
1539 unlink ( '/tmp/newcacert' );
1540 unlink ( '/tmp/newhostcert' );
1541 if ( $errormessage ) {
1542 unlink ( "${General::swroot}/ca/ $cgiparams {'CA_NAME'}cert.pem" );
1543 unlink ( "${General::swroot}/certs/ $cgiparams {'NAME'}cert.pem" );
1546 & General
:: log ( "ipsec" , "p12 import completed!" );
1547 } elsif ( $cgiparams { 'AUTH' } eq 'certfile' ) {
1548 if ( $cgiparams { 'KEY' }) {
1549 $errormessage = $Lang :: tr
{ 'cant change certificates' };
1552 if ( ref ( $cgiparams { 'FH' }) ne 'Fh' ) {
1553 $errormessage = $Lang :: tr
{ 'there was no file upload' };
1556 # Move uploaded certificate to a temporary file
1557 ( my $fh , my $filename ) = tempfile
( );
1558 if ( copy
( $cgiparams { 'FH' }, $fh ) != 1 ) {
1563 # Verify the certificate has a valid CA and move it
1564 & General
:: log ( "ipsec" , "Validating imported cert against our known CA..." );
1565 my $validca = 1 ; #assume ok
1566 my $test = `/usr/bin/openssl verify -CAfile ${General::swroot}/ca/cacert.pem $filename ` ;
1567 if ( $test !~ /: OK/ ) {
1569 foreach my $key ( keys %cahash ) {
1570 $test = `/usr/bin/openssl verify -CAfile ${General::swroot}/ca/ $cahash { $key }[0]cert.pem $filename ` ;
1571 if ( $test =~ /: OK/ ) {
1578 $errormessage = $Lang :: tr
{ 'certificate does not have a valid ca associated with it' };
1582 move
( $filename , "${General::swroot}/certs/ $cgiparams {'NAME'}cert.pem" );
1584 $errormessage = " $Lang ::tr{'certificate file move failed'}: $!" ;
1590 $cgiparams { 'CERT_NAME' } = getCNfromcert
( "${General::swroot}/certs/ $cgiparams {'NAME'}cert.pem" );
1591 if ( $cgiparams { 'CERT_NAME' } eq '' ) {
1592 unlink ( "${General::swroot}/certs/ $cgiparams {'NAME'}cert.pem" );
1593 $errormessage = $Lang :: tr
{ 'could not retrieve common name from certificate' };
1596 } elsif ( $cgiparams { 'AUTH' } eq 'certgen' ) {
1597 if ( $cgiparams { 'KEY' }) {
1598 $errormessage = $Lang :: tr
{ 'cant change certificates' };
1601 # Validate input since the form was submitted
1602 if ( length ( $cgiparams { 'CERT_NAME' }) > 60 ) {
1603 $errormessage = $Lang :: tr
{ 'name too long' };
1606 if ( $cgiparams { 'CERT_NAME' } !~ /^[a-zA-Z0-9 ,\.\-_]+$/ ) {
1607 $errormessage = $Lang :: tr
{ 'invalid input for name' };
1610 if ( $cgiparams { 'CERT_EMAIL' } ne '' && (! & General
:: validemail
( $cgiparams { 'CERT_EMAIL' }))) {
1611 $errormessage = $Lang :: tr
{ 'invalid input for e-mail address' };
1614 if ( length ( $cgiparams { 'CERT_EMAIL' }) > 40 ) {
1615 $errormessage = $Lang :: tr
{ 'e-mail address too long' };
1618 if ( $cgiparams { 'CERT_OU' } ne '' && $cgiparams { 'CERT_OU' } !~ /^[a-zA-Z0-9 ,\.\-_]*$/ ) {
1619 $errormessage = $Lang :: tr
{ 'invalid input for department' };
1622 if ( length ( $cgiparams { 'CERT_ORGANIZATION' }) > 60 ) {
1623 $errormessage = $Lang :: tr
{ 'organization too long' };
1626 if ( $cgiparams { 'CERT_ORGANIZATION' } !~ /^[a-zA-Z0-9 ,\.\-_]+$/ ) {
1627 $errormessage = $Lang :: tr
{ 'invalid input for organization' };
1630 if ( $cgiparams { 'CERT_CITY' } ne '' && $cgiparams { 'CERT_CITY' } !~ /^[a-zA-Z0-9 ,\.\-_]*$/ ) {
1631 $errormessage = $Lang :: tr
{ 'invalid input for city' };
1634 if ( $cgiparams { 'CERT_STATE' } ne '' && $cgiparams { 'CERT_STATE' } !~ /^[a-zA-Z0-9 ,\.\-_]*$/ ) {
1635 $errormessage = $Lang :: tr
{ 'invalid input for state or province' };
1638 if ( $cgiparams { 'CERT_COUNTRY' } !~ /^[A-Z]*$/ ) {
1639 $errormessage = $Lang :: tr
{ 'invalid input for country' };
1642 #the exact syntax is a list comma separated of
1643 # email:any-validemail
1644 # URI: a uniform resource indicator
1645 # DNS: a DNS domain name
1646 # RID: a registered OBJECT IDENTIFIER
1648 # example: email:franck@foo.com,IP:10.0.0.10,DNS:franck.foo.com
1650 if ( $cgiparams { 'SUBJECTALTNAME' } ne '' && $cgiparams { 'SUBJECTALTNAME' } !~ /^(email|URI|DNS|RID|IP):[a-zA-Z0-9 :\/ , \
. \
- _@
]*$/) {
1651 $errormessage = $Lang :: tr
{ 'vpn altname syntax' };
1655 if ( length ( $cgiparams { 'CERT_PASS1' }) < 5 ) {
1656 $errormessage = $Lang :: tr
{ 'password too short' };
1659 if ( $cgiparams { 'CERT_PASS1' } ne $cgiparams { 'CERT_PASS2' }) {
1660 $errormessage = $Lang :: tr
{ 'passwords do not match' };
1664 # Replace empty strings with a .
1665 ( my $ou = $cgiparams { 'CERT_OU' }) =~ s/^\s*$/\./ ;
1666 ( my $city = $cgiparams { 'CERT_CITY' }) =~ s/^\s*$/\./ ;
1667 ( my $state = $cgiparams { 'CERT_STATE' }) =~ s/^\s*$/\./ ;
1669 # Create the Host certificate request
1670 & General
:: log ( "ipsec" , "Creating a cert..." );
1672 if ( open ( STDIN
, "-|" )) {
1673 my $opt = " req -nodes -rand /proc/interrupts:/proc/net/rt_cache" ;
1674 $opt .= " -newkey rsa:1024" ;
1675 $opt .= " -keyout ${General::swroot}/certs/ $cgiparams {'NAME'}key.pem" ;
1676 $opt .= " -out ${General::swroot}/certs/ $cgiparams {'NAME'}req.pem" ;
1678 if ( $errormessage = & callssl
( $opt ) ) {
1679 unlink ( "${General::swroot}/certs/ $cgiparams {'NAME'}key.pem" );
1680 unlink ( "${General::swroot}/certs/ $cgiparams {'NAME'}req.pem" );
1684 print " $cgiparams {'CERT_COUNTRY'} \n " ;
1687 print " $cgiparams {'CERT_ORGANIZATION'} \n " ;
1689 print " $cgiparams {'CERT_NAME'} \n " ;
1690 print " $cgiparams {'CERT_EMAIL'} \n " ;
1696 # Sign the host certificate request
1697 & General
:: log ( "ipsec" , "Signing the cert $cgiparams {'NAME'}..." );
1699 #No easy way for specifying the contain of subjectAltName without writing a config file...
1700 my ( $fh , $v3extname ) = tempfile
( '/tmp/XXXXXXXX' );
1702 basicConstraints=CA:FALSE
1703 nsComment="OpenSSL Generated Certificate"
1704 subjectKeyIdentifier=hash
1705 authorityKeyIdentifier=keyid,issuer:always
1708 print $fh "subjectAltName= $cgiparams {'SUBJECTALTNAME'}" if ( $cgiparams { 'SUBJECTALTNAME' });
1711 my $opt = " ca -days 999999 -batch -notext" ;
1712 $opt .= " -in ${General::swroot}/certs/ $cgiparams {'NAME'}req.pem" ;
1713 $opt .= " -out ${General::swroot}/certs/ $cgiparams {'NAME'}cert.pem" ;
1714 $opt .= " -extfile $v3extname " ;
1716 if ( $errormessage = & callssl
( $opt ) ) {
1717 unlink ( $v3extname );
1718 unlink ( "${General::swroot}/certs/ $cgiparams {'NAME'}key.pem" );
1719 unlink ( "${General::swroot}/certs/ $cgiparams {'NAME'}req.pem" );
1720 unlink ( "${General::swroot}/certs/ $cgiparams {'NAME'}cert.pem" );
1721 & cleanssldatabase
();
1724 unlink ( $v3extname );
1725 unlink ( "${General::swroot}/certs/ $cgiparams {'NAME'}req.pem" );
1726 & cleanssldatabase
();
1729 # Create the pkcs12 file
1730 & General
:: log ( "ipsec" , "Packing a pkcs12 file..." );
1731 $opt = " pkcs12 -export" ;
1732 $opt .= " -inkey ${General::swroot}/certs/ $cgiparams {'NAME'}key.pem" ;
1733 $opt .= " -in ${General::swroot}/certs/ $cgiparams {'NAME'}cert.pem" ;
1734 $opt .= " -name \" $cgiparams {'NAME'} \" " ;
1735 $opt .= " -passout pass: $cgiparams {'CERT_PASS1'}" ;
1736 $opt .= " -certfile ${General::swroot}/ca/cacert.pem" ;
1737 $opt .= " -caname \" $vpnsettings {'ROOTCERT_ORGANIZATION'} CA \" " ;
1738 $opt .= " -out ${General::swroot}/certs/ $cgiparams {'NAME'}.p12" ;
1740 if ( $errormessage = & callssl
( $opt ) ) {
1741 unlink ( "${General::swroot}/certs/ $cgiparams {'NAME'}key.pem" );
1742 unlink ( "${General::swroot}/certs/ $cgiparams {'NAME'}cert.pem" );
1743 unlink ( "${General::swroot}/certs/ $cgiparams {'NAME'}.p12" );
1746 unlink ( "${General::swroot}/certs/ $cgiparams {'NAME'}key.pem" );
1748 } elsif ( $cgiparams { 'AUTH' } eq 'cert' ) {
1749 ; # Nothing, just editing
1750 } elsif ( $cgiparams { 'AUTH' } eq 'auth-dn' ) {
1751 $cgiparams { 'CERT_NAME' } = ' %auth -dn' ; # a special value saying 'no cert file'
1753 $errormessage = $Lang :: tr
{ 'invalid input for authentication method' };
1757 # 1)Error message here is not accurate.
1758 # 2)Test is superfluous, openswan can reference same cert multiple times
1759 # 3)Present since initial version (1.3.2.11), it isn't a bug correction
1760 # Check if there is no other entry with this certificate name
1761 #if ((! $cgiparams{'KEY'}) && ($cgiparams{'AUTH'} ne 'psk') && ($cgiparams{'AUTH'} ne 'auth-dn')) {
1762 # foreach my $key (keys %confighash) {
1763 # if ($confighash{$key}[2] eq $cgiparams{'CERT_NAME'}) {
1764 # $errormessage = $Lang::tr{'a connection with this common name already exists'};
1765 # goto VPNCONF_ERROR;
1771 my $key = $cgiparams { 'KEY' };
1773 $key = & General
:: findhasharraykey
( \
%confighash );
1774 foreach my $i ( 0 .. 28 ) { $confighash { $key }[ $i ] = "" ;}
1776 $confighash { $key }[ 0 ] = $cgiparams { 'ENABLED' };
1777 $confighash { $key }[ 1 ] = $cgiparams { 'NAME' };
1778 if ((! $cgiparams { 'KEY' }) && $cgiparams { 'AUTH' } ne 'psk' ) {
1779 $confighash { $key }[ 2 ] = $cgiparams { 'CERT_NAME' };
1781 $confighash { $key }[ 3 ] = $cgiparams { 'TYPE' };
1782 if ( $cgiparams { 'AUTH' } eq 'psk' ) {
1783 $confighash { $key }[ 4 ] = 'psk' ;
1784 $confighash { $key }[ 5 ] = $cgiparams { 'PSK' };
1786 $confighash { $key }[ 4 ] = 'cert' ;
1788 if ( $cgiparams { 'TYPE' } eq 'net' ) {
1789 $confighash { $key }[ 6 ] = $cgiparams { 'SIDE' };
1790 $confighash { $key }[ 11 ] = $cgiparams { 'REMOTE_SUBNET' };
1792 $confighash { $key }[ 7 ] = $cgiparams { 'LOCAL_ID' };
1793 $confighash { $key }[ 8 ] = $cgiparams { 'LOCAL_SUBNET' };
1794 $confighash { $key }[ 9 ] = $cgiparams { 'REMOTE_ID' };
1795 $confighash { $key }[ 10 ] = $cgiparams { 'REMOTE' };
1796 $confighash { $key }[ 25 ] = $cgiparams { 'REMARK' };
1797 $confighash { $key }[ 26 ] = $cgiparams { 'INTERFACE' };
1798 $confighash { $key }[ 27 ] = $cgiparams { 'DPD_ACTION' };
1800 #dont forget advanced value
1801 $confighash { $key }[ 18 ] = $cgiparams { 'IKE_ENCRYPTION' };
1802 $confighash { $key }[ 19 ] = $cgiparams { 'IKE_INTEGRITY' };
1803 $confighash { $key }[ 20 ] = $cgiparams { 'IKE_GROUPTYPE' };
1804 $confighash { $key }[ 16 ] = $cgiparams { 'IKE_LIFETIME' };
1805 $confighash { $key }[ 21 ] = $cgiparams { 'ESP_ENCRYPTION' };
1806 $confighash { $key }[ 22 ] = $cgiparams { 'ESP_INTEGRITY' };
1807 $confighash { $key }[ 23 ] = $cgiparams { 'ESP_GROUPTYPE' };
1808 $confighash { $key }[ 17 ] = $cgiparams { 'ESP_KEYLIFE' };
1809 $confighash { $key }[ 12 ] = $cgiparams { 'AGGRMODE' };
1810 $confighash { $key }[ 13 ] = $cgiparams { 'COMPRESSION' };
1811 $confighash { $key }[ 24 ] = $cgiparams { 'ONLY_PROPOSED' };
1812 $confighash { $key }[ 28 ] = $cgiparams { 'PFS' };
1813 $confighash { $key }[ 14 ] = $cgiparams { 'VHOST' };
1815 #free unused fields!
1816 $confighash { $key }[ 15 ] = 'off' ;
1818 & General
:: writehasharray
( "${General::swroot}/vpn/config" , \
%confighash );
1821 system ( '/usr/local/bin/ipsecctrl' , 'S' , $key );
1824 if ( $cgiparams { 'EDIT_ADVANCED' } eq 'on' ) {
1825 $cgiparams { 'KEY' } = $key ;
1826 $cgiparams { 'ACTION' } = $Lang :: tr
{ 'advanced' };
1829 } else { # add new connection
1830 $cgiparams { 'ENABLED' } = 'on' ;
1831 $cgiparams { 'SIDE' } = 'left' ;
1832 if ( ! - f
"${General::swroot}/private/cakey.pem" ) {
1833 $cgiparams { 'AUTH' } = 'psk' ;
1834 } elsif ( ! - f
"${General::swroot}/ca/cacert.pem" ) {
1835 $cgiparams { 'AUTH' } = 'certfile' ;
1837 $cgiparams { 'AUTH' } = 'certgen' ;
1839 $cgiparams { 'LOCAL_SUBNET' } = " $netsettings {'GREEN_NETADDRESS'}/ $netsettings {'GREEN_NETMASK'}" ;
1840 $cgiparams { 'CERT_EMAIL' } = $vpnsettings { 'ROOTCERT_EMAIL' };
1841 $cgiparams { 'CERT_OU' } = $vpnsettings { 'ROOTCERT_OU' };
1842 $cgiparams { 'CERT_ORGANIZATION' } = $vpnsettings { 'ROOTCERT_ORGANIZATION' };
1843 $cgiparams { 'CERT_CITY' } = $vpnsettings { 'ROOTCERT_CITY' };
1844 $cgiparams { 'CERT_STATE' } = $vpnsettings { 'ROOTCERT_STATE' };
1845 $cgiparams { 'CERT_COUNTRY' } = $vpnsettings { 'ROOTCERT_COUNTRY' };
1847 # choose appropriate dpd action
1848 if ( $cgiparams { 'TYPE' } eq 'host' ) {
1849 $cgiparams { 'DPD_ACTION' } = 'clear' ;
1851 $cgiparams { 'DPD_ACTION' } = 'restart' ;
1854 # Default is yes for 'pfs'
1855 $cgiparams { 'PFS' } = 'on' ;
1858 $cgiparams { 'LOCAL_ID' } = '' ;
1859 $cgiparams { 'REMOTE_ID' } = '' ;
1861 #use default advanced value
1862 $cgiparams { 'IKE_ENCRYPTION' } = 'aes128|3des' ; #[18];
1863 $cgiparams { 'IKE_INTEGRITY' } = 'sha|md5' ; #[19];
1864 $cgiparams { 'IKE_GROUPTYPE' } = '1536|1024' ; #[20];
1865 $cgiparams { 'IKE_LIFETIME' } = '1' ; #[16];
1866 $cgiparams { 'ESP_ENCRYPTION' } = 'aes128|3des' ; #[21];
1867 $cgiparams { 'ESP_INTEGRITY' } = 'sha1|md5' ; #[22];
1868 $cgiparams { 'ESP_GROUPTYPE' } = '' ; #[23];
1869 $cgiparams { 'ESP_KEYLIFE' } = '8' ; #[17];
1870 $cgiparams { 'AGGRMODE' } = 'off' ; #[12];
1871 $cgiparams { 'COMPRESSION' } = 'off' ; #[13];
1872 $cgiparams { 'ONLY_PROPOSED' } = 'off' ; #[24];
1873 $cgiparams { 'PFS' } = 'on' ; #[28];
1874 $cgiparams { 'VHOST' } = 'on' ; #[14];
1878 $checked { 'ENABLED' }{ 'off' } = '' ;
1879 $checked { 'ENABLED' }{ 'on' } = '' ;
1880 $checked { 'ENABLED' }{ $cgiparams { 'ENABLED' }} = "checked='checked'" ;
1881 $checked { 'ENABLED_GREEN' }{ 'off' } = '' ;
1882 $checked { 'ENABLED_GREEN' }{ 'on' } = '' ;
1883 $checked { 'ENABLED_GREEN' }{ $cgiparams { 'ENABLED_GREEN' }} = "checked='checked'" ;
1884 $checked { 'ENABLED_ORANGE' }{ 'off' } = '' ;
1885 $checked { 'ENABLED_ORANGE' }{ 'on' } = '' ;
1886 $checked { 'ENABLED_ORANGE' }{ $cgiparams { 'ENABLED_ORANGE' }} = "checked='checked'" ;
1887 $checked { 'ENABLED_BLUE' }{ 'off' } = '' ;
1888 $checked { 'ENABLED_BLUE' }{ 'on' } = '' ;
1889 $checked { 'ENABLED_BLUE' }{ $cgiparams { 'ENABLED_BLUE' }} = "checked='checked'" ;
1891 $checked { 'EDIT_ADVANCED' }{ 'off' } = '' ;
1892 $checked { 'EDIT_ADVANCED' }{ 'on' } = '' ;
1893 $checked { 'EDIT_ADVANCED' }{ $cgiparams { 'EDIT_ADVANCED' }} = "checked='checked'" ;
1895 $selected { 'SIDE' }{ 'left' } = '' ;
1896 $selected { 'SIDE' }{ 'right' } = '' ;
1897 $selected { 'SIDE' }{ $cgiparams { 'SIDE' }} = "selected='selected'" ;
1899 $checked { 'AUTH' }{ 'psk' } = '' ;
1900 $checked { 'AUTH' }{ 'certreq' } = '' ;
1901 $checked { 'AUTH' }{ 'certgen' } = '' ;
1902 $checked { 'AUTH' }{ 'certfile' } = '' ;
1903 $checked { 'AUTH' }{ 'pkcs12' } = '' ;
1904 $checked { 'AUTH' }{ 'auth-dn' } = '' ;
1905 $checked { 'AUTH' }{ $cgiparams { 'AUTH' }} = "checked='checked'" ;
1907 $selected { 'INTERFACE' }{ 'RED' } = '' ;
1908 $selected { 'INTERFACE' }{ 'ORANGE' } = '' ;
1909 $selected { 'INTERFACE' }{ 'GREEN' } = '' ;
1910 $selected { 'INTERFACE' }{ 'BLUE' } = '' ;
1911 $selected { 'INTERFACE' }{ $cgiparams { 'INTERFACE' }} = "selected='selected'" ;
1913 $selected { 'DPD_ACTION' }{ 'clear' } = '' ;
1914 $selected { 'DPD_ACTION' }{ 'hold' } = '' ;
1915 $selected { 'DPD_ACTION' }{ 'restart' } = '' ;
1916 $selected { 'DPD_ACTION' }{ $cgiparams { 'DPD_ACTION' }} = "selected='selected'" ;
1918 & Header
:: showhttpheaders
();
1919 & Header
:: openpage
( $Lang :: tr
{ 'vpn configuration main' }, 1 , '' );
1920 & Header
:: openbigbox
( '100%' , 'left' , '' , $errormessage );
1921 if ( $errormessage ) {
1922 & Header
:: openbox
( '100%' , 'left' , $Lang :: tr
{ 'error messages' });
1923 print "<class name='base'> $errormessage " ;
1924 print " </class>" ;
1925 & Header
:: closebox
();
1929 & Header
:: openbox
( '100%' , 'left' , " $Lang ::tr{'warning messages'}:" );
1930 print "<class name='base'> $warnmessage " ;
1931 print " </class>" ;
1932 & Header
:: closebox
();
1935 print "<form method='post' enctype='multipart/form-data' action=' $ENV {'SCRIPT_NAME'}'>" ;
1937 <input type='hidden' name='TYPE' value=' $cgiparams {'TYPE'}' />
1938 <input type='hidden' name='IKE_ENCRYPTION' value=' $cgiparams {'IKE_ENCRYPTION'}' />
1939 <input type='hidden' name='IKE_INTEGRITY' value=' $cgiparams {'IKE_INTEGRITY'}' />
1940 <input type='hidden' name='IKE_GROUPTYPE' value=' $cgiparams {'IKE_GROUPTYPE'}' />
1941 <input type='hidden' name='IKE_LIFETIME' value=' $cgiparams {'IKE_LIFETIME'}' />
1942 <input type='hidden' name='ESP_ENCRYPTION' value=' $cgiparams {'ESP_ENCRYPTION'}' />
1943 <input type='hidden' name='ESP_INTEGRITY' value=' $cgiparams {'ESP_INTEGRITY'}' />
1944 <input type='hidden' name='ESP_GROUPTYPE' value=' $cgiparams {'ESP_GROUPTYPE'}' />
1945 <input type='hidden' name='ESP_KEYLIFE' value=' $cgiparams {'ESP_KEYLIFE'}' />
1946 <input type='hidden' name='AGGRMODE' value=' $cgiparams {'AGGRMODE'}' />
1947 <input type='hidden' name='COMPRESSION' value=' $cgiparams {'COMPRESSION'}' />
1948 <input type='hidden' name='ONLY_PROPOSED' value=' $cgiparams {'ONLY_PROPOSED'}' />
1949 <input type='hidden' name='PFS' value=' $cgiparams {'PFS'}' />
1950 <input type='hidden' name='VHOST' value=' $cgiparams {'VHOST'}' />
1953 if ( $cgiparams { 'KEY' }) {
1954 print "<input type='hidden' name='KEY' value=' $cgiparams {'KEY'}' />" ;
1955 print "<input type='hidden' name='AUTH' value=' $cgiparams {'AUTH'}' />" ;
1958 & Header
:: openbox
( '100%' , 'left' , " $Lang ::tr{'connection'}:" );
1959 print "<table width='100%'>" ;
1960 print "<tr><td width='25%' class='boldbase'> $Lang ::tr{'name'}:</td>" ;
1961 if ( $cgiparams { 'KEY' }) {
1962 print "<td width='25%' class='base'><input type='hidden' name='NAME' value=' $cgiparams {'NAME'}' /><b> $cgiparams {'NAME'}</b></td>" ;
1964 print "<td width='25%'><input type='text' name='NAME' value=' $cgiparams {'NAME'}' size='30' /></td>" ;
1966 print "<td> $Lang ::tr{'enabled'}</td><td><input type='checkbox' name='ENABLED' $checked{'ENABLED'}{'on'} /></td></tr>" ;
1968 if ( $cgiparams { 'TYPE' } eq 'host' ) {
1970 print "<tr><td> $Lang ::tr{'interface'}</td>" ;
1971 print "<td><select name='INTERFACE'>" ;
1972 print "<option value='RED' $selected {'INTERFACE'}{'RED'}>RED</option>" ;
1973 print "<option value='BLUE' $selected {'INTERFACE'}{'BLUE'}>BLUE</option>" if ( $netsettings { 'BLUE_DEV' } ne '' );
1974 print "<option value='GREEN' $selected {'INTERFACE'}{'GREEN'}>GREEN</option>" ;
1975 # print "<option value='ORANGE' $selected{'INTERFACE'}{'ORANGE'}>ORANGE</option>";
1976 print "</select></td></tr>" ;
1978 <tr><td class='boldbase'> $Lang ::tr{'local subnet'}</td>
1979 <td><input type='text' name='LOCAL_SUBNET' value=' $cgiparams {'LOCAL_SUBNET'}' size='30' /></td>
1980 <td colspan='2'> </td>
1982 <td class='boldbase'> $Lang ::tr{'remote host/ip'}: <img src='/blob.gif' alt='*' /></td>
1983 <td><input type='text' name='REMOTE' value=' $cgiparams {'REMOTE'}' size='30' /></td>
1984 <td colspan='2'> </td>
1990 <tr><td class='boldbase' nowrap='nowrap'> $Lang ::tr{'ipcop side'}
1991 <input type='hidden' name='INTERFACE' value='RED' /></td>
1992 <td><select name='SIDE'><option value='left' $selected {'SIDE'}{'left'}>left</option>
1993 <option value='right' $selected {'SIDE'}{'right'}>right</option></select></td>
1994 <td class='boldbase'> $Lang ::tr{'remote host/ip'}:</td>
1995 <td><input type='text' name='REMOTE' value=' $cgiparams {'REMOTE'}' size ='30' /></td>
1997 <td class='boldbase' nowrap='nowrap'> $Lang ::tr{'local subnet'}</td>
1998 <td><input type='text' name='LOCAL_SUBNET' value=' $cgiparams {'LOCAL_SUBNET'}' size='30' /></td>
1999 <td class='boldbase' nowrap='nowrap'> $Lang ::tr{'remote subnet'}</td>
2000 <td><input type='text' name='REMOTE_SUBNET' value=' $cgiparams {'REMOTE_SUBNET'}' size='30' /></td>
2007 <td> $Lang ::tr{'dpd action'}:</td>
2008 <td><select name='DPD_ACTION'>
2009 <option value='clear' $selected {'DPD_ACTION'}{'clear'}>clear</option>
2010 <option value='hold' $selected {'DPD_ACTION'}{'hold'}>hold</option>
2011 <option value='restart' $selected {'DPD_ACTION'}{'restart'}>restart</option>
2012 </select> <a href='http://www.openswan.com/docs/local/README.DPD'>?</a>
2015 <!--http://www.openswan.com/docs/local/README.DPD
2016 http://bugs.xelerance.com/view.php?id=156
2017 restart = clear + reinitiate connection
2019 <td><b> $Lang ::tr{'options'}</b></td>
2021 <td class='boldbase'> $Lang ::tr{'vpn local id'}: <img src='/blob.gif' alt='*' />
2022 <br />( $Lang ::tr{'eg'} <tt>@xy.example.com</tt>)</td>
2023 <td><input type='text' name='LOCAL_ID' value=' $cgiparams {'LOCAL_ID'}' /></td>
2024 <td class='boldbase'> $Lang ::tr{'vpn remote id'}: <img src='/blob.gif' alt='*' /></td>
2025 <td><input type='text' name='REMOTE_ID' value=' $cgiparams {'REMOTE_ID'}' /></td>
2027 <td class='boldbase'> $Lang ::tr{'remark title'} <img src='/blob.gif' alt='*' /></td>
2028 <td colspan='3'><input type='text' name='REMARK' value=' $cgiparams {'REMARK'}' size='55' maxlength='50' /></td>
2032 if (! $cgiparams { 'KEY' }) {
2033 print "<tr><td colspan='3'><input type='checkbox' name='EDIT_ADVANCED' $checked {'EDIT_ADVANCED'}{'on'} /> $Lang ::tr{'edit advanced settings when done'}</td></tr>" ;
2036 & Header
:: closebox
();
2038 if ( $cgiparams { 'KEY' } && $cgiparams { 'AUTH' } eq 'psk' ) {
2039 & Header
:: openbox
( '100%' , 'left' , $Lang :: tr
{ 'authentication' });
2041 <table width='100%' cellpadding='0' cellspacing='5' border='0'>
2042 <tr><td class='base' width='50%'> $Lang ::tr{'use a pre-shared key'}</td>
2043 <td class='base' width='50%'><input type='text' name='PSK' size='30' value=' $cgiparams {'PSK'}' /></td>
2048 & Header
:: closebox
();
2049 } elsif (! $cgiparams { 'KEY' }) {
2050 my $pskdisabled = ( $vpnsettings { 'VPN_IP' } eq ' %defaultroute ' ) ?
"disabled='disabled'" : '' ;
2051 $cgiparams { 'PSK' } = $Lang :: tr
{ 'vpn incompatible use of defaultroute' } if ( $pskdisabled );
2052 my $cakeydisabled = ( ! - f
"${General::swroot}/private/cakey.pem" ) ?
"disabled='disabled'" : '' ;
2053 $cgiparams { 'CERT_NAME' } = $Lang :: tr
{ 'vpn no full pki' } if ( $cakeydisabled );
2054 my $cacrtdisabled = ( ! - f
"${General::swroot}/ca/cacert.pem" ) ?
"disabled='disabled'" : '' ;
2056 & Header
:: openbox
( '100%' , 'left' , $Lang :: tr
{ 'authentication' });
2058 <table width='100%' cellpadding='0' cellspacing='5' border='0'>
2059 <tr><td width='5%'><input type='radio' name='AUTH' value='psk' $checked {'AUTH'}{'psk'} $pskdisabled /></td>
2060 <td class='base' width='55%'> $Lang ::tr{'use a pre-shared key'}</td>
2061 <td class='base' width='40%'><input type='text' name='PSK' size='30' value=' $cgiparams {'PSK'}' $pskdisabled /></td></tr>
2062 <tr><td colspan='3' bgcolor='#000000'></td></tr>
2063 <tr><td><input type='radio' name='AUTH' value='certreq' $checked {'AUTH'}{'certreq'} $cakeydisabled /></td>
2064 <td class='base'><hr /> $Lang ::tr{'upload a certificate request'}</td>
2065 <td class='base' rowspan='3' valign='middle'><input type='file' name='FH' size='30' $cacrtdisabled /></td></tr>
2066 <tr><td><input type='radio' name='AUTH' value='certfile' $checked {'AUTH'}{'certfile'} $cacrtdisabled /></td>
2067 <td class='base'> $Lang ::tr{'upload a certificate'}</td></tr>
2068 <tr><td><input type='radio' name='AUTH' value='pkcs12' $cacrtdisabled /></td>
2069 <td class='base'> $Lang ::tr{'upload p12 file'} $Lang ::tr{'pkcs12 file password'}:<input type='password' name='P12_PASS'/></td></tr>
2070 <tr><td><input type='radio' name='AUTH' value='auth-dn' $checked {'AUTH'}{'auth-dn'} $cacrtdisabled /></td>
2071 <td class='base'><hr /> $Lang ::tr{'vpn auth-dn'}</td></tr>
2072 <tr><td colspan='3' bgcolor='#000000'></td></tr>
2073 <tr><td><input type='radio' name='AUTH' value='certgen' $checked {'AUTH'}{'certgen'} $cakeydisabled /></td>
2074 <td class='base'><hr /> $Lang ::tr{'generate a certificate'}</td><td> </td></tr>
2076 <td class='base'> $Lang ::tr{'users fullname or system hostname'}:</td>
2077 <td class='base' nowrap='nowrap'><input type='text' name='CERT_NAME' value=' $cgiparams {'CERT_NAME'}' size='32' $cakeydisabled /></td></tr>
2079 <td class='base'> $Lang ::tr{'users email'}: <img src='/blob.gif' alt='*' /></td>
2080 <td class='base' nowrap='nowrap'><input type='text' name='CERT_EMAIL' value=' $cgiparams {'CERT_EMAIL'}' size='32' $cakeydisabled /></td></tr>
2082 <td class='base'> $Lang ::tr{'users department'}: <img src='/blob.gif' alt='*' /></td>
2083 <td class='base' nowrap='nowrap'><input type='text' name='CERT_OU' value=' $cgiparams {'CERT_OU'}' size='32' $cakeydisabled /></td></tr>
2085 <td class='base'> $Lang ::tr{'organization name'}: <img src='/blob.gif' alt='*' /></td>
2086 <td class='base' nowrap='nowrap'><input type='text' name='CERT_ORGANIZATION' value=' $cgiparams {'CERT_ORGANIZATION'}' size='32' $cakeydisabled /></td></tr>
2088 <td class='base'> $Lang ::tr{'city'}: <img src='/blob.gif' alt='*' /></td>
2089 <td class='base' nowrap='nowrap'><input type='text' name='CERT_CITY' value=' $cgiparams {'CERT_CITY'}' size='32' $cakeydisabled /></td></tr>
2091 <td class='base'> $Lang ::tr{'state or province'}: <img src='/blob.gif' alt='*' /></td>
2092 <td class='base' nowrap='nowrap'><input type='text' name='CERT_STATE' value=' $cgiparams {'CERT_STATE'}' size='32' $cakeydisabled /></td></tr>
2094 <td class='base'> $Lang ::tr{'country'}:</td>
2095 <td class='base'><select name='CERT_COUNTRY' $cakeydisabled >
2098 foreach my $country ( sort keys %{ Countries
:: countries
}) {
2099 print " \t\t\t <option value=' $Countries ::countries{ $country }'" ;
2100 if ( $Countries :: countries
{ $country } eq $cgiparams { 'CERT_COUNTRY' } ) {
2101 print " selected='selected'" ;
2103 print "> $country </option> \n " ;
2108 <tr><td> </td><td class='base'> $Lang ::tr{'vpn subjectaltname'} (subjectAltName=email:*,URI:*,DNS:*,RID:*)<img src='/blob.gif' alt='*' /></td>
2109 <td class='base' nowrap='nowrap'><input type='text' name='SUBJECTALTNAME' value=' $cgiparams {'SUBJECTALTNAME'}' size='32' $cakeydisabled /></td></tr>
2111 <td class='base'> $Lang ::tr{'pkcs12 file password'}:</td>
2112 <td class='base' nowrap='nowrap'><input type='password' name='CERT_PASS1' value=' $cgiparams {'CERT_PASS1'}' size='32' $cakeydisabled /></td></tr>
2113 <tr><td> </td><td class='base'> $Lang ::tr{'pkcs12 file password'}:( $Lang ::tr{'confirmation'})</td>
2114 <td class='base' nowrap='nowrap'><input type='password' name='CERT_PASS2' value=' $cgiparams {'CERT_PASS2'}' size='32' $cakeydisabled /></td></tr>
2118 & Header
:: closebox
();
2121 print "<div align='center'><input type='submit' name='ACTION' value=' $Lang ::tr{'save'}' />" ;
2122 if ( $cgiparams { 'KEY' }) {
2123 print "<input type='submit' name='ACTION' value=' $Lang ::tr{'advanced'}' />" ;
2125 print "<input type='submit' name='ACTION' value=' $Lang ::tr{'cancel'}' /></div></form>" ;
2126 & Header
:: closebigbox
();
2127 & Header
:: closepage
();
2134 ### Advanced settings
2136 if (( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'advanced' }) ||
2137 ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'save' } && $cgiparams { 'ADVANCED' } eq 'yes' )) {
2138 & General
:: readhash
( "${General::swroot}/vpn/settings" , \
%vpnsettings );
2139 & General
:: readhasharray
( "${General::swroot}/vpn/config" , \
%confighash );
2140 if (! $confighash { $cgiparams { 'KEY' }}) {
2141 $errormessage = $Lang :: tr
{ 'invalid key' };
2145 if ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'save' }) {
2146 # I didn't read any incompatibilities here....
2147 #if ($cgiparams{'VHOST'} eq 'on' && $cgiparams{'COMPRESSION'} eq 'on') {
2148 # $errormessage = $Lang::tr{'cannot enable both nat traversal and compression'};
2149 # goto ADVANCED_ERROR;
2151 my @temp = split ( '\|' , $cgiparams { 'IKE_ENCRYPTION' });
2153 $errormessage = $Lang :: tr
{ 'invalid input' };
2154 goto ADVANCED_ERROR
;
2156 foreach my $val ( @temp ) {
2157 if ( $val !~ /^(aes256|aes128|3des|twofish256|twofish128|serpent256|serpent128|blowfish256|blowfish128|cast128)$/ ) {
2158 $errormessage = $Lang :: tr
{ 'invalid input' };
2159 goto ADVANCED_ERROR
;
2162 @temp = split ( '\|' , $cgiparams { 'IKE_INTEGRITY' });
2164 $errormessage = $Lang :: tr
{ 'invalid input' };
2165 goto ADVANCED_ERROR
;
2167 foreach my $val ( @temp ) {
2168 if ( $val !~ /^(sha2_512|sha2_256|sha|md5)$/ ) {
2169 $errormessage = $Lang :: tr
{ 'invalid input' };
2170 goto ADVANCED_ERROR
;
2173 @temp = split ( '\|' , $cgiparams { 'IKE_GROUPTYPE' });
2175 $errormessage = $Lang :: tr
{ 'invalid input' };
2176 goto ADVANCED_ERROR
;
2178 foreach my $val ( @temp ) {
2179 if ( $val !~ /^(768|1024|1536|2048|3072|4096|6144|8192)$/ ) {
2180 $errormessage = $Lang :: tr
{ 'invalid input' };
2181 goto ADVANCED_ERROR
;
2184 if ( $cgiparams { 'IKE_LIFETIME' } !~ /^\d+$/ ) {
2185 $errormessage = $Lang :: tr
{ 'invalid input for ike lifetime' };
2186 goto ADVANCED_ERROR
;
2188 if ( $cgiparams { 'IKE_LIFETIME' } < 1 || $cgiparams { 'IKE_LIFETIME' } > 8 ) {
2189 $errormessage = $Lang :: tr
{ 'ike lifetime should be between 1 and 8 hours' };
2190 goto ADVANCED_ERROR
;
2192 @temp = split ( '\|' , $cgiparams { 'ESP_ENCRYPTION' });
2194 $errormessage = $Lang :: tr
{ 'invalid input' };
2195 goto ADVANCED_ERROR
;
2197 foreach my $val ( @temp ) {
2198 if ( $val !~ /^(aes256|aes128|3des|twofish256|twofish128|serpent256|serpent128|blowfish256|blowfish128)$/ ) {
2199 $errormessage = $Lang :: tr
{ 'invalid input' };
2200 goto ADVANCED_ERROR
;
2203 @temp = split ( '\|' , $cgiparams { 'ESP_INTEGRITY' });
2205 $errormessage = $Lang :: tr
{ 'invalid input' };
2206 goto ADVANCED_ERROR
;
2208 foreach my $val ( @temp ) {
2209 if ( $val !~ /^(sha2_512|sha2_256|sha1|md5)$/ ) {
2210 $errormessage = $Lang :: tr
{ 'invalid input' };
2211 goto ADVANCED_ERROR
;
2214 if ( $cgiparams { 'ESP_GROUPTYPE' } ne '' &&
2215 $cgiparams { 'ESP_GROUPTYPE' } !~ /^modp(768|1024|1536|2048|3072|4096)$/ ) {
2216 $errormessage = $Lang :: tr
{ 'invalid input' };
2217 goto ADVANCED_ERROR
;
2220 if ( $cgiparams { 'ESP_KEYLIFE' } !~ /^\d+$/ ) {
2221 $errormessage = $Lang :: tr
{ 'invalid input for esp keylife' };
2222 goto ADVANCED_ERROR
;
2224 if ( $cgiparams { 'ESP_KEYLIFE' } < 1 || $cgiparams { 'ESP_KEYLIFE' } > 24 ) {
2225 $errormessage = $Lang :: tr
{ 'esp keylife should be between 1 and 24 hours' };
2226 goto ADVANCED_ERROR
;
2230 ( $cgiparams { 'AGGRMODE' } !~ /^(|on|off)$/ ) ||
2231 ( $cgiparams { 'COMPRESSION' } !~ /^(|on|off)$/ ) ||
2232 ( $cgiparams { 'ONLY_PROPOSED' } !~ /^(|on|off)$/ ) ||
2233 ( $cgiparams { 'PFS' } !~ /^(|on|off)$/ ) ||
2234 ( $cgiparams { 'VHOST' } !~ /^(|on|off)$/ )
2236 $errormessage = $Lang :: tr
{ 'invalid input' };
2237 goto ADVANCED_ERROR
;
2240 $confighash { $cgiparams { 'KEY' }}[ 18 ] = $cgiparams { 'IKE_ENCRYPTION' };
2241 $confighash { $cgiparams { 'KEY' }}[ 19 ] = $cgiparams { 'IKE_INTEGRITY' };
2242 $confighash { $cgiparams { 'KEY' }}[ 20 ] = $cgiparams { 'IKE_GROUPTYPE' };
2243 $confighash { $cgiparams { 'KEY' }}[ 16 ] = $cgiparams { 'IKE_LIFETIME' };
2244 $confighash { $cgiparams { 'KEY' }}[ 21 ] = $cgiparams { 'ESP_ENCRYPTION' };
2245 $confighash { $cgiparams { 'KEY' }}[ 22 ] = $cgiparams { 'ESP_INTEGRITY' };
2246 $confighash { $cgiparams { 'KEY' }}[ 23 ] = $cgiparams { 'ESP_GROUPTYPE' };
2247 $confighash { $cgiparams { 'KEY' }}[ 17 ] = $cgiparams { 'ESP_KEYLIFE' };
2248 $confighash { $cgiparams { 'KEY' }}[ 12 ] = $cgiparams { 'AGGRMODE' };
2249 $confighash { $cgiparams { 'KEY' }}[ 13 ] = $cgiparams { 'COMPRESSION' };
2250 $confighash { $cgiparams { 'KEY' }}[ 24 ] = $cgiparams { 'ONLY_PROPOSED' };
2251 $confighash { $cgiparams { 'KEY' }}[ 28 ] = $cgiparams { 'PFS' };
2252 $confighash { $cgiparams { 'KEY' }}[ 14 ] = $cgiparams { 'VHOST' };
2253 & General
:: writehasharray
( "${General::swroot}/vpn/config" , \
%confighash );
2256 system ( '/usr/local/bin/ipsecctrl' , 'S' , $cgiparams { 'KEY' });
2261 $cgiparams { 'IKE_ENCRYPTION' } = $confighash { $cgiparams { 'KEY' }}[ 18 ];
2262 $cgiparams { 'IKE_INTEGRITY' } = $confighash { $cgiparams { 'KEY' }}[ 19 ];
2263 $cgiparams { 'IKE_GROUPTYPE' } = $confighash { $cgiparams { 'KEY' }}[ 20 ];
2264 $cgiparams { 'IKE_LIFETIME' } = $confighash { $cgiparams { 'KEY' }}[ 16 ];
2265 $cgiparams { 'ESP_ENCRYPTION' } = $confighash { $cgiparams { 'KEY' }}[ 21 ];
2266 $cgiparams { 'ESP_INTEGRITY' } = $confighash { $cgiparams { 'KEY' }}[ 22 ];
2267 $cgiparams { 'ESP_GROUPTYPE' } = $confighash { $cgiparams { 'KEY' }}[ 23 ];
2268 $cgiparams { 'ESP_KEYLIFE' } = $confighash { $cgiparams { 'KEY' }}[ 17 ];
2269 $cgiparams { 'AGGRMODE' } = $confighash { $cgiparams { 'KEY' }}[ 12 ];
2270 $cgiparams { 'COMPRESSION' } = $confighash { $cgiparams { 'KEY' }}[ 13 ];
2271 $cgiparams { 'ONLY_PROPOSED' } = $confighash { $cgiparams { 'KEY' }}[ 24 ];
2272 $cgiparams { 'PFS' } = $confighash { $cgiparams { 'KEY' }}[ 28 ];
2273 $cgiparams { 'VHOST' } = $confighash { $cgiparams { 'KEY' }}[ 14 ];
2275 if ( $confighash { $cgiparams { 'KEY' }}[ 3 ] eq 'net' || $confighash { $cgiparams { 'KEY' }}[ 10 ]) {
2276 $cgiparams { 'VHOST' } = 'off' ;
2281 $checked { 'IKE_ENCRYPTION' }{ 'aes256' } = '' ;
2282 $checked { 'IKE_ENCRYPTION' }{ 'aes128' } = '' ;
2283 $checked { 'IKE_ENCRYPTION' }{ '3des' } = '' ;
2284 $checked { 'IKE_ENCRYPTION' }{ 'twofish256' } = '' ;
2285 $checked { 'IKE_ENCRYPTION' }{ 'twofish128' } = '' ;
2286 $checked { 'IKE_ENCRYPTION' }{ 'serpent256' } = '' ;
2287 $checked { 'IKE_ENCRYPTION' }{ 'serpent128' } = '' ;
2288 $checked { 'IKE_ENCRYPTION' }{ 'blowfish256' } = '' ;
2289 $checked { 'IKE_ENCRYPTION' }{ 'blowfish128' } = '' ;
2290 $checked { 'IKE_ENCRYPTION' }{ 'cast128' } = '' ;
2291 my @temp = split ( '\|' , $cgiparams { 'IKE_ENCRYPTION' });
2292 foreach my $key ( @temp ) { $checked { 'IKE_ENCRYPTION' }{ $key } = "selected='selected'" ; }
2293 $checked { 'IKE_INTEGRITY' }{ 'sha2_512' } = '' ;
2294 $checked { 'IKE_INTEGRITY' }{ 'sha2_256' } = '' ;
2295 $checked { 'IKE_INTEGRITY' }{ 'sha' } = '' ;
2296 $checked { 'IKE_INTEGRITY' }{ 'md5' } = '' ;
2297 @temp = split ( '\|' , $cgiparams { 'IKE_INTEGRITY' });
2298 foreach my $key ( @temp ) { $checked { 'IKE_INTEGRITY' }{ $key } = "selected='selected'" ; }
2299 $checked { 'IKE_GROUPTYPE' }{ '768' } = '' ;
2300 $checked { 'IKE_GROUPTYPE' }{ '1024' } = '' ;
2301 $checked { 'IKE_GROUPTYPE' }{ '1536' } = '' ;
2302 $checked { 'IKE_GROUPTYPE' }{ '2048' } = '' ;
2303 $checked { 'IKE_GROUPTYPE' }{ '3072' } = '' ;
2304 $checked { 'IKE_GROUPTYPE' }{ '4096' } = '' ;
2305 $checked { 'IKE_GROUPTYPE' }{ '6144' } = '' ;
2306 $checked { 'IKE_GROUPTYPE' }{ '8192' } = '' ;
2307 @temp = split ( '\|' , $cgiparams { 'IKE_GROUPTYPE' });
2308 foreach my $key ( @temp ) { $checked { 'IKE_GROUPTYPE' }{ $key } = "selected='selected'" ; }
2309 $checked { 'ESP_ENCRYPTION' }{ 'aes256' } = '' ;
2310 $checked { 'ESP_ENCRYPTION' }{ 'aes128' } = '' ;
2311 $checked { 'ESP_ENCRYPTION' }{ '3des' } = '' ;
2312 $checked { 'ESP_ENCRYPTION' }{ 'twofish256' } = '' ;
2313 $checked { 'ESP_ENCRYPTION' }{ 'twofish128' } = '' ;
2314 $checked { 'ESP_ENCRYPTION' }{ 'serpent256' } = '' ;
2315 $checked { 'ESP_ENCRYPTION' }{ 'serpent128' } = '' ;
2316 $checked { 'ESP_ENCRYPTION' }{ 'blowfish256' } = '' ;
2317 $checked { 'ESP_ENCRYPTION' }{ 'blowfish128' } = '' ;
2318 @temp = split ( '\|' , $cgiparams { 'ESP_ENCRYPTION' });
2319 foreach my $key ( @temp ) { $checked { 'ESP_ENCRYPTION' }{ $key } = "selected='selected'" ; }
2320 $checked { 'ESP_INTEGRITY' }{ 'sha2_512' } = '' ;
2321 $checked { 'ESP_INTEGRITY' }{ 'sha2_256' } = '' ;
2322 $checked { 'ESP_INTEGRITY' }{ 'sha1' } = '' ;
2323 $checked { 'ESP_INTEGRITY' }{ 'md5' } = '' ;
2324 @temp = split ( '\|' , $cgiparams { 'ESP_INTEGRITY' });
2325 foreach my $key ( @temp ) { $checked { 'ESP_INTEGRITY' }{ $key } = "selected='selected'" ; }
2326 $checked { 'ESP_GROUPTYPE' }{ 'modp768' } = '' ;
2327 $checked { 'ESP_GROUPTYPE' }{ 'modp1024' } = '' ;
2328 $checked { 'ESP_GROUPTYPE' }{ 'modp1536' } = '' ;
2329 $checked { 'ESP_GROUPTYPE' }{ 'modp2048' } = '' ;
2330 $checked { 'ESP_GROUPTYPE' }{ 'modp3072' } = '' ;
2331 $checked { 'ESP_GROUPTYPE' }{ 'modp4096' } = '' ;
2332 $checked { 'ESP_GROUPTYPE' }{ $cgiparams { 'ESP_GROUPTYPE' }} = "selected='selected'" ;
2334 $checked { 'AGGRMODE' } = $cgiparams { 'AGGRMODE' } eq 'on' ?
"checked='checked'" : '' ;
2335 $checked { 'COMPRESSION' } = $cgiparams { 'COMPRESSION' } eq 'on' ?
"checked='checked'" : '' ;
2336 $checked { 'ONLY_PROPOSED' } = $cgiparams { 'ONLY_PROPOSED' } eq 'on' ?
"checked='checked'" : '' ;
2337 $checked { 'PFS' } = $cgiparams { 'PFS' } eq 'on' ?
"checked='checked'" : '' ;
2338 $checked { 'VHOST' } = $cgiparams { 'VHOST' } eq 'on' ?
"checked='checked'" : '' ;
2340 & Header
:: showhttpheaders
();
2341 & Header
:: openpage
( $Lang :: tr
{ 'vpn configuration main' }, 1 , '' );
2342 & Header
:: openbigbox
( '100%' , 'left' , '' , $errormessage );
2344 if ( $errormessage ) {
2345 & Header
:: openbox
( '100%' , 'left' , $Lang :: tr
{ 'error messages' });
2346 print "<class name='base'> $errormessage " ;
2347 print " </class>" ;
2348 & Header
:: closebox
();
2352 & Header
:: openbox
( '100%' , 'left' , $Lang :: tr
{ 'warning messages' });
2353 print "<class name='base'> $warnmessage " ;
2354 print " </class>" ;
2355 & Header
:: closebox
();
2358 & Header
:: openbox
( '100%' , 'left' , " $Lang ::tr{'advanced'}:" );
2360 <form method='post' enctype='multipart/form-data' action=' $ENV {'SCRIPT_NAME'}'>
2361 <input type='hidden' name='ADVANCED' value='yes' />
2362 <input type='hidden' name='KEY' value=' $cgiparams {'KEY'}' />
2364 <table width='100%'>
2365 <tr><td class='boldbase' align='right' valign='top'> $Lang ::tr{'ike encryption'}</td><td class='boldbase' valign='top'>
2366 <select name='IKE_ENCRYPTION' multiple='multiple' size='4'>
2367 <option value='aes256' $checked {'IKE_ENCRYPTION'}{'aes256'}>AES (256 bit)</option>
2368 <option value='aes128' $checked {'IKE_ENCRYPTION'}{'aes128'}>AES (128 bit)</option>
2369 <option value='3des' $checked {'IKE_ENCRYPTION'}{'3des'}>3DES</option>
2370 <option value='twofish256' $checked {'IKE_ENCRYPTION'}{'twofish256'}>Twofish (256 bit)</option>
2371 <option value='twofish128' $checked {'IKE_ENCRYPTION'}{'twofish128'}>Twofish (128 bit)</option>
2372 <option value='serpent256' $checked {'IKE_ENCRYPTION'}{'serpent256'}>Serpent (256 bit)</option>
2373 <option value='serpent128' $checked {'IKE_ENCRYPTION'}{'serpent128'}>Serpent (128 bit)</option>
2374 <option value='blowfish256' $checked {'IKE_ENCRYPTION'}{'blowfish256'}>Blowfish (256 bit)</option>
2375 <option value='blowfish128' $checked {'IKE_ENCRYPTION'}{'blowfish128'}>Blowfish (128 bit)</option>
2376 <option value='cast128' $checked {'IKE_ENCRYPTION'}{'cast128'}>Cast (128 bit)</option>
2379 <td class='boldbase' align='right' valign='top'> $Lang ::tr{'ike integrity'}</td><td class='boldbase' valign='top'>
2380 <select name='IKE_INTEGRITY' multiple='multiple' size='4'>
2381 <option value='sha2_512' $checked {'IKE_INTEGRITY'}{'sha2_512'}>SHA2 (512)</option>
2382 <option value='sha2_256' $checked {'IKE_INTEGRITY'}{'sha2_256'}>SHA2 (256)</option>
2383 <option value='sha' $checked {'IKE_INTEGRITY'}{'sha'}>SHA</option>
2384 <option value='md5' $checked {'IKE_INTEGRITY'}{'md5'}>MD5</option>
2387 <td class='boldbase' align='right' valign='top'> $Lang ::tr{'ike grouptype'}</td><td class='boldbase' valign='top'>
2388 <select name='IKE_GROUPTYPE' multiple='multiple' size='4'>
2389 <option value='8192' $checked {'IKE_GROUPTYPE'}{'8192'}>MODP-8192</option>
2390 <option value='6144' $checked {'IKE_GROUPTYPE'}{'6144'}>MODP-6144</option>
2391 <option value='4096' $checked {'IKE_GROUPTYPE'}{'4096'}>MODP-4096</option>
2392 <option value='3072' $checked {'IKE_GROUPTYPE'}{'3072'}>MODP-3072</option>
2393 <option value='2048' $checked {'IKE_GROUPTYPE'}{'2048'}>MODP-2048</option>
2394 <option value='1536' $checked {'IKE_GROUPTYPE'}{'1536'}>MODP-1536</option>
2395 <option value='1024' $checked {'IKE_GROUPTYPE'}{'1024'}>MODP-1024</option>
2396 <option value='768' $checked {'IKE_GROUPTYPE'}{'768'}>MODP-768</option>
2399 <td class='boldbase' align='right' valign='top'> $Lang ::tr{'ike lifetime'}</td><td class='boldbase' valign='top'>
2400 <input type='text' name='IKE_LIFETIME' value=' $cgiparams {'IKE_LIFETIME'}' size='5' /> $Lang ::tr{'hours'}</td>
2403 <td colspan='1'><hr /></td>
2405 <td class='boldbase' align='right' valign='top'> $Lang ::tr{'esp encryption'}</td><td class='boldbase' valign='top'>
2406 <select name='ESP_ENCRYPTION' multiple='multiple' size='4'>
2407 <option value='aes256' $checked {'ESP_ENCRYPTION'}{'aes256'}>AES (256 bit)</option>
2408 <option value='aes128' $checked {'ESP_ENCRYPTION'}{'aes128'}>AES (128 bit)</option>
2409 <option value='3des' $checked {'ESP_ENCRYPTION'}{'3des'}>3DES</option>
2410 <option value='twofish256' $checked {'ESP_ENCRYPTION'}{'twofish256'}>Twofish (256 bit)</option>
2411 <option value='twofish128' $checked {'ESP_ENCRYPTION'}{'twofish128'}>Twofish (128 bit)</option>
2412 <option value='serpent256' $checked {'ESP_ENCRYPTION'}{'serpent256'}>Serpent (256 bit)</option>
2413 <option value='serpent128' $checked {'ESP_ENCRYPTION'}{'serpent128'}>Serpent (128 bit)</option>
2414 <option value='blowfish256' $checked {'ESP_ENCRYPTION'}{'blowfish256'}>Blowfish (256 bit)</option>
2415 <option value='blowfish128' $checked {'ESP_ENCRYPTION'}{'blowfish128'}>Blowfish (128 bit)</option></select></td>
2417 <td class='boldbase' align='right' valign='top'> $Lang ::tr{'esp integrity'}</td><td class='boldbase' valign='top'>
2418 <select name='ESP_INTEGRITY' multiple='multiple' size='4'>
2419 <option value='sha2_512' $checked {'ESP_INTEGRITY'}{'sha2_512'}>SHA2 (512)</option>
2420 <option value='sha2_256' $checked {'ESP_INTEGRITY'}{'sha2_256'}>SHA2 (256)</option>
2421 <option value='sha1' $checked {'ESP_INTEGRITY'}{'sha1'}>SHA1</option>
2422 <option value='md5' $checked {'ESP_INTEGRITY'}{'md5'}>MD5</option></select></td>
2424 <td class='boldbase' align='right' valign='top'> $Lang ::tr{'esp grouptype'}</td><td class='boldbase' valign='top'>
2425 <select name='ESP_GROUPTYPE'>
2426 <option value=''> $Lang ::tr{'phase1 group'}</option>
2427 <option value='modp4096' $checked {'ESP_GROUPTYPE'}{'modp4096'}>MODP-4096</option>
2428 <option value='modp3072' $checked {'ESP_GROUPTYPE'}{'modp3072'}>MODP-3072</option>
2429 <option value='modp2048' $checked {'ESP_GROUPTYPE'}{'modp2048'}>MODP-2048</option>
2430 <option value='modp1536' $checked {'ESP_GROUPTYPE'}{'modp1536'}>MODP-1536</option>
2431 <option value='modp1024' $checked {'ESP_GROUPTYPE'}{'modp1024'}>MODP-1024</option>
2432 <option value='modp768' $checked {'ESP_GROUPTYPE'}{'modp768'}>MODP-768</option></select></td>
2434 <td class='boldbase' align='right' valign='top'> $Lang ::tr{'esp keylife'}</td><td class='boldbase' valign='top'>
2435 <input type='text' name='ESP_KEYLIFE' value=' $cgiparams {'ESP_KEYLIFE'}' size='5' /> $Lang ::tr{'hours'}</td>
2437 <td colspan='1'><hr /></td>
2439 <td colspan='5'><input type='checkbox' name='ONLY_PROPOSED' $checked {'ONLY_PROPOSED'} />
2440 IKE+ESP: $Lang ::tr{'use only proposed settings'}</td>
2442 <td colspan='5'><input type='checkbox' name='AGGRMODE' $checked {'AGGRMODE'} />
2443 $Lang ::tr{'vpn aggrmode'}</td>
2445 <td colspan='5'><input type='checkbox' name='PFS' $checked {'PFS'} />
2446 $Lang ::tr{'pfs yes no'}</td>
2447 <td align='right'><input type='submit' name='ACTION' value=' $Lang ::tr{'save'}' /></td>
2449 <td colspan='5'><input type='checkbox' name='COMPRESSION' $checked {'COMPRESSION'} />
2450 $Lang ::tr{'vpn payload compression'}</td>
2451 <td align='right'><input type='submit' name='ACTION' value=' $Lang ::tr{'cancel'}' /></td>
2455 if ( $confighash { $cgiparams { 'KEY' }}[ 3 ] eq 'net' ) {
2456 print "<tr><td><input type='hidden' name='VHOST' value='off' /></td></tr>" ;
2457 } elsif ( $confighash { $cgiparams { 'KEY' }}[ 10 ]) {
2458 print "<tr><td colspan='5'><input type='checkbox' name='VHOST' $checked {'VHOST'} disabled='disabled' />" ;
2459 print " $Lang ::tr{'vpn vhost'}</td></tr>" ;
2461 print "<tr><td colspan='5'><input type='checkbox' name='VHOST' $checked {'VHOST'} />" ;
2462 print " $Lang ::tr{'vpn vhost'}</td></tr>" ;
2465 print "</table></form>" ;
2466 & Header
:: closebox
();
2467 & Header
:: closebigbox
();
2468 & Header
:: closepage
();
2475 ### Default status page
2480 & General
:: readhash
( "${General::swroot}/vpn/settings" , \
%cgiparams );
2481 & General
:: readhasharray
( "${General::swroot}/vpn/caconfig" , \
%cahash );
2482 & General
:: readhasharray
( "${General::swroot}/vpn/config" , \
%confighash );
2483 $cgiparams { 'CA_NAME' } = '' ;
2485 my @status = `/usr/sbin/ipsec auto --status` ;
2487 # suggest a default name for this side
2488 if ( $cgiparams { 'VPN_IP' } eq '' && - e
"${General::swroot}/red/active" ) {
2489 if ( open ( IPADDR
, "${General::swroot}/red/local-ipaddress" )) {
2490 my $ipaddr = < IPADDR
>;
2493 $cgiparams { 'VPN_IP' } = ( gethostbyaddr ( pack ( "C4" , split ( /\./ , $ipaddr )), 2 ))[ 0 ];
2494 if ( $cgiparams { 'VPN_IP' } eq '' ) {
2495 $cgiparams { 'VPN_IP' } = $ipaddr ;
2499 # no IP found, use %defaultroute
2500 $cgiparams { 'VPN_IP' } = ' %defaultroute ' if ( $cgiparams { 'VPN_IP' } eq '' );
2502 $cgiparams { 'VPN_DELAYED_START' } = 0 if (! defined ( $cgiparams { 'VPN_DELAYED_START' }));
2503 $checked { 'VPN_WATCH' } = $cgiparams { 'VPN_WATCH' } eq 'on' ?
"checked='checked'" : '' ;
2504 map ( $checked { $_ } = $cgiparams { $_ } eq 'on' ?
"checked='checked'" : '' ,
2505 ( 'ENABLED' , 'ENABLED_GREEN' , 'ENABLED_ORANGE' , 'ENABLED_BLUE' , 'DBG_CRYPT' , 'DBG_PARSING' , 'DBG_EMITTING' , 'DBG_CONTROL' ,
2506 'DBG_KLIPS' , 'DBG_DNS' , 'DBG_NAT_T' ));
2509 & Header
:: showhttpheaders
();
2510 & Header
:: openpage
( $Lang :: tr
{ 'vpn configuration main' }, 1 , '' );
2511 & Header
:: openbigbox
( '100%' , 'left' , '' , $errormessage );
2513 if ( $errormessage ) {
2514 & Header
:: openbox
( '100%' , 'left' , $Lang :: tr
{ 'error messages' });
2515 print "<class name='base'> $errormessage \n " ;
2516 print " </class> \n " ;
2517 & Header
:: closebox
();
2520 & Header
:: openbox
( '100%' , 'left' , $Lang :: tr
{ 'global settings' });
2523 <form method='post' action=' $ENV {'SCRIPT_NAME'}'>
2524 <table width='100%'>
2526 <td width='20%' class='base' nowrap='nowrap'> $Lang ::tr{'local vpn hostname/ip'}:</td>
2527 <td width='20%'><input type='text' name='VPN_IP' value=' $cgiparams {'VPN_IP'}' /></td>
2528 <td width='20%' class='base'> $Lang ::tr{'enabled'}<input type='checkbox' name='ENABLED' $checked {'ENABLED'} /></td>
2529 <td width='20%' class='base' nowrap='nowrap'> $Lang ::tr{'vpn on green'}:</td>
2530 <td width='20%' class='base'> $Lang ::tr{'enabled'}<input type='checkbox' name='ENABLED_GREEN' $checked {'ENABLED_GREEN'} /></td>
2534 if ( $netsettings { 'ORANGE_DEV' } ne '' ) {
2536 <td class='base' nowrap='nowrap'> $Lang ::tr{'vpn on orange'}:</td>
2537 <td class='base'> $Lang ::tr{'enabled'}<input type='checkbox' name='ENABLED_ORANGE' $checked {'ENABLED_ORANGE'} /></td>
2543 <td class='base' nowrap='nowrap'> $Lang ::tr{'override mtu'}: <img src='/blob.gif' alt='*' /></td>
2544 <td ><input type='text' name='VPN_OVERRIDE_MTU' value=' $cgiparams {'VPN_OVERRIDE_MTU'}' /></td>
2550 if ( $netsettings { 'BLUE_DEV' } ne '' ) {
2552 <td class='base' nowrap='nowrap'> $Lang ::tr{'vpn on blue'}:</td>
2553 <td class='base'> $Lang ::tr{'enabled'}<input type='checkbox' name='ENABLED_BLUE' $checked {'ENABLED_BLUE'} /></td>
2558 <td class='base' nowrap='nowrap'> $Lang ::tr{'vpn delayed start'}: <img src='/blob.gif' alt='*' /><img src='/blob.gif' alt='*' /></td>
2559 <td ><input type='text' name='VPN_DELAYED_START' value=' $cgiparams {'VPN_DELAYED_START'}' /></td>
2564 <p> $Lang ::tr{'vpn watch'}:<input type='checkbox' name='VPN_WATCH' $checked {'VPN_WATCH'} /></p>
2565 <p>PLUTO DEBUG =
2566 crypt:<input type='checkbox' name='DBG_CRYPT' $checked {'DBG_CRYPT'} />,
2567 parsing:<input type='checkbox' name='DBG_PARSING' $checked {'DBG_PARSING'} />,
2568 emitting:<input type='checkbox' name='DBG_EMITTING' $checked {'DBG_EMITTING'} />,
2569 control:<input type='checkbox' name='DBG_CONTROL' $checked {'DBG_CONTROL'} />,
2570 klips:<input type='checkbox' name='DBG_KLIPS' $checked {'DBG_KLIPS'} />,
2571 dns:<input type='checkbox' name='DBG_DNS' $checked {'DBG_DNS'} />,
2572 nat_t:<input type='checkbox' name='DBG_NAT_T' $checked {'DBG_NAT_T'} /></p>
2575 <table width='100%'>
2577 <td class='base' valign='top'><img src='/blob.gif' alt='*' /></td>
2578 <td width='70%' class='base' valign='top'> $Lang ::tr{'this field may be blank'}</td>
2581 <td class='base' valign='top' nowrap='nowrap'><img src='/blob.gif' alt='*' /><img src='/blob.gif' alt='*' /> </td>
2582 <td class='base'> <font class='base'> $Lang ::tr{'vpn delayed start help'}</font></td>
2583 <td width='30%' align='center' class='base'><input type='submit' name='ACTION' value=' $Lang ::tr{'save'}' /></td>
2589 & Header
:: closebox
();
2592 & Header
:: openbox
( '100%' , 'left' , $Lang :: tr
{ 'connection status and controlc' });
2594 <table width='100%' border='0' cellspacing='1' cellpadding='0'>
2596 <td width='10%' class='boldbase' align='center'><b> $Lang ::tr{'name'}</b></td>
2597 <td width='22%' class='boldbase' align='center'><b> $Lang ::tr{'type'}</b></td>
2598 <td width='23%' class='boldbase' align='center'><b> $Lang ::tr{'common name'}</b></td>
2599 <td width='30%' class='boldbase' align='center'><b> $Lang ::tr{'remark'}</b></td>
2600 <td width='10%' class='boldbase' align='center'><b> $Lang ::tr{'status'}</b></td>
2601 <td class='boldbase' align='center' colspan='6'><b> $Lang ::tr{'action'}</b></td>
2607 foreach my $key ( keys %confighash ) {
2608 if ( $confighash { $key }[ 0 ] eq 'on' ) { $gif = 'on.gif' ; } else { $gif = 'off.gif' ; }
2611 print "<tr bgcolor='${Header::table1colour}'> \n " ;
2613 print "<tr bgcolor='${Header::table2colour}'> \n " ;
2615 print "<td align='center' nowrap='nowrap'> $confighash { $key }[1]</td>" ;
2616 print "<td align='center' nowrap='nowrap'>" . $Lang :: tr
{ " $confighash { $key }[3]" } . " (" . $Lang :: tr
{ " $confighash { $key }[4]" } . ")</td>" ;
2617 if ( $confighash { $key }[ 2 ] eq ' %auth -dn' ) {
2618 print "<td align='left' nowrap='nowrap'> $confighash { $key }[9]</td>" ;
2619 } elsif ( $confighash { $key }[ 4 ] eq 'cert' ) {
2620 print "<td align='left' nowrap='nowrap'> $confighash { $key }[2]</td>" ;
2622 print "<td align='left'> </td>" ;
2624 print "<td align='center'> $confighash { $key }[25]</td>" ;
2625 my $active = "<table cellpadding='2' cellspacing='0' bgcolor='${Header::colourred}' width='100%'><tr><td align='center'><b><font color='#FFFFFF'> $Lang ::tr{'capsclosed'}</font></b></td></tr></table>" ;
2626 if ( $confighash { $key }[ 0 ] eq 'off' ) {
2627 $active = "<table cellpadding='2' cellspacing='0' bgcolor='${Header::colourblue}' width='100%'><tr><td align='center'><b><font color='#FFFFFF'> $Lang ::tr{'capsclosed'}</font></b></td></tr></table>" ;
2629 foreach my $line ( @status ) {
2630 if ( $line =~ /\"$confighash{$key}[1]\".*IPsec SA established/ ) {
2631 $active = "<table cellpadding='2' cellspacing='0' bgcolor='${Header::colourgreen}' width='100%'><tr><td align='center'><b><font color='#FFFFFF'> $Lang ::tr{'capsopen'}</font></b></td></tr></table>" ;
2636 <td align='center'> $active </td>
2638 <form method='post' action=' $ENV {'SCRIPT_NAME'}'>
2639 <input type='image' name=' $Lang ::tr{'restart'}' src='/images/reload.gif' alt=' $Lang ::tr{'restart'}' title=' $Lang ::tr{'restart'}' />
2640 <input type='hidden' name='ACTION' value=' $Lang ::tr{'restart'}' />
2641 <input type='hidden' name='KEY' value=' $key ' />
2646 if (( $confighash { $key }[ 4 ] eq 'cert' ) && ( $confighash { $key }[ 2 ] ne ' %auth -dn' )) {
2649 <form method='post' action=' $ENV {'SCRIPT_NAME'}'>
2650 <input type='image' name=' $Lang ::tr{'show certificate'}' src='/images/info.gif' alt=' $Lang ::tr{'show certificate'}' title=' $Lang ::tr{'show certificate'}' />
2651 <input type='hidden' name='ACTION' value=' $Lang ::tr{'show certificate'}' />
2652 <input type='hidden' name='KEY' value=' $key ' />
2657 print "<td width='2%'> </td>" ;
2659 if ( $confighash { $key }[ 4 ] eq 'cert' && - f
"${General::swroot}/certs/ $confighash { $key }[1].p12" ) {
2662 <form method='post' action=' $ENV {'SCRIPT_NAME'}'>
2663 <input type='image' name=' $Lang ::tr{'download pkcs12 file'}' src='/images/floppy.gif' alt=' $Lang ::tr{'download pkcs12 file'}' title=' $Lang ::tr{'download pkcs12 file'}' />
2664 <input type='hidden' name='ACTION' value=' $Lang ::tr{'download pkcs12 file'}' />
2665 <input type='hidden' name='KEY' value=' $key ' />
2669 ; } elsif (( $confighash { $key }[ 4 ] eq 'cert' ) && ( $confighash { $key }[ 2 ] ne ' %auth -dn' )) {
2672 <form method='post' action=' $ENV {'SCRIPT_NAME'}'>
2673 <input type='image' name=' $Lang ::tr{'download certificate'}' src='/images/floppy.gif' alt=' $Lang ::tr{'download certificate'}' title=' $Lang ::tr{'download certificate'}' />
2674 <input type='hidden' name='ACTION' value=' $Lang ::tr{'download certificate'}' />
2675 <input type='hidden' name='KEY' value=' $key ' />
2680 print "<td width='2%'> </td>" ;
2684 <form method='post' action=' $ENV {'SCRIPT_NAME'}'>
2685 <input type='image' name=' $Lang ::tr{'toggle enable disable'}' src='/images/ $gif ' alt=' $Lang ::tr{'toggle enable disable'}' title=' $Lang ::tr{'toggle enable disable'}' />
2686 <input type='hidden' name='ACTION' value=' $Lang ::tr{'toggle enable disable'}' />
2687 <input type='hidden' name='KEY' value=' $key ' />
2692 <form method='post' action=' $ENV {'SCRIPT_NAME'}'>
2693 <input type='hidden' name='ACTION' value=' $Lang ::tr{'edit'}' />
2694 <input type='image' name=' $Lang ::tr{'edit'}' src='/images/edit.gif' alt=' $Lang ::tr{'edit'}' title=' $Lang ::tr{'edit'}' />
2695 <input type='hidden' name='KEY' value=' $key ' />
2698 <td align='center' >
2699 <form method='post' action=' $ENV {'SCRIPT_NAME'}'>
2700 <input type='hidden' name='ACTION' value=' $Lang ::tr{'remove'}' />
2701 <input type='image' name=' $Lang ::tr{'remove'}' src='/images/delete.gif' alt=' $Lang ::tr{'remove'}' title=' $Lang ::tr{'remove'}' />
2702 <input type='hidden' name='KEY' value=' $key ' />
2712 # If the config file contains entries, print Key to action icons
2717 <td class='boldbase'> <b> $Lang ::tr{'legend'}:</b></td>
2718 <td> <img src='/images/on.gif' alt=' $Lang ::tr{'click to disable'}' /></td>
2719 <td class='base'> $Lang ::tr{'click to disable'}</td>
2720 <td> <img src='/images/info.gif' alt=' $Lang ::tr{'show certificate'}' /></td>
2721 <td class='base'> $Lang ::tr{'show certificate'}</td>
2722 <td> <img src='/images/edit.gif' alt=' $Lang ::tr{'edit'}' /></td>
2723 <td class='base'> $Lang ::tr{'edit'}</td>
2724 <td> <img src='/images/delete.gif' alt=' $Lang ::tr{'remove'}' /></td>
2725 <td class='base'> $Lang ::tr{'remove'}</td>
2729 <td> <img src='/images/off.gif' alt='?OFF' /></td>
2730 <td class='base'> $Lang ::tr{'click to enable'}</td>
2731 <td> <img src='/images/floppy.gif' alt='?FLOPPY' /></td>
2732 <td class='base'> $Lang ::tr{'download certificate'}</td>
2733 <td> <img src='/images/reload.gif' alt='?RELOAD'/></td>
2734 <td class='base'> $Lang ::tr{'restart'}</td>
2742 <table width='100%'>
2743 <tr><td align='center' colspan='9'>
2744 <form method='post' action=' $ENV {'SCRIPT_NAME'}'>
2745 <input type='submit' name='ACTION' value=' $Lang ::tr{'add'}' />
2751 & Header
:: closebox
();
2753 & Header
:: openbox
( '100%' , 'left' , " $Lang ::tr{'certificate authorities'}:" );
2755 <table width='100%' border='0' cellspacing='1' cellpadding='0'>
2757 <td width='25%' class='boldbase' align='center'><b> $Lang ::tr{'name'}</b></td>
2758 <td width='65%' class='boldbase' align='center'><b> $Lang ::tr{'subject'}</b></td>
2759 <td width='10%' class='boldbase' colspan='3' align='center'><b> $Lang ::tr{'action'}</b></td>
2763 if (- f
"${General::swroot}/ca/cacert.pem" ) {
2764 my $casubject = & Header
:: cleanhtml
( getsubjectfromcert
( "${General::swroot}/ca/cacert.pem" ));
2767 <tr bgcolor='${Header::table2colour}'>
2768 <td class='base'> $Lang ::tr{'root certificate'}</td>
2769 <td class='base'> $casubject </td>
2770 <td width='3%' align='center'>
2771 <form method='post' action=' $ENV {'SCRIPT_NAME'}'>
2772 <input type='hidden' name='ACTION' value=' $Lang ::tr{'show root certificate'}' />
2773 <input type='image' name=' $Lang ::tr{'edit'}' src='/images/info.gif' alt=' $Lang ::tr{'show root certificate'}' title=' $Lang ::tr{'show root certificate'}' />
2776 <td width='3%' align='center'>
2777 <form method='post' action=' $ENV {'SCRIPT_NAME'}'>
2778 <input type='image' name=' $Lang ::tr{'download root certificate'}' src='/images/floppy.gif' alt=' $Lang ::tr{'download root certificate'}' title=' $Lang ::tr{'download root certificate'}' />
2779 <input type='hidden' name='ACTION' value=' $Lang ::tr{'download root certificate'}' />
2782 <td width='4%'> </td></tr>
2786 # display rootcert generation buttons
2788 <tr bgcolor='${Header::table2colour}'>
2789 <td class='base'> $Lang ::tr{'root certificate'}:</td>
2790 <td class='base'> $Lang ::tr{'not present'}</td>
2791 <td colspan='3'> </td></tr>
2796 if (- f
"${General::swroot}/certs/hostcert.pem" ) {
2797 my $hostsubject = & Header
:: cleanhtml
( getsubjectfromcert
( "${General::swroot}/certs/hostcert.pem" ));
2800 <tr bgcolor='${Header::table1colour}'>
2801 <td class='base'> $Lang ::tr{'host certificate'}</td>
2802 <td class='base'> $hostsubject </td>
2803 <td width='3%' align='center'>
2804 <form method='post' action=' $ENV {'SCRIPT_NAME'}'>
2805 <input type='hidden' name='ACTION' value=' $Lang ::tr{'show host certificate'}' />
2806 <input type='image' name=' $Lang ::tr{'show host certificate'}' src='/images/info.gif' alt=' $Lang ::tr{'show host certificate'}' title=' $Lang ::tr{'show host certificate'}' />
2809 <td width='3%' align='center'>
2810 <form method='post' action=' $ENV {'SCRIPT_NAME'}'>
2811 <input type='image' name=' $Lang ::tr{'download host certificate'}' src='/images/floppy.gif' alt=' $Lang ::tr{'download host certificate'}' title=' $Lang ::tr{'download host certificate'}' />
2812 <input type='hidden' name='ACTION' value=' $Lang ::tr{'download host certificate'}' />
2815 <td width='4%'> </td></tr>
2821 <tr bgcolor='${Header::table1colour}'>
2822 <td width='25%' class='base'> $Lang ::tr{'host certificate'}:</td>
2823 <td class='base'> $Lang ::tr{'not present'}</td>
2824 <td colspan='3'> </td></tr>
2829 if ( keys %cahash > 0 ) {
2830 foreach my $key ( keys %cahash ) {
2831 if (( $key + 1 ) % 2 ) {
2832 print "<tr bgcolor='${Header::table1colour}'> \n " ;
2834 print "<tr bgcolor='${Header::table2colour}'> \n " ;
2836 print "<td class='base'> $cahash { $key }[0]</td> \n " ;
2837 print "<td class='base'> $cahash { $key }[1]</td> \n " ;
2840 <form method='post' name='cafrm${key}a' action=' $ENV {'SCRIPT_NAME'}'>
2841 <input type='image' name=' $Lang ::tr{'show ca certificate'}' src='/images/info.gif' alt=' $Lang ::tr{'show ca certificate'}' title=' $Lang ::tr{'show ca certificate'}' />
2842 <input type='hidden' name='ACTION' value=' $Lang ::tr{'show ca certificate'}' />
2843 <input type='hidden' name='KEY' value=' $key ' />
2847 <form method='post' name='cafrm${key}b' action=' $ENV {'SCRIPT_NAME'}'>
2848 <input type='image' name=' $Lang ::tr{'download ca certificate'}' src='/images/floppy.gif' alt=' $Lang ::tr{'download ca certificate'}' title=' $Lang ::tr{'download ca certificate'}' />
2849 <input type='hidden' name='ACTION' value=' $Lang ::tr{'download ca certificate'}' />
2850 <input type='hidden' name='KEY' value=' $key ' />
2854 <form method='post' name='cafrm${key}c' action=' $ENV {'SCRIPT_NAME'}'>
2855 <input type='hidden' name='ACTION' value=' $Lang ::tr{'remove ca certificate'}' />
2856 <input type='image' name=' $Lang ::tr{'remove ca certificate'}' src='/images/delete.gif' alt=' $Lang ::tr{'remove ca certificate'}' title=' $Lang ::tr{'remove ca certificate'}' />
2857 <input type='hidden' name='KEY' value=' $key ' />
2867 # If the file contains entries, print Key to action icons
2868 if ( - f
"${General::swroot}/ca/cacert.pem" ) {
2871 <td class='boldbase'> <b> $Lang ::tr{'legend'}:</b></td>
2872 <td> <img src='/images/info.gif' alt=' $Lang ::tr{'show certificate'}' /></td>
2873 <td class='base'> $Lang ::tr{'show certificate'}</td>
2874 <td> <img src='/images/floppy.gif' alt=' $Lang ::tr{'download certificate'}' /></td>
2875 <td class='base'> $Lang ::tr{'download certificate'}</td>
2880 my $createCA = - f
"${General::swroot}/ca/cacert.pem" ?
'' : "<tr><td colspan='3'></td><td><input type='submit' name='ACTION' value=' $Lang ::tr{'generate root/host certificates'}' /></td></tr>" ;
2883 <form method='post' enctype='multipart/form-data' action=' $ENV {'SCRIPT_NAME'}'>
2884 <table width='100%' border='0' cellspacing='1' cellpadding='0'>
2887 <td class='base' nowrap='nowrap'> $Lang ::tr{'ca name'}:</td>
2888 <td nowrap='nowrap'><input type='text' name='CA_NAME' value=' $cgiparams {'CA_NAME'}' size='15' /> </td>
2889 <td nowrap='nowrap'><input type='file' name='FH' size='30' /></td>
2890 <td nowrap='nowrap'><input type='submit' name='ACTION' value=' $Lang ::tr{'upload ca certificate'}' /></td>
2893 <td colspan='3'> $Lang ::tr{'resetting the vpn configuration will remove the root ca, the host certificate and all certificate based connections'}:</td>
2894 <td><input type='submit' name='ACTION' value=' $Lang ::tr{'remove x509'}' /></td>
2900 & Header
:: closebox
();
2902 print " $Lang ::tr{'this feature has been sponsored by'} : " ;
2903 print "<a href='http://www.seminolegas.com/' target='_blank'>Seminole Canada Gas Company</a>. \n " ;
2905 & Header
:: closebigbox
();
2906 & Header
:: closepage
();