]>
git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blob - html/cgi-bin/vpnmain.cgi
2 ###############################################################################
4 # IPFire.org - A linux based firewall #
5 # Copyright (C) 2007-2011 IPFire Team info@ipfire.org #
7 # This program is free software: you can redistribute it and/or modify #
8 # it under the terms of the GNU General Public License as published by #
9 # the Free Software Foundation, either version 3 of the License, or #
10 # (at your option) any later version. #
12 # This program is distributed in the hope that it will be useful, #
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of #
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
15 # GNU General Public License for more details. #
17 # You should have received a copy of the GNU General Public License #
18 # along with this program. If not, see <http://www.gnu.org/licenses/>. #
20 ###############################################################################
24 use File
:: Temp qw
/ tempfile tempdir / ;
27 # enable only the following on debugging purpose
29 #use CGI::Carp 'fatalsToBrowser';
31 require '/var/ipfire/general-functions.pl' ;
32 require "${General::swroot}/lang.pl" ;
33 require "${General::swroot}/header.pl" ;
34 require "${General::swroot}/countries.pl" ;
36 #workaround to suppress a warning when a variable is used only once
37 my @dummy = ( ${ Header
:: colourgreen
}, ${ Header
:: colourblue
} );
41 ### Initialize variables
43 my $sleepDelay = 4 ; # after a call to ipsecctrl S or R, wait this delay (seconds) before reading status
44 # (let the ipsec do its job)
53 my $errormessage = '' ;
56 my %mainsettings = ();
57 & General
:: readhash
( "${General::swroot}/main/settings" , \
%mainsettings );
58 & General
:: readhash
( "/srv/web/ipfire/html/themes/" . $mainsettings { 'THEME' }. "/include/colors.txt" , \
%color );
60 & General
:: readhash
( "${General::swroot}/ethernet/settings" , \
%netsettings );
62 my $green_cidr = & General
:: ipcidr
( " $netsettings {'GREEN_NETADDRESS'}/ $netsettings {'GREEN_NETMASK'}" );
63 my $blue_cidr = "# Blue not defined" ;
64 if ( $netsettings { 'BLUE_DEV' }) {
65 $blue_cidr = & General
:: ipcidr
( " $netsettings {'BLUE_NETADDRESS'}/ $netsettings {'BLUE_NETMASK'}" );
67 my $orange_cidr = "# Orange not defined" ;
68 if ( $netsettings { 'ORANGE_DEV' }) {
69 $orange_cidr = & General
:: ipcidr
( " $netsettings {'ORANGE_NETADDRESS'}/ $netsettings {'ORANGE_NETMASK'}" );
72 $cgiparams { 'ENABLED' } = 'off' ;
73 $cgiparams { 'EDIT_ADVANCED' } = 'off' ;
74 $cgiparams { 'ACTION' } = '' ;
75 $cgiparams { 'CA_NAME' } = '' ;
76 $cgiparams { 'DBG_CRYPT' } = '' ;
77 $cgiparams { 'DBG_PARSING' } = '' ;
78 $cgiparams { 'DBG_EMITTING' } = '' ;
79 $cgiparams { 'DBG_CONTROL' } = '' ;
80 $cgiparams { 'DBG_KLIPS' } = '' ;
81 $cgiparams { 'DBG_DNS' } = '' ;
82 $cgiparams { 'DBG_NAT_T' } = '' ;
83 $cgiparams { 'KEY' } = '' ;
84 $cgiparams { 'TYPE' } = '' ;
85 $cgiparams { 'ADVANCED' } = '' ;
86 $cgiparams { 'INTERFACE' } = '' ;
87 $cgiparams { 'NAME' } = '' ;
88 $cgiparams { 'LOCAL_SUBNET' } = '' ;
89 $cgiparams { 'REMOTE_SUBNET' } = '' ;
90 $cgiparams { 'REMOTE' } = '' ;
91 $cgiparams { 'LOCAL_ID' } = '' ;
92 $cgiparams { 'REMOTE_ID' } = '' ;
93 $cgiparams { 'REMARK' } = '' ;
94 $cgiparams { 'PSK' } = '' ;
95 $cgiparams { 'CERT_NAME' } = '' ;
96 $cgiparams { 'CERT_EMAIL' } = '' ;
97 $cgiparams { 'CERT_OU' } = '' ;
98 $cgiparams { 'CERT_ORGANIZATION' } = '' ;
99 $cgiparams { 'CERT_CITY' } = '' ;
100 $cgiparams { 'CERT_STATE' } = '' ;
101 $cgiparams { 'CERT_COUNTRY' } = '' ;
102 $cgiparams { 'SUBJECTALTNAME' } = '' ;
103 $cgiparams { 'CERT_PASS1' } = '' ;
104 $cgiparams { 'CERT_PASS2' } = '' ;
105 $cgiparams { 'ROOTCERT_HOSTNAME' } = '' ;
106 $cgiparams { 'ROOTCERT_COUNTRY' } = '' ;
107 $cgiparams { 'P12_PASS' } = '' ;
108 $cgiparams { 'ROOTCERT_ORGANIZATION' } = '' ;
109 $cgiparams { 'ROOTCERT_HOSTNAME' } = '' ;
110 $cgiparams { 'ROOTCERT_EMAIL' } = '' ;
111 $cgiparams { 'ROOTCERT_OU' } = '' ;
112 $cgiparams { 'ROOTCERT_CITY' } = '' ;
113 $cgiparams { 'ROOTCERT_STATE' } = '' ;
115 & Header
:: getcgihash
( \
%cgiparams , { 'wantfile' => 1 , 'filevar' => 'FH' });
121 my $hostname = $_ [ 0 ];
122 unless ( $hostname ) { return "No hostname" };
123 my $res = new Net
:: DNS
:: Resolver
;
124 my $query = $res -> search ( " $hostname " );
126 foreach my $rr ( $query -> answer ) {
127 ## Potential bug - we are only looking at A records:
128 return 0 if $rr -> type eq "A" ;
131 return $res -> errorstring ;
135 ### Just return true is one interface is vpn enabled
138 return ( $vpnsettings { 'ENABLED' } eq 'on' );
141 ### old version: maintain serial number to one, without explication.
142 ### this : let the counter go, so that each cert is numbered.
146 if ( open ( FILE
, ">${General::swroot}/certs/serial" )) {
150 if ( open ( FILE
, ">${General::swroot}/certs/index.txt" )) {
154 unlink ( "${General::swroot}/certs/index.txt.old" );
155 unlink ( "${General::swroot}/certs/serial.old" );
156 unlink ( "${General::swroot}/certs/01.pem" );
158 sub newcleanssldatabase
160 if (! - s
"${General::swroot}/certs/serial" ) {
161 open ( FILE
, ">${General::swroot}/certs/serial" );
165 if (! - s
">${General::swroot}/certs/index.txt" ) {
166 system ( "touch ${General::swroot}/certs/index.txt" );
168 unlink ( "${General::swroot}/certs/index.txt.old" );
169 unlink ( "${General::swroot}/certs/serial.old" );
170 # unlink ("${General::swroot}/certs/01.pem"); numbering evolves. Wrong place to delete
174 ### Call openssl and return errormessage if any
178 my $retssl = `/usr/bin/openssl $opt 2>&1` ; #redirect stderr
180 foreach my $line ( split ( /\n/ , $retssl )) {
181 & General
:: log ( "ipsec" , " $line " ) if ( 0 ); # 1 for verbose logging
182 $ret .= '<br>' . $line if ( $line =~ /error|unknown/ );
185 $ret = & Header
:: cleanhtml
( $ret );
187 return $ret ?
" $Lang ::tr{'openssl produced an error'}: $ret " : '' ;
190 ### Obtain a CN from given cert
192 sub getCNfromcert
($) {
193 #&General::log("ipsec", "Extracting name from $_[0]...");
194 my $temp = `/usr/bin/openssl x509 -text -in $_ [0]` ;
195 $temp =~ /Subject:.*CN=(.*)[\n]/ ;
197 $temp =~ s
+/ Email
+, E
+;
198 $temp =~ s/ ST=/ S=/ ;
204 ### Obtain Subject from given cert
206 sub getsubjectfromcert
($) {
207 #&General::log("ipsec", "Extracting subject from $_[0]...");
208 my $temp = `/usr/bin/openssl x509 -text -in $_ [0]` ;
209 $temp =~ /Subject: (.*)[\n]/ ;
211 $temp =~ s
+/ Email
+, E
+;
212 $temp =~ s/ ST=/ S=/ ;
216 ### Combine local subnet and connection name to make a unique name for each connection section
217 ### (this sub is not used now)
219 sub makeconnname
($) {
223 $subnet =~ /^(.*?)\/ (.* ?
)$/; # $1=IP $2=mask
224 my $ip = unpack ( 'N' , & Socket
:: inet_aton
( $1 ));
225 if ( length ( $2 ) > 2 ) {
226 my $mm = unpack ( 'N' , & Socket
:: inet_aton
( $2 ));
227 while ( ( $mm & 1 )== 0 ) {
234 return sprintf ( " %s - %X " , $conn , $ip );
237 ### Write a config file.
239 ###Type=Host : GUI can choose the interface used (RED,GREEN,BLUE) and
240 ### the side is always defined as 'left'.
241 ### configihash[14]: 'VHOST' is allowed
244 sub writeipsecfiles
{
245 my %lconfighash = ();
246 my %lvpnsettings = ();
247 & General
:: readhasharray
( "${General::swroot}/vpn/config" , \
%lconfighash );
248 & General
:: readhash
( "${General::swroot}/vpn/settings" , \
%lvpnsettings );
250 open ( CONF
, ">${General::swroot}/vpn/ipsec.conf" ) or die "Unable to open ${General::swroot}/vpn/ipsec.conf: $!" ;
251 open ( SECRETS
, ">${General::swroot}/vpn/ipsec.secrets" ) or die "Unable to open ${General::swroot}/vpn/ipsec.secrets: $!" ;
254 print CONF
"version 2 \n\n " ;
255 print CONF
"config setup \n " ;
256 #create an ipsec Interface for each 'enabled' ones
257 #loop trought configuration and add physical interfaces to the list
258 my $interfaces = " \t interfaces= \" " ;
259 foreach my $key ( keys %lconfighash ) {
260 next if ( $lconfighash { $key }[ 0 ] ne 'on' );
261 $interfaces .= " %defaultroute " if ( $interfaces !~ /defaultroute/ && $lconfighash { $key }[ 26 ] eq 'RED' );
262 $interfaces .= " $netsettings {'GREEN_DEV'} " if ( $interfaces !~ /ipsec1/ && $lconfighash { $key }[ 26 ] eq 'GREEN' );
263 $interfaces .= " $netsettings {'BLUE_DEV'} " if ( $interfaces !~ /ipsec2/ && $lconfighash { $key }[ 26 ] eq 'BLUE' );
264 $interfaces .= " $netsettings {'ORANGE_DEV'} " if ( $interfaces !~ /ipsec3/ && $lconfighash { $key }[ 26 ] eq 'ORANGE' );
266 print CONF
$interfaces . " \"\n " ;
268 my $plutodebug = '' ; # build debug list
269 map ( $plutodebug .= $lvpnsettings { $_ } eq 'on' ?
lc ( substr ( $_ , 4 )). ' ' : '' ,
270 ( 'DBG_CRYPT' , 'DBG_PARSING' , 'DBG_EMITTING' , 'DBG_CONTROL' ,
272 $plutodebug = 'none' if $plutodebug eq '' ; # if nothing selected, use 'none'.
273 #print CONF "\tklipsdebug=\"none\"\n";
274 print CONF
" \t plutodebug= \" $plutodebug \"\n " ;
275 # deprecated in ipsec.conf version 2
276 #print CONF "\tplutoload=%search\n";
277 #print CONF "\tplutostart=%search\n";
278 print CONF
" \t uniqueids=yes \n " ;
279 print CONF
" \t nat_traversal=yes \n " ;
280 print CONF
" \t overridemtu= $lvpnsettings {'VPN_OVERRIDE_MTU'} \n " if ( $lvpnsettings { 'VPN_OVERRIDE_MTU' } ne '' );
281 print CONF
" \t virtual_private= %v4 :10.0.0.0/8, %v4 :172.16.0.0/12, %v4 :192.168.0.0/16" ;
282 print CONF
", %v4 :! $green_cidr " ;
283 if ( length ( $netsettings { 'ORANGE_DEV' }) > 2 ) {
284 print CONF
", %v4 :! $orange_cidr " ;
286 if ( length ( $netsettings { 'BLUE_DEV' }) > 2 ) {
287 print CONF
", %v4 :! $blue_cidr " ;
289 foreach my $key ( keys %lconfighash ) {
290 if ( $lconfighash { $key }[ 3 ] eq 'net' ) {
291 print CONF
", %v4 :! $lconfighash { $key }[11]" ;
295 print CONF
"conn %default \n " ;
296 print CONF
" \t keyingtries=0 \n " ;
297 #strongswan doesn't know this
298 #print CONF "\tdisablearrivalcheck=no\n";
301 # Add user includes to config file
302 print CONF
"include /etc/ipsec.user.conf \n " ;
305 print SECRETS
"include /etc/ipsec.user.secrets \n " ;
307 if (- f
"${General::swroot}/certs/hostkey.pem" ) {
308 print SECRETS
": RSA ${General::swroot}/certs/hostkey.pem \n "
310 my $last_secrets = '' ; # old the less specifics connections
312 foreach my $key ( keys %lconfighash ) {
313 next if ( $lconfighash { $key }[ 0 ] ne 'on' );
315 #remote peer is not set? => use '%any'
316 $lconfighash { $key }[ 10 ] = ' %any ' if ( $lconfighash { $key }[ 10 ] eq '' );
319 if ( $lconfighash { $key }[ 26 ] eq 'BLUE' ) {
320 $localside = $netsettings { 'BLUE_ADDRESS' };
321 } elsif ( $lconfighash { $key }[ 26 ] eq 'GREEN' ) {
322 $localside = $netsettings { 'GREEN_ADDRESS' };
323 } elsif ( $lconfighash { $key }[ 26 ] eq 'ORANGE' ) {
324 $localside = $netsettings { 'ORANGE_ADDRESS' };
326 $localside = $lvpnsettings { 'VPN_IP' };
329 print CONF
"conn $lconfighash { $key }[1] \n " ;
330 print CONF
" \t left= $localside \n " ;
331 print CONF
" \t leftnexthop= %defaultroute \n " if ( $lconfighash { $key }[ 26 ] eq 'RED' && $lvpnsettings { 'VPN_IP' } ne ' %defaultroute ' );
332 my $cidr_net =& General
:: ipcidr
( $lconfighash { $key }[ 8 ]);
333 print CONF
" \t leftsubnet= $cidr_net \n " ;
334 print CONF
" \t leftfirewall=yes \n " ;
335 print CONF
" \t lefthostaccess=yes \n " ;
337 print CONF
" \t right= $lconfighash { $key }[10] \n " ;
338 if ( $lconfighash { $key }[ 3 ] eq 'net' ) {
339 my $cidr_net =& General
:: ipcidr
( $lconfighash { $key }[ 11 ]);
340 print CONF
" \t rightsubnet= $cidr_net \n " ;
341 print CONF
" \t rightnexthop= %defaultroute \n " ;
342 } elsif ( $lconfighash { $key }[ 10 ] eq ' %any ' && $lconfighash { $key }[ 14 ] eq 'on' ) { #vhost allowed for roadwarriors?
343 print CONF
" \t rightsubnet=vhost: %no , %priv \n " ;
346 # Local Cert and Remote Cert (unless auth is DN dn-auth)
347 if ( $lconfighash { $key }[ 4 ] eq 'cert' ) {
348 print CONF
" \t leftcert=${General::swroot}/certs/hostcert.pem \n " ;
349 print CONF
" \t rightcert=${General::swroot}/certs/ $lconfighash { $key }[1]cert.pem \n " if ( $lconfighash { $key }[ 2 ] ne ' %auth -dn' );
352 # Local and Remote IDs
353 print CONF
" \t leftid= \" $lconfighash { $key }[7] \"\n " if ( $lconfighash { $key }[ 7 ]);
354 print CONF
" \t rightid= \" $lconfighash { $key }[9] \"\n " if ( $lconfighash { $key }[ 9 ]);
357 if ( $lconfighash { $key }[ 18 ] && $lconfighash { $key }[ 19 ] && $lconfighash { $key }[ 20 ]) {
359 my @encs = split ( '\|' , $lconfighash { $key }[ 18 ]);
360 my @ints = split ( '\|' , $lconfighash { $key }[ 19 ]);
361 my @groups = split ( '\|' , $lconfighash { $key }[ 20 ]);
363 foreach my $i ( @encs ) {
364 foreach my $j ( @ints ) {
365 foreach my $k ( @groups ) {
366 if ( $comma != 0 ) { print CONF
"," ; } else { $comma = 1 ; }
367 print CONF
" $i - $j -modp $k " ;
371 if ( $lconfighash { $key }[ 24 ] eq 'on' ) { #only proposed algorythms?
377 if ( $lconfighash { $key }[ 21 ] && $lconfighash { $key }[ 22 ]) {
379 my @encs = split ( '\|' , $lconfighash { $key }[ 21 ]);
380 my @ints = split ( '\|' , $lconfighash { $key }[ 22 ]);
382 foreach my $i ( @encs ) {
383 foreach my $j ( @ints ) {
384 if ( $comma != 0 ) { print CONF
"," ; } else { $comma = 1 ; }
388 if ( $lconfighash { $key }[ 24 ] eq 'on' ) { #only proposed algorythms?
394 if ( $lconfighash { $key }[ 23 ]) {
395 print CONF
" \t pfsgroup= $lconfighash { $key }[23] \n " ;
399 print CONF
" \t keyexchange=ikev1 \n " ;
402 print CONF
" \t ikelifetime= $lconfighash { $key }[16]h \n " if ( $lconfighash { $key }[ 16 ]);
403 print CONF
" \t keylife= $lconfighash { $key }[17]h \n " if ( $lconfighash { $key }[ 17 ]);
406 print CONF
" \t compress=yes \n " if ( $lconfighash { $key }[ 13 ] eq 'on' );
408 # Dead Peer Detection
409 print CONF
" \t dpddelay=30 \n " ;
410 print CONF
" \t dpdtimeout=120 \n " ;
411 print CONF
" \t dpdaction= $lconfighash { $key }[27] \n " ;
414 print CONF
" \t pfs=" . ( $lconfighash { $key }[ 28 ] eq 'on' ?
"yes \n " : "no \n " );
416 # Build Authentication details: LEFTid RIGHTid : PSK psk
418 if ( $lconfighash { $key }[ 4 ] eq 'psk' ) {
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' , 'DBG_CRYPT' , 'DBG_PARSING' , 'DBG_EMITTING' , 'DBG_CONTROL' ,
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 );
603 system ( '/usr/local/bin/ipsecctrl' , 'R' );
609 ### Display ca certificate
611 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'show ca certificate' }) {
612 & General
:: readhasharray
( "${General::swroot}/vpn/caconfig" , \
%cahash );
614 if ( - f
"${General::swroot}/ca/ $cahash { $cgiparams {'KEY'}}[0]cert.pem" ) {
615 & Header
:: showhttpheaders
();
616 & Header
:: openpage
( $Lang :: tr
{ 'vpn configuration main' }, 1 , '' );
617 & Header
:: openbigbox
( '100%' , 'left' , '' , '' );
618 & Header
:: openbox
( '100%' , 'left' , " $Lang ::tr{'ca certificate'}:" );
619 my $output = `/usr/bin/openssl x509 -text -in ${General::swroot}/ca/ $cahash { $cgiparams {'KEY'}}[0]cert.pem` ;
620 $output = & Header
:: cleanhtml
( $output , "y" );
621 print "<pre> $output </pre> \n " ;
623 print "<div align='center'><a href='/cgi-bin/vpnmain.cgi'> $Lang ::tr{'back'}</a></div>" ;
624 & Header
:: closebigbox
();
625 & Header
:: closepage
();
628 $errormessage = $Lang :: tr
{ 'invalid key' };
632 ### Export ca certificate to browser
634 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'download ca certificate' }) {
635 & General
:: readhasharray
( "${General::swroot}/vpn/caconfig" , \
%cahash );
637 if ( - f
"${General::swroot}/ca/ $cahash { $cgiparams {'KEY'}}[0]cert.pem" ) {
638 print "Content-Type: application/force-download \n " ;
639 print "Content-Type: application/octet-stream \r\n " ;
640 print "Content-Disposition: attachment; filename= $cahash { $cgiparams {'KEY'}}[0]cert.pem \r\n\r\n " ;
641 print `/usr/bin/openssl x509 -in ${General::swroot}/ca/ $cahash { $cgiparams {'KEY'}}[0]cert.pem` ;
644 $errormessage = $Lang :: tr
{ 'invalid key' };
648 ### Remove ca certificate (step 2)
650 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'remove ca certificate' } && $cgiparams { 'AREUSURE' } eq 'yes' ) {
651 & General
:: readhasharray
( "${General::swroot}/vpn/config" , \
%confighash );
652 & General
:: readhasharray
( "${General::swroot}/vpn/caconfig" , \
%cahash );
654 if ( - f
"${General::swroot}/ca/ $cahash { $cgiparams {'KEY'}}[0]cert.pem" ) {
655 foreach my $key ( keys %confighash ) {
656 my $test = `/usr/bin/openssl verify -CAfile ${General::swroot}/ca/ $cahash { $cgiparams {'KEY'}}[0]cert.pem ${General::swroot}/certs/ $confighash { $key }[1]cert.pem` ;
657 if ( $test =~ /: OK/ ) {
659 system ( '/usr/local/bin/ipsecctrl' , 'D' , $key ) if (& vpnenabled
);
660 unlink ( "${General::swroot}/certs/ $confighash { $key }[1]cert.pem" );
661 unlink ( "${General::swroot}/certs/ $confighash { $key }[1].p12" );
662 delete $confighash { $key };
663 & General
:: writehasharray
( "${General::swroot}/vpn/config" , \
%confighash );
667 unlink ( "${General::swroot}/ca/ $cahash { $cgiparams {'KEY'}}[0]cert.pem" );
668 delete $cahash { $cgiparams { 'KEY' }};
669 & General
:: writehasharray
( "${General::swroot}/vpn/caconfig" , \
%cahash );
670 system ( '/usr/local/bin/ipsecctrl' , 'R' );
673 $errormessage = $Lang :: tr
{ 'invalid key' };
676 ### Remove ca certificate (step 1)
678 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'remove ca certificate' }) {
679 & General
:: readhasharray
( "${General::swroot}/vpn/config" , \
%confighash );
680 & General
:: readhasharray
( "${General::swroot}/vpn/caconfig" , \
%cahash );
682 my $assignedcerts = 0 ;
683 if ( - f
"${General::swroot}/ca/ $cahash { $cgiparams {'KEY'}}[0]cert.pem" ) {
684 foreach my $key ( keys %confighash ) {
685 my $test = `/usr/bin/openssl verify -CAfile ${General::swroot}/ca/ $cahash { $cgiparams {'KEY'}}[0]cert.pem ${General::swroot}/certs/ $confighash { $key }[1]cert.pem` ;
686 if ( $test =~ /: OK/ ) {
690 if ( $assignedcerts ) {
691 & Header
:: showhttpheaders
();
692 & Header
:: openpage
( $Lang :: tr
{ 'vpn configuration main' }, 1 , '' );
693 & Header
:: openbigbox
( '100%' , 'left' , '' , '' );
694 & Header
:: openbox
( '100%' , 'left' , $Lang :: tr
{ 'are you sure' });
696 <form method='post' action=' $ENV {'SCRIPT_NAME'}'>
700 <input type='hidden' name='KEY' value=' $cgiparams {'KEY'}' />
701 <input type='hidden' name='AREUSURE' value='yes' /></td>
704 <b><font color='${Header::colourred}'> $Lang ::tr{'capswarning'}</font></b>
705 $Lang ::tr{'connections are associated with this ca. deleting the ca will delete these connections as well.'}</td>
708 <input type='submit' name='ACTION' value=' $Lang ::tr{'remove ca certificate'}' />
709 <input type='submit' name='ACTION' value=' $Lang ::tr{'cancel'}' /></td>
716 & Header
:: closebigbox
();
717 & Header
:: closepage
();
720 unlink ( "${General::swroot}/ca/ $cahash { $cgiparams {'KEY'}}[0]cert.pem" );
721 delete $cahash { $cgiparams { 'KEY' }};
722 & General
:: writehasharray
( "${General::swroot}/vpn/caconfig" , \
%cahash );
723 system ( '/usr/local/bin/ipsecctrl' , 'R' );
727 $errormessage = $Lang :: tr
{ 'invalid key' };
731 ### Display root certificate
733 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'show root certificate' } ||
734 $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'show host certificate' }) {
736 & Header
:: showhttpheaders
();
737 & Header
:: openpage
( $Lang :: tr
{ 'vpn configuration main' }, 1 , '' );
738 & Header
:: openbigbox
( '100%' , 'left' , '' , '' );
739 if ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'show root certificate' }) {
740 & Header
:: openbox
( '100%' , 'left' , " $Lang ::tr{'root certificate'}:" );
741 $output = `/usr/bin/openssl x509 -text -in ${General::swroot}/ca/cacert.pem` ;
743 & Header
:: openbox
( '100%' , 'left' , " $Lang ::tr{'host certificate'}:" );
744 $output = `/usr/bin/openssl x509 -text -in ${General::swroot}/certs/hostcert.pem` ;
746 $output = & Header
:: cleanhtml
( $output , "y" );
747 print "<pre> $output </pre> \n " ;
749 print "<div align='center'><a href='/cgi-bin/vpnmain.cgi'> $Lang ::tr{'back'}</a></div>" ;
750 & Header
:: closebigbox
();
751 & Header
:: closepage
();
755 ### Export root certificate to browser
757 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'download root certificate' }) {
758 if ( - f
"${General::swroot}/ca/cacert.pem" ) {
759 print "Content-Type: application/force-download \n " ;
760 print "Content-Disposition: attachment; filename=cacert.pem \r\n\r\n " ;
761 print `/usr/bin/openssl x509 -in ${General::swroot}/ca/cacert.pem` ;
765 ### Export host certificate to browser
767 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'download host certificate' }) {
768 if ( - f
"${General::swroot}/certs/hostcert.pem" ) {
769 print "Content-Type: application/force-download \n " ;
770 print "Content-Disposition: attachment; filename=hostcert.pem \r\n\r\n " ;
771 print `/usr/bin/openssl x509 -in ${General::swroot}/certs/hostcert.pem` ;
775 ### Form for generating/importing the caroot+host certificate
777 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'generate root/host certificates' } ||
778 $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'upload p12 file' }) {
780 if (- f
"${General::swroot}/ca/cacert.pem" ) {
781 $errormessage = $Lang :: tr
{ 'valid root certificate already exists' };
785 & General
:: readhash
( "${General::swroot}/vpn/settings" , \
%vpnsettings );
786 # fill in initial values
787 if ( $cgiparams { 'ROOTCERT_HOSTNAME' } eq '' ) {
788 if (- e
"${General::swroot}/red/active" && open ( IPADDR
, "${General::swroot}/red/local-ipaddress" )) {
789 my $ipaddr = < IPADDR
>;
792 $cgiparams { 'ROOTCERT_HOSTNAME' } = ( gethostbyaddr ( pack ( "C4" , split ( /\./ , $ipaddr )), 2 ))[ 0 ];
793 if ( $cgiparams { 'ROOTCERT_HOSTNAME' } eq '' ) {
794 $cgiparams { 'ROOTCERT_HOSTNAME' } = $ipaddr ;
797 $cgiparams { 'ROOTCERT_COUNTRY' } = $vpnsettings { 'ROOTCERT_COUNTRY' } if (! $cgiparams { 'ROOTCERT_COUNTRY' });
798 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'upload p12 file' }) {
799 & General
:: log ( "ipsec" , "Importing from p12..." );
801 if ( ref ( $cgiparams { 'FH' }) ne 'Fh' ) {
802 $errormessage = $Lang :: tr
{ 'there was no file upload' };
806 # Move uploaded certificate request to a temporary file
807 ( my $fh , my $filename ) = tempfile
( );
808 if ( copy
( $cgiparams { 'FH' }, $fh ) != 1 ) {
813 # Extract the CA certificate from the file
814 & General
:: log ( "ipsec" , "Extracting caroot from p12..." );
815 if ( open ( STDIN
, "-|" )) {
816 my $opt = " pkcs12 -cacerts -nokeys" ;
817 $opt .= " -in $filename " ;
818 $opt .= " -out /tmp/newcacert" ;
819 $errormessage = & callssl
( $opt );
821 print " $cgiparams {'P12_PASS'} \n " ;
825 # Extract the Host certificate from the file
826 if (! $errormessage ) {
827 & General
:: log ( "ipsec" , "Extracting host cert from p12..." );
828 if ( open ( STDIN
, "-|" )) {
829 my $opt = " pkcs12 -clcerts -nokeys" ;
830 $opt .= " -in $filename " ;
831 $opt .= " -out /tmp/newhostcert" ;
832 $errormessage = & callssl
( $opt );
834 print " $cgiparams {'P12_PASS'} \n " ;
839 # Extract the Host key from the file
840 if (! $errormessage ) {
841 & General
:: log ( "ipsec" , "Extracting private key from p12..." );
842 if ( open ( STDIN
, "-|" )) {
843 my $opt = " pkcs12 -nocerts -nodes" ;
844 $opt .= " -in $filename " ;
845 $opt .= " -out /tmp/newhostkey" ;
846 $errormessage = & callssl
( $opt );
848 print " $cgiparams {'P12_PASS'} \n " ;
853 if (! $errormessage ) {
854 & General
:: log ( "ipsec" , "Moving cacert..." );
855 move
( "/tmp/newcacert" , "${General::swroot}/ca/cacert.pem" );
856 $errormessage = " $Lang ::tr{'certificate file move failed'}: $!" if ($ ?
ne 0 );
859 if (! $errormessage ) {
860 & General
:: log ( "ipsec" , "Moving host cert..." );
861 move
( "/tmp/newhostcert" , "${General::swroot}/certs/hostcert.pem" );
862 $errormessage = " $Lang ::tr{'certificate file move failed'}: $!" if ($ ?
ne 0 );
865 if (! $errormessage ) {
866 & General
:: log ( "ipsec" , "Moving private key..." );
867 move
( "/tmp/newhostkey" , "${General::swroot}/certs/hostkey.pem" );
868 $errormessage = " $Lang ::tr{'certificate file move failed'}: $!" if ($ ?
ne 0 );
873 unlink ( '/tmp/newcacert' );
874 unlink ( '/tmp/newhostcert' );
875 unlink ( '/tmp/newhostkey' );
877 unlink ( "${General::swroot}/ca/cacert.pem" );
878 unlink ( "${General::swroot}/certs/hostcert.pem" );
879 unlink ( "${General::swroot}/certs/hostkey.pem" );
883 # Create empty CRL cannot be done because we don't have
884 # the private key for this CAROOT
885 # IPFire can only import certificates
887 & General
:: log ( "ipsec" , "p12 import completed!" );
889 goto ROOTCERT_SUCCESS
;
891 } elsif ( $cgiparams { 'ROOTCERT_COUNTRY' } ne '' ) {
893 # Validate input since the form was submitted
894 if ( $cgiparams { 'ROOTCERT_ORGANIZATION' } eq '' ){
895 $errormessage = $Lang :: tr
{ 'organization cant be empty' };
898 if ( length ( $cgiparams { 'ROOTCERT_ORGANIZATION' }) > 60 ) {
899 $errormessage = $Lang :: tr
{ 'organization too long' };
902 if ( $cgiparams { 'ROOTCERT_ORGANIZATION' } !~ /^[a-zA-Z0-9 ,\.\-_]*$/ ) {
903 $errormessage = $Lang :: tr
{ 'invalid input for organization' };
906 if ( $cgiparams { 'ROOTCERT_HOSTNAME' } eq '' ){
907 $errormessage = $Lang :: tr
{ 'hostname cant be empty' };
910 unless (& General
:: validfqdn
( $cgiparams { 'ROOTCERT_HOSTNAME' }) || & General
:: validip
( $cgiparams { 'ROOTCERT_HOSTNAME' })) {
911 $errormessage = $Lang :: tr
{ 'invalid input for hostname' };
914 if ( $cgiparams { 'ROOTCERT_EMAIL' } ne '' && (! & General
:: validemail
( $cgiparams { 'ROOTCERT_EMAIL' }))) {
915 $errormessage = $Lang :: tr
{ 'invalid input for e-mail address' };
918 if ( length ( $cgiparams { 'ROOTCERT_EMAIL' }) > 40 ) {
919 $errormessage = $Lang :: tr
{ 'e-mail address too long' };
922 if ( $cgiparams { 'ROOTCERT_OU' } ne '' && $cgiparams { 'ROOTCERT_OU' } !~ /^[a-zA-Z0-9 ,\.\-_]*$/ ) {
923 $errormessage = $Lang :: tr
{ 'invalid input for department' };
926 if ( $cgiparams { 'ROOTCERT_CITY' } ne '' && $cgiparams { 'ROOTCERT_CITY' } !~ /^[a-zA-Z0-9 ,\.\-_]*$/ ) {
927 $errormessage = $Lang :: tr
{ 'invalid input for city' };
930 if ( $cgiparams { 'ROOTCERT_STATE' } ne '' && $cgiparams { 'ROOTCERT_STATE' } !~ /^[a-zA-Z0-9 ,\.\-_]*$/ ) {
931 $errormessage = $Lang :: tr
{ 'invalid input for state or province' };
934 if ( $cgiparams { 'ROOTCERT_COUNTRY' } !~ /^[A-Z]*$/ ) {
935 $errormessage = $Lang :: tr
{ 'invalid input for country' };
938 #the exact syntax is a list comma separated of
939 # email:any-validemail
940 # URI: a uniform resource indicator
941 # DNS: a DNS domain name
942 # RID: a registered OBJECT IDENTIFIER
944 # example: email:franck@foo.com,IP:10.0.0.10,DNS:franck.foo.com
946 if ( $cgiparams { 'SUBJECTALTNAME' } ne '' && $cgiparams { 'SUBJECTALTNAME' } !~ /^(email|URI|DNS|RID|IP):[a-zA-Z0-9 :\/ , \
. \
- _@
]*$/) {
947 $errormessage = $Lang :: tr
{ 'vpn altname syntax' };
951 # Copy the cgisettings to vpnsettings and save the configfile
952 $vpnsettings { 'ROOTCERT_ORGANIZATION' } = $cgiparams { 'ROOTCERT_ORGANIZATION' };
953 $vpnsettings { 'ROOTCERT_HOSTNAME' } = $cgiparams { 'ROOTCERT_HOSTNAME' };
954 $vpnsettings { 'ROOTCERT_EMAIL' } = $cgiparams { 'ROOTCERT_EMAIL' };
955 $vpnsettings { 'ROOTCERT_OU' } = $cgiparams { 'ROOTCERT_OU' };
956 $vpnsettings { 'ROOTCERT_CITY' } = $cgiparams { 'ROOTCERT_CITY' };
957 $vpnsettings { 'ROOTCERT_STATE' } = $cgiparams { 'ROOTCERT_STATE' };
958 $vpnsettings { 'ROOTCERT_COUNTRY' } = $cgiparams { 'ROOTCERT_COUNTRY' };
959 & General
:: writehash
( "${General::swroot}/vpn/settings" , \
%vpnsettings );
961 # Replace empty strings with a .
962 ( my $ou = $cgiparams { 'ROOTCERT_OU' }) =~ s/^\s*$/\./ ;
963 ( my $city = $cgiparams { 'ROOTCERT_CITY' }) =~ s/^\s*$/\./ ;
964 ( my $state = $cgiparams { 'ROOTCERT_STATE' }) =~ s/^\s*$/\./ ;
966 # Create the CA certificate
967 if (! $errormessage ) {
968 & General
:: log ( "ipsec" , "Creating cacert..." );
969 if ( open ( STDIN
, "-|" )) {
970 my $opt = " req -x509 -nodes -rand /proc/interrupts:/proc/net/rt_cache" ;
971 $opt .= " -days 999999" ;
972 $opt .= " -newkey rsa:2048" ;
973 $opt .= " -keyout ${General::swroot}/private/cakey.pem" ;
974 $opt .= " -out ${General::swroot}/ca/cacert.pem" ;
976 $errormessage = & callssl
( $opt );
978 print " $cgiparams {'ROOTCERT_COUNTRY'} \n " ;
981 print " $cgiparams {'ROOTCERT_ORGANIZATION'} \n " ;
983 print " $cgiparams {'ROOTCERT_ORGANIZATION'} CA \n " ;
984 print " $cgiparams {'ROOTCERT_EMAIL'} \n " ;
989 # Create the Host certificate request
990 if (! $errormessage ) {
991 & General
:: log ( "ipsec" , "Creating host cert..." );
992 if ( open ( STDIN
, "-|" )) {
993 my $opt = " req -nodes -rand /proc/interrupts:/proc/net/rt_cache" ;
994 $opt .= " -newkey rsa:1024" ;
995 $opt .= " -keyout ${General::swroot}/certs/hostkey.pem" ;
996 $opt .= " -out ${General::swroot}/certs/hostreq.pem" ;
997 $errormessage = & callssl
( $opt );
999 print " $cgiparams {'ROOTCERT_COUNTRY'} \n " ;
1002 print " $cgiparams {'ROOTCERT_ORGANIZATION'} \n " ;
1004 print " $cgiparams {'ROOTCERT_HOSTNAME'} \n " ;
1005 print " $cgiparams {'ROOTCERT_EMAIL'} \n " ;
1012 # Sign the host certificate request
1013 if (! $errormessage ) {
1014 & General
:: log ( "ipsec" , "Self signing host cert..." );
1016 #No easy way for specifying the contain of subjectAltName without writing a config file...
1017 my ( $fh , $v3extname ) = tempfile
( '/tmp/XXXXXXXX' );
1019 basicConstraints=CA:FALSE
1020 nsComment="OpenSSL Generated Certificate"
1021 subjectKeyIdentifier=hash
1022 authorityKeyIdentifier=keyid,issuer:always
1025 print $fh "subjectAltName= $cgiparams {'SUBJECTALTNAME'}" if ( $cgiparams { 'SUBJECTALTNAME' });
1028 my $opt = " ca -days 999999" ;
1029 $opt .= " -batch -notext" ;
1030 $opt .= " -in ${General::swroot}/certs/hostreq.pem" ;
1031 $opt .= " -out ${General::swroot}/certs/hostcert.pem" ;
1032 $opt .= " -extfile $v3extname " ;
1033 $errormessage = & callssl
( $opt );
1034 unlink ( "${General::swroot}/certs/hostreq.pem" ); #no more needed
1035 unlink ( $v3extname );
1038 # Create an empty CRL
1039 if (! $errormessage ) {
1040 & General
:: log ( "ipsec" , "Creating emptycrl..." );
1041 my $opt = " ca -gencrl" ;
1042 $opt .= " -out ${General::swroot}/crls/cacrl.pem" ;
1043 $errormessage = & callssl
( $opt );
1046 # Successfully build CA / CERT!
1047 if (! $errormessage ) {
1048 & cleanssldatabase
();
1049 goto ROOTCERT_SUCCESS
;
1053 unlink ( "${General::swroot}/ca/cacert.pem" );
1054 unlink ( "${General::swroot}/certs/hostkey.pem" );
1055 unlink ( "${General::swroot}/certs/hostcert.pem" );
1056 unlink ( "${General::swroot}/crls/cacrl.pem" );
1057 & cleanssldatabase
();
1061 & Header
:: showhttpheaders
();
1062 & Header
:: openpage
( $Lang :: tr
{ 'vpn configuration main' }, 1 , '' );
1063 & Header
:: openbigbox
( '100%' , 'left' , '' , $errormessage );
1064 if ( $errormessage ) {
1065 & Header
:: openbox
( '100%' , 'left' , $Lang :: tr
{ 'error messages' });
1066 print "<class name='base'> $errormessage " ;
1067 print " </class>" ;
1068 & Header
:: closebox
();
1070 & Header
:: openbox
( '100%' , 'left' , " $Lang ::tr{'generate root/host certificates'}:" );
1072 <form method='post' enctype='multipart/form-data' action=' $ENV {'SCRIPT_NAME'}'>
1073 <table width='100%' border='0' cellspacing='1' cellpadding='0'>
1074 <tr><td width='40%' class='base'> $Lang ::tr{'organization name'}:</td>
1075 <td width='60%' class='base' nowrap='nowrap'><input type='text' name='ROOTCERT_ORGANIZATION' value=' $cgiparams {'ROOTCERT_ORGANIZATION'}' size='32' /></td></tr>
1076 <tr><td class='base'> $Lang ::tr{'ipfires hostname'}:</td>
1077 <td class='base' nowrap='nowrap'><input type='text' name='ROOTCERT_HOSTNAME' value=' $cgiparams {'ROOTCERT_HOSTNAME'}' size='32' /></td></tr>
1078 <tr><td class='base'> $Lang ::tr{'your e-mail'}: <img src='/blob.gif' alt='*' /></td>
1079 <td class='base' nowrap='nowrap'><input type='text' name='ROOTCERT_EMAIL' value=' $cgiparams {'ROOTCERT_EMAIL'}' size='32' /></td></tr>
1080 <tr><td class='base'> $Lang ::tr{'your department'}: <img src='/blob.gif' alt='*' /></td>
1081 <td class='base' nowrap='nowrap'><input type='text' name='ROOTCERT_OU' value=' $cgiparams {'ROOTCERT_OU'}' size='32' /></td></tr>
1082 <tr><td class='base'> $Lang ::tr{'city'}: <img src='/blob.gif' alt='*' /></td>
1083 <td class='base' nowrap='nowrap'><input type='text' name='ROOTCERT_CITY' value=' $cgiparams {'ROOTCERT_CITY'}' size='32' /></td></tr>
1084 <tr><td class='base'> $Lang ::tr{'state or province'}: <img src='/blob.gif' alt='*' /></td>
1085 <td class='base' nowrap='nowrap'><input type='text' name='ROOTCERT_STATE' value=' $cgiparams {'ROOTCERT_STATE'}' size='32' /></td></tr>
1086 <tr><td class='base'> $Lang ::tr{'country'}:</td>
1087 <td class='base'><select name='ROOTCERT_COUNTRY'>
1090 foreach my $country ( sort keys %{ Countries
:: countries
}) {
1091 print "<option value=' $Countries ::countries{ $country }'" ;
1092 if ( $Countries :: countries
{ $country } eq $cgiparams { 'ROOTCERT_COUNTRY' } ) {
1093 print " selected='selected'" ;
1095 print "> $country </option>" ;
1099 <tr><td class='base'> $Lang ::tr{'vpn subjectaltname'} (subjectAltName=email:*,URI:*,DNS:*,RID:*) <img src='/blob.gif' alt='*' /></td>
1100 <td class='base' nowrap='nowrap'><input type='text' name='SUBJECTALTNAME' value=' $cgiparams {'SUBJECTALTNAME'}' size='32' /></td></tr>
1102 <td><br /><input type='submit' name='ACTION' value=' $Lang ::tr{'generate root/host certificates'}' /><br /><br /></td></tr>
1103 <tr><td class='base' colspan='2' align='left'>
1104 <b><font color='${Header::colourred}'> $Lang ::tr{'capswarning'}</font></b>:
1105 $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'}
1107 <tr><td colspan='2'><hr /></td></tr>
1108 <tr><td class='base' nowrap='nowrap'> $Lang ::tr{'upload p12 file'}:</td>
1109 <td nowrap='nowrap'><input type='file' name='FH' size='32' /></td></tr>
1110 <tr><td class='base'> $Lang ::tr{'pkcs12 file password'}: <img src='/blob.gif' alt='*' /></td>
1111 <td class='base' nowrap='nowrap'><input type='password' name='P12_PASS' value=' $cgiparams {'P12_PASS'}' size='32' /></td></tr>
1113 <td><input type='submit' name='ACTION' value=' $Lang ::tr{'upload p12 file'}' /></td></tr>
1114 <tr><td class='base' colspan='2' align='left'>
1115 <img src='/blob.gif' alt='*' /> $Lang ::tr{'this field may be blank'}</td></tr>
1119 & Header
:: closebox
();
1120 & Header
:: closebigbox
();
1121 & Header
:: closepage
();
1126 system ( '/usr/local/bin/ipsecctrl' , 'S' );
1131 ### Export PKCS12 file to browser
1133 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'download pkcs12 file' }) {
1134 & General
:: readhasharray
( "${General::swroot}/vpn/config" , \
%confighash );
1135 print "Content-Type: application/force-download \n " ;
1136 print "Content-Disposition: attachment; filename=" . $confighash { $cgiparams { 'KEY' }}[ 1 ] . ".p12 \r\n " ;
1137 print "Content-Type: application/octet-stream \r\n\r\n " ;
1138 print `/bin/cat ${General::swroot}/certs/ $confighash { $cgiparams {'KEY'}}[1].p12` ;
1142 ### Display certificate
1144 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'show certificate' }) {
1145 & General
:: readhasharray
( "${General::swroot}/vpn/config" , \
%confighash );
1147 if ( - f
"${General::swroot}/certs/ $confighash { $cgiparams {'KEY'}}[1]cert.pem" ) {
1148 & Header
:: showhttpheaders
();
1149 & Header
:: openpage
( $Lang :: tr
{ 'vpn configuration main' }, 1 , '' );
1150 & Header
:: openbigbox
( '100%' , 'left' , '' , '' );
1151 & Header
:: openbox
( '100%' , 'left' , " $Lang ::tr{'cert'}:" );
1152 my $output = `/usr/bin/openssl x509 -text -in ${General::swroot}/certs/ $confighash { $cgiparams {'KEY'}}[1]cert.pem` ;
1153 $output = & Header
:: cleanhtml
( $output , "y" );
1154 print "<pre> $output </pre> \n " ;
1155 & Header
:: closebox
();
1156 print "<div align='center'><a href='/cgi-bin/vpnmain.cgi'> $Lang ::tr{'back'}</a></div>" ;
1157 & Header
:: closebigbox
();
1158 & Header
:: closepage
();
1163 ### Export Certificate to browser
1165 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'download certificate' }) {
1166 & General
:: readhasharray
( "${General::swroot}/vpn/config" , \
%confighash );
1168 if ( - f
"${General::swroot}/certs/ $confighash { $cgiparams {'KEY'}}[1]cert.pem" ) {
1169 print "Content-Type: application/force-download \n " ;
1170 print "Content-Disposition: attachment; filename=" . $confighash { $cgiparams { 'KEY' }}[ 1 ] . "cert.pem \n\n " ;
1171 print `/bin/cat ${General::swroot}/certs/ $confighash { $cgiparams {'KEY'}}[1]cert.pem` ;
1176 ### Enable/Disable connection
1178 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'toggle enable disable' }) {
1180 & General
:: readhash
( "${General::swroot}/vpn/settings" , \
%vpnsettings );
1181 & General
:: readhasharray
( "${General::swroot}/vpn/config" , \
%confighash );
1183 if ( $confighash { $cgiparams { 'KEY' }}) {
1184 if ( $confighash { $cgiparams { 'KEY' }}[ 0 ] eq 'off' ) {
1185 $confighash { $cgiparams { 'KEY' }}[ 0 ] = 'on' ;
1186 & General
:: writehasharray
( "${General::swroot}/vpn/config" , \
%confighash );
1188 system ( '/usr/local/bin/ipsecctrl' , 'S' , $cgiparams { 'KEY' }) if (& vpnenabled
);
1190 system ( '/usr/local/bin/ipsecctrl' , 'D' , $cgiparams { 'KEY' }) if (& vpnenabled
);
1191 $confighash { $cgiparams { 'KEY' }}[ 0 ] = 'off' ;
1192 & General
:: writehasharray
( "${General::swroot}/vpn/config" , \
%confighash );
1197 $errormessage = $Lang :: tr
{ 'invalid key' };
1201 ### Restart connection
1203 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'restart' }) {
1204 & General
:: readhash
( "${General::swroot}/vpn/settings" , \
%vpnsettings );
1205 & General
:: readhasharray
( "${General::swroot}/vpn/config" , \
%confighash );
1207 if ( $confighash { $cgiparams { 'KEY' }}) {
1209 system ( '/usr/local/bin/ipsecctrl' , 'S' , $cgiparams { 'KEY' });
1213 $errormessage = $Lang :: tr
{ 'invalid key' };
1217 ### Remove connection
1219 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'remove' }) {
1220 & General
:: readhash
( "${General::swroot}/vpn/settings" , \
%vpnsettings );
1221 & General
:: readhasharray
( "${General::swroot}/vpn/config" , \
%confighash );
1223 if ( $confighash { $cgiparams { 'KEY' }}) {
1224 system ( '/usr/local/bin/ipsecctrl' , 'D' , $cgiparams { 'KEY' }) if (& vpnenabled
);
1225 unlink ( "${General::swroot}/certs/ $confighash { $cgiparams {'KEY'}}[1]cert.pem" );
1226 unlink ( "${General::swroot}/certs/ $confighash { $cgiparams {'KEY'}}[1].p12" );
1227 delete $confighash { $cgiparams { 'KEY' }};
1228 & General
:: writehasharray
( "${General::swroot}/vpn/config" , \
%confighash );
1231 $errormessage = $Lang :: tr
{ 'invalid key' };
1235 ### Choose between adding a host-net or net-net connection
1237 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'add' } && $cgiparams { 'TYPE' } eq '' ) {
1238 & Header
:: showhttpheaders
();
1239 & Header
:: openpage
( $Lang :: tr
{ 'vpn configuration main' }, 1 , '' );
1240 & Header
:: openbigbox
( '100%' , 'left' , '' , '' );
1241 & Header
:: openbox
( '100%' , 'left' , $Lang :: tr
{ 'connection type' });
1243 <form method='post' action=' $ENV {'SCRIPT_NAME'}'>
1244 <b> $Lang ::tr{'connection type'}:</b><br />
1246 <tr><td><input type='radio' name='TYPE' value='host' checked='checked' /></td>
1247 <td class='base'> $Lang ::tr{'host to net vpn'}</td>
1249 <td><input type='radio' name='TYPE' value='net' /></td>
1250 <td class='base'> $Lang ::tr{'net to net vpn'}</td>
1252 <td align='center' colspan='2'><input type='submit' name='ACTION' value=' $Lang ::tr{'add'}' /></td>
1257 & Header
:: closebox
();
1258 & Header
:: closebigbox
();
1259 & Header
:: closepage
();
1262 ### Adding/Editing/Saving a connection
1264 } elsif (( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'add' }) ||
1265 ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'edit' }) ||
1266 ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'save' } && $cgiparams { 'ADVANCED' } eq '' )) {
1268 & General
:: readhash
( "${General::swroot}/vpn/settings" , \
%vpnsettings );
1269 & General
:: readhasharray
( "${General::swroot}/vpn/caconfig" , \
%cahash );
1270 & General
:: readhasharray
( "${General::swroot}/vpn/config" , \
%confighash );
1272 if ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'edit' }) {
1273 if (! $confighash { $cgiparams { 'KEY' }}[ 0 ]) {
1274 $errormessage = $Lang :: tr
{ 'invalid key' };
1277 $cgiparams { 'ENABLED' } = $confighash { $cgiparams { 'KEY' }}[ 0 ];
1278 $cgiparams { 'NAME' } = $confighash { $cgiparams { 'KEY' }}[ 1 ];
1279 $cgiparams { 'TYPE' } = $confighash { $cgiparams { 'KEY' }}[ 3 ];
1280 $cgiparams { 'AUTH' } = $confighash { $cgiparams { 'KEY' }}[ 4 ];
1281 $cgiparams { 'PSK' } = $confighash { $cgiparams { 'KEY' }}[ 5 ];
1282 #$cgiparams{'free'} = $confighash{$cgiparams{'KEY'}}[6];
1283 $cgiparams { 'LOCAL_ID' } = $confighash { $cgiparams { 'KEY' }}[ 7 ];
1284 $cgiparams { 'LOCAL_SUBNET' } = $confighash { $cgiparams { 'KEY' }}[ 8 ];
1285 $cgiparams { 'REMOTE_ID' } = $confighash { $cgiparams { 'KEY' }}[ 9 ];
1286 $cgiparams { 'REMOTE' } = $confighash { $cgiparams { 'KEY' }}[ 10 ];
1287 $cgiparams { 'REMOTE_SUBNET' } = $confighash { $cgiparams { 'KEY' }}[ 11 ];
1288 $cgiparams { 'REMARK' } = $confighash { $cgiparams { 'KEY' }}[ 25 ];
1289 $cgiparams { 'INTERFACE' } = $confighash { $cgiparams { 'KEY' }}[ 26 ];
1290 $cgiparams { 'DPD_ACTION' } = $confighash { $cgiparams { 'KEY' }}[ 27 ];
1291 $cgiparams { 'IKE_ENCRYPTION' } = $confighash { $cgiparams { 'KEY' }}[ 18 ];
1292 $cgiparams { 'IKE_INTEGRITY' } = $confighash { $cgiparams { 'KEY' }}[ 19 ];
1293 $cgiparams { 'IKE_GROUPTYPE' } = $confighash { $cgiparams { 'KEY' }}[ 20 ];
1294 $cgiparams { 'IKE_LIFETIME' } = $confighash { $cgiparams { 'KEY' }}[ 16 ];
1295 $cgiparams { 'ESP_ENCRYPTION' } = $confighash { $cgiparams { 'KEY' }}[ 21 ];
1296 $cgiparams { 'ESP_INTEGRITY' } = $confighash { $cgiparams { 'KEY' }}[ 22 ];
1297 $cgiparams { 'ESP_GROUPTYPE' } = $confighash { $cgiparams { 'KEY' }}[ 23 ];
1298 $cgiparams { 'ESP_KEYLIFE' } = $confighash { $cgiparams { 'KEY' }}[ 17 ];
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 # Check if there is no other entry with this name
1327 if (! $cgiparams { 'KEY' }) { #only for add
1328 foreach my $key ( keys %confighash ) {
1329 if ( $confighash { $key }[ 1 ] eq $cgiparams { 'NAME' }) {
1330 $errormessage = $Lang :: tr
{ 'a connection with this name already exists' };
1336 if (( $cgiparams { 'TYPE' } eq 'net' ) && (! $cgiparams { 'REMOTE' })) {
1337 $errormessage = $Lang :: tr
{ 'invalid input for remote host/ip' };
1341 if ( $cgiparams { 'REMOTE' }) {
1342 if (! & General
:: validip
( $cgiparams { 'REMOTE' })) {
1343 if (! & General
:: validfqdn
( $cgiparams { 'REMOTE' })) {
1344 $errormessage = $Lang :: tr
{ 'invalid input for remote host/ip' };
1347 if (& valid_dns_host
( $cgiparams { 'REMOTE' })) {
1348 $warnmessage = " $Lang ::tr{'check vpn lr'} $cgiparams {'REMOTE'}. $Lang ::tr{'dns check failed'}" ;
1354 unless (& General
:: validipandmask
( $cgiparams { 'LOCAL_SUBNET' })) {
1355 $errormessage = $Lang :: tr
{ 'local subnet is invalid' };
1359 # Allow only one roadwarrior/psk without remote IP-address
1360 if ( $cgiparams { 'REMOTE' } eq '' && $cgiparams { 'AUTH' } eq 'psk' ) {
1361 foreach my $key ( keys %confighash ) {
1362 if ( ( $cgiparams { 'KEY' } ne $key ) &&
1363 ( $confighash { $key }[ 4 ] eq 'psk' ) &&
1364 ( $confighash { $key }[ 10 ] eq '' ) ) {
1365 $errormessage = $Lang :: tr
{ 'you can only define one roadwarrior connection when using pre-shared key authentication' };
1370 if (( $cgiparams { 'TYPE' } eq 'net' ) && (! & General
:: validipandmask
( $cgiparams { 'REMOTE_SUBNET' }))) {
1371 $errormessage = $Lang :: tr
{ 'remote subnet is invalid' };
1375 if ( $cgiparams { 'ENABLED' } !~ /^(on|off)$/ ) {
1376 $errormessage = $Lang :: tr
{ 'invalid input' };
1379 if ( $cgiparams { 'EDIT_ADVANCED' } !~ /^(on|off)$/ ) {
1380 $errormessage = $Lang :: tr
{ 'invalid input' };
1384 # Allow nothing or a string (DN,FDQN,) beginning with @
1385 # with no comma but slashes between RID eg @O=FR/C=Paris/OU=myhome/CN=franck
1386 if ( ( $cgiparams { 'LOCAL_ID' } !~ /^(|[\w.-]*@[\w. =*\/ -]+| \d
+ \
. \d
+ \
. \d
+ \
. \d
+)$/) ||
1387 ( $cgiparams { 'REMOTE_ID' } !~ /^(|[\w.-]*@[\w. =*\/ -]+| \d
+ \
. \d
+ \
. \d
+ \
. \d
+)$/) ||
1388 (( $cgiparams { 'REMOTE_ID' } eq $cgiparams { 'LOCAL_ID' }) && ( $cgiparams { 'LOCAL_ID' } ne '' ))
1390 $errormessage = $Lang :: tr
{ 'invalid local-remote id' } . '<br />' .
1391 'DER_ASN1_DN: @c =FR/ou=Paris/ou=Home/cn=*<br />' .
1392 'FQDN: @ipfire .org<br />' .
1393 'USER_FQDN: info @ipfire .org<br />' .
1394 'IPV4_ADDR: 123.123.123.123' ;
1397 # If Auth is DN, verify existance of Remote ID.
1398 if ( $cgiparams { 'REMOTE_ID' } eq '' && (
1399 $cgiparams { 'AUTH' } eq 'auth-dn' || # while creation
1400 $confighash { $cgiparams { 'KEY' }}[ 2 ] eq ' %auth -dn' )){ # while editing
1401 $errormessage = $Lang :: tr
{ 'vpn missing remote id' };
1405 if ( $cgiparams { 'AUTH' } eq 'psk' ) {
1406 if (! length ( $cgiparams { 'PSK' }) ) {
1407 $errormessage = $Lang :: tr
{ 'pre-shared key is too short' };
1410 if ( $cgiparams { 'PSK' } =~ /'/ ) {
1411 $cgiparams { 'PSK' } =~ tr/'/ / ;
1412 $errormessage = $Lang :: tr
{ 'invalid characters found in pre-shared key' };
1415 } elsif ( $cgiparams { 'AUTH' } eq 'certreq' ) {
1416 if ( $cgiparams { 'KEY' }) {
1417 $errormessage = $Lang :: tr
{ 'cant change certificates' };
1420 if ( ref ( $cgiparams { 'FH' }) ne 'Fh' ) {
1421 $errormessage = $Lang :: tr
{ 'there was no file upload' };
1425 # Move uploaded certificate request to a temporary file
1426 ( my $fh , my $filename ) = tempfile
( );
1427 if ( copy
( $cgiparams { 'FH' }, $fh ) != 1 ) {
1432 # Sign the certificate request
1433 & General
:: log ( "ipsec" , "Signing your cert $cgiparams {'NAME'}..." );
1434 my $opt = " ca -days 999999" ;
1435 $opt .= " -batch -notext" ;
1436 $opt .= " -in $filename " ;
1437 $opt .= " -out ${General::swroot}/certs/ $cgiparams {'NAME'}cert.pem" ;
1439 if ( $errormessage = & callssl
( $opt ) ) {
1441 unlink ( "${General::swroot}/certs/ $cgiparams {'NAME'}cert.pem" );
1442 & cleanssldatabase
();
1446 & cleanssldatabase
();
1449 $cgiparams { 'CERT_NAME' } = getCNfromcert
( "${General::swroot}/certs/ $cgiparams {'NAME'}cert.pem" );
1450 if ( $cgiparams { 'CERT_NAME' } eq '' ) {
1451 $errormessage = $Lang :: tr
{ 'could not retrieve common name from certificate' };
1454 } elsif ( $cgiparams { 'AUTH' } eq 'pkcs12' ) {
1455 & General
:: log ( "ipsec" , "Importing from p12..." );
1457 if ( ref ( $cgiparams { 'FH' }) ne 'Fh' ) {
1458 $errormessage = $Lang :: tr
{ 'there was no file upload' };
1459 goto ROOTCERT_ERROR
;
1462 # Move uploaded certificate request to a temporary file
1463 ( my $fh , my $filename ) = tempfile
( );
1464 if ( copy
( $cgiparams { 'FH' }, $fh ) != 1 ) {
1466 goto ROOTCERT_ERROR
;
1469 # Extract the CA certificate from the file
1470 & General
:: log ( "ipsec" , "Extracting caroot from p12..." );
1471 if ( open ( STDIN
, "-|" )) {
1472 my $opt = " pkcs12 -cacerts -nokeys" ;
1473 $opt .= " -in $filename " ;
1474 $opt .= " -out /tmp/newcacert" ;
1475 $errormessage = & callssl
( $opt );
1477 print " $cgiparams {'P12_PASS'} \n " ;
1481 # Extract the Host certificate from the file
1482 if (! $errormessage ) {
1483 & General
:: log ( "ipsec" , "Extracting host cert from p12..." );
1484 if ( open ( STDIN
, "-|" )) {
1485 my $opt = " pkcs12 -clcerts -nokeys" ;
1486 $opt .= " -in $filename " ;
1487 $opt .= " -out /tmp/newhostcert" ;
1488 $errormessage = & callssl
( $opt );
1490 print " $cgiparams {'P12_PASS'} \n " ;
1495 if (! $errormessage ) {
1496 & General
:: log ( "ipsec" , "Moving cacert..." );
1497 #If CA have new subject, add it to our list of CA
1498 my $casubject = & Header
:: cleanhtml
( getsubjectfromcert
( '/tmp/newcacert' ));
1500 foreach my $x ( keys %cahash ) {
1501 $casubject = '' if ( $cahash { $x }[ 1 ] eq $casubject );
1502 unshift ( @names , $cahash { $x }[ 0 ]);
1504 if ( $casubject ) { # a new one!
1505 my $temp = `/usr/bin/openssl x509 -text -in /tmp/newcacert` ;
1506 if ( $temp !~ /CA:TRUE/i ) {
1507 $errormessage = $Lang :: tr
{ 'not a valid ca certificate' };
1509 #compute a name for it
1511 while ( grep ( /Imported-$idx/ , @names ) ) { $idx ++};
1512 $cgiparams { 'CA_NAME' }= "Imported- $idx " ;
1513 $cgiparams { 'CERT_NAME' }=& Header
:: cleanhtml
( getCNfromcert
( '/tmp/newhostcert' ));
1514 move
( "/tmp/newcacert" , "${General::swroot}/ca/ $cgiparams {'CA_NAME'}cert.pem" );
1515 $errormessage = " $Lang ::tr{'certificate file move failed'}: $!" if ($ ?
ne 0 );
1516 if (! $errormessage ) {
1517 my $key = & General
:: findhasharraykey
( \
%cahash );
1518 $cahash { $key }[ 0 ] = $cgiparams { 'CA_NAME' };
1519 $cahash { $key }[ 1 ] = $casubject ;
1520 & General
:: writehasharray
( "${General::swroot}/vpn/caconfig" , \
%cahash );
1521 system ( '/usr/local/bin/ipsecctrl' , 'R' );
1526 if (! $errormessage ) {
1527 & General
:: log ( "ipsec" , "Moving host cert..." );
1528 move
( "/tmp/newhostcert" , "${General::swroot}/certs/ $cgiparams {'NAME'}cert.pem" );
1529 $errormessage = " $Lang ::tr{'certificate file move failed'}: $!" if ($ ?
ne 0 );
1534 unlink ( '/tmp/newcacert' );
1535 unlink ( '/tmp/newhostcert' );
1536 if ( $errormessage ) {
1537 unlink ( "${General::swroot}/ca/ $cgiparams {'CA_NAME'}cert.pem" );
1538 unlink ( "${General::swroot}/certs/ $cgiparams {'NAME'}cert.pem" );
1541 & General
:: log ( "ipsec" , "p12 import completed!" );
1542 } elsif ( $cgiparams { 'AUTH' } eq 'certfile' ) {
1543 if ( $cgiparams { 'KEY' }) {
1544 $errormessage = $Lang :: tr
{ 'cant change certificates' };
1547 if ( ref ( $cgiparams { 'FH' }) ne 'Fh' ) {
1548 $errormessage = $Lang :: tr
{ 'there was no file upload' };
1551 # Move uploaded certificate to a temporary file
1552 ( my $fh , my $filename ) = tempfile
( );
1553 if ( copy
( $cgiparams { 'FH' }, $fh ) != 1 ) {
1558 # Verify the certificate has a valid CA and move it
1559 & General
:: log ( "ipsec" , "Validating imported cert against our known CA..." );
1560 my $validca = 1 ; #assume ok
1561 my $test = `/usr/bin/openssl verify -CAfile ${General::swroot}/ca/cacert.pem $filename ` ;
1562 if ( $test !~ /: OK/ ) {
1564 foreach my $key ( keys %cahash ) {
1565 $test = `/usr/bin/openssl verify -CAfile ${General::swroot}/ca/ $cahash { $key }[0]cert.pem $filename ` ;
1566 if ( $test =~ /: OK/ ) {
1573 $errormessage = $Lang :: tr
{ 'certificate does not have a valid ca associated with it' };
1577 move
( $filename , "${General::swroot}/certs/ $cgiparams {'NAME'}cert.pem" );
1579 $errormessage = " $Lang ::tr{'certificate file move failed'}: $!" ;
1585 $cgiparams { 'CERT_NAME' } = getCNfromcert
( "${General::swroot}/certs/ $cgiparams {'NAME'}cert.pem" );
1586 if ( $cgiparams { 'CERT_NAME' } eq '' ) {
1587 unlink ( "${General::swroot}/certs/ $cgiparams {'NAME'}cert.pem" );
1588 $errormessage = $Lang :: tr
{ 'could not retrieve common name from certificate' };
1591 } elsif ( $cgiparams { 'AUTH' } eq 'certgen' ) {
1592 if ( $cgiparams { 'KEY' }) {
1593 $errormessage = $Lang :: tr
{ 'cant change certificates' };
1596 # Validate input since the form was submitted
1597 if ( length ( $cgiparams { 'CERT_NAME' }) > 60 ) {
1598 $errormessage = $Lang :: tr
{ 'name too long' };
1601 if ( $cgiparams { 'CERT_NAME' } !~ /^[a-zA-Z0-9 ,\.\-_]+$/ ) {
1602 $errormessage = $Lang :: tr
{ 'invalid input for name' };
1605 if ( $cgiparams { 'CERT_EMAIL' } ne '' && (! & General
:: validemail
( $cgiparams { 'CERT_EMAIL' }))) {
1606 $errormessage = $Lang :: tr
{ 'invalid input for e-mail address' };
1609 if ( length ( $cgiparams { 'CERT_EMAIL' }) > 40 ) {
1610 $errormessage = $Lang :: tr
{ 'e-mail address too long' };
1613 if ( $cgiparams { 'CERT_OU' } ne '' && $cgiparams { 'CERT_OU' } !~ /^[a-zA-Z0-9 ,\.\-_]*$/ ) {
1614 $errormessage = $Lang :: tr
{ 'invalid input for department' };
1617 if ( length ( $cgiparams { 'CERT_ORGANIZATION' }) > 60 ) {
1618 $errormessage = $Lang :: tr
{ 'organization too long' };
1621 if ( $cgiparams { 'CERT_ORGANIZATION' } !~ /^[a-zA-Z0-9 ,\.\-_]+$/ ) {
1622 $errormessage = $Lang :: tr
{ 'invalid input for organization' };
1625 if ( $cgiparams { 'CERT_CITY' } ne '' && $cgiparams { 'CERT_CITY' } !~ /^[a-zA-Z0-9 ,\.\-_]*$/ ) {
1626 $errormessage = $Lang :: tr
{ 'invalid input for city' };
1629 if ( $cgiparams { 'CERT_STATE' } ne '' && $cgiparams { 'CERT_STATE' } !~ /^[a-zA-Z0-9 ,\.\-_]*$/ ) {
1630 $errormessage = $Lang :: tr
{ 'invalid input for state or province' };
1633 if ( $cgiparams { 'CERT_COUNTRY' } !~ /^[A-Z]*$/ ) {
1634 $errormessage = $Lang :: tr
{ 'invalid input for country' };
1637 #the exact syntax is a list comma separated of
1638 # email:any-validemail
1639 # URI: a uniform resource indicator
1640 # DNS: a DNS domain name
1641 # RID: a registered OBJECT IDENTIFIER
1643 # example: email:franck@foo.com,IP:10.0.0.10,DNS:franck.foo.com
1645 if ( $cgiparams { 'SUBJECTALTNAME' } ne '' && $cgiparams { 'SUBJECTALTNAME' } !~ /^(email|URI|DNS|RID|IP):[a-zA-Z0-9 :\/ , \
. \
- _@
]*$/) {
1646 $errormessage = $Lang :: tr
{ 'vpn altname syntax' };
1650 if ( length ( $cgiparams { 'CERT_PASS1' }) < 5 ) {
1651 $errormessage = $Lang :: tr
{ 'password too short' };
1654 if ( $cgiparams { 'CERT_PASS1' } ne $cgiparams { 'CERT_PASS2' }) {
1655 $errormessage = $Lang :: tr
{ 'passwords do not match' };
1659 # Replace empty strings with a .
1660 ( my $ou = $cgiparams { 'CERT_OU' }) =~ s/^\s*$/\./ ;
1661 ( my $city = $cgiparams { 'CERT_CITY' }) =~ s/^\s*$/\./ ;
1662 ( my $state = $cgiparams { 'CERT_STATE' }) =~ s/^\s*$/\./ ;
1664 # Create the Host certificate request
1665 & General
:: log ( "ipsec" , "Creating a cert..." );
1667 if ( open ( STDIN
, "-|" )) {
1668 my $opt = " req -nodes -rand /proc/interrupts:/proc/net/rt_cache" ;
1669 $opt .= " -newkey rsa:1024" ;
1670 $opt .= " -keyout ${General::swroot}/certs/ $cgiparams {'NAME'}key.pem" ;
1671 $opt .= " -out ${General::swroot}/certs/ $cgiparams {'NAME'}req.pem" ;
1673 if ( $errormessage = & callssl
( $opt ) ) {
1674 unlink ( "${General::swroot}/certs/ $cgiparams {'NAME'}key.pem" );
1675 unlink ( "${General::swroot}/certs/ $cgiparams {'NAME'}req.pem" );
1679 print " $cgiparams {'CERT_COUNTRY'} \n " ;
1682 print " $cgiparams {'CERT_ORGANIZATION'} \n " ;
1684 print " $cgiparams {'CERT_NAME'} \n " ;
1685 print " $cgiparams {'CERT_EMAIL'} \n " ;
1691 # Sign the host certificate request
1692 & General
:: log ( "ipsec" , "Signing the cert $cgiparams {'NAME'}..." );
1694 #No easy way for specifying the contain of subjectAltName without writing a config file...
1695 my ( $fh , $v3extname ) = tempfile
( '/tmp/XXXXXXXX' );
1697 basicConstraints=CA:FALSE
1698 nsComment="OpenSSL Generated Certificate"
1699 subjectKeyIdentifier=hash
1700 authorityKeyIdentifier=keyid,issuer:always
1703 print $fh "subjectAltName= $cgiparams {'SUBJECTALTNAME'}" if ( $cgiparams { 'SUBJECTALTNAME' });
1706 my $opt = " ca -days 999999 -batch -notext" ;
1707 $opt .= " -in ${General::swroot}/certs/ $cgiparams {'NAME'}req.pem" ;
1708 $opt .= " -out ${General::swroot}/certs/ $cgiparams {'NAME'}cert.pem" ;
1709 $opt .= " -extfile $v3extname " ;
1711 if ( $errormessage = & callssl
( $opt ) ) {
1712 unlink ( $v3extname );
1713 unlink ( "${General::swroot}/certs/ $cgiparams {'NAME'}key.pem" );
1714 unlink ( "${General::swroot}/certs/ $cgiparams {'NAME'}req.pem" );
1715 unlink ( "${General::swroot}/certs/ $cgiparams {'NAME'}cert.pem" );
1716 & cleanssldatabase
();
1719 unlink ( $v3extname );
1720 unlink ( "${General::swroot}/certs/ $cgiparams {'NAME'}req.pem" );
1721 & cleanssldatabase
();
1724 # Create the pkcs12 file
1725 & General
:: log ( "ipsec" , "Packing a pkcs12 file..." );
1726 $opt = " pkcs12 -export" ;
1727 $opt .= " -inkey ${General::swroot}/certs/ $cgiparams {'NAME'}key.pem" ;
1728 $opt .= " -in ${General::swroot}/certs/ $cgiparams {'NAME'}cert.pem" ;
1729 $opt .= " -name \" $cgiparams {'NAME'} \" " ;
1730 $opt .= " -passout pass: $cgiparams {'CERT_PASS1'}" ;
1731 $opt .= " -certfile ${General::swroot}/ca/cacert.pem" ;
1732 $opt .= " -caname \" $vpnsettings {'ROOTCERT_ORGANIZATION'} CA \" " ;
1733 $opt .= " -out ${General::swroot}/certs/ $cgiparams {'NAME'}.p12" ;
1735 if ( $errormessage = & callssl
( $opt ) ) {
1736 unlink ( "${General::swroot}/certs/ $cgiparams {'NAME'}key.pem" );
1737 unlink ( "${General::swroot}/certs/ $cgiparams {'NAME'}cert.pem" );
1738 unlink ( "${General::swroot}/certs/ $cgiparams {'NAME'}.p12" );
1741 unlink ( "${General::swroot}/certs/ $cgiparams {'NAME'}key.pem" );
1743 } elsif ( $cgiparams { 'AUTH' } eq 'cert' ) {
1744 ; # Nothing, just editing
1745 } elsif ( $cgiparams { 'AUTH' } eq 'auth-dn' ) {
1746 $cgiparams { 'CERT_NAME' } = ' %auth -dn' ; # a special value saying 'no cert file'
1748 $errormessage = $Lang :: tr
{ 'invalid input for authentication method' };
1752 # 1)Error message here is not accurate.
1753 # 2)Test is superfluous, openswan can reference same cert multiple times
1754 # 3)Present since initial version (1.3.2.11), it isn't a bug correction
1755 # Check if there is no other entry with this certificate name
1756 #if ((! $cgiparams{'KEY'}) && ($cgiparams{'AUTH'} ne 'psk') && ($cgiparams{'AUTH'} ne 'auth-dn')) {
1757 # foreach my $key (keys %confighash) {
1758 # if ($confighash{$key}[2] eq $cgiparams{'CERT_NAME'}) {
1759 # $errormessage = $Lang::tr{'a connection with this common name already exists'};
1760 # goto VPNCONF_ERROR;
1766 my $key = $cgiparams { 'KEY' };
1768 $key = & General
:: findhasharraykey
( \
%confighash );
1769 foreach my $i ( 0 .. 28 ) { $confighash { $key }[ $i ] = "" ;}
1771 $confighash { $key }[ 0 ] = $cgiparams { 'ENABLED' };
1772 $confighash { $key }[ 1 ] = $cgiparams { 'NAME' };
1773 if ((! $cgiparams { 'KEY' }) && $cgiparams { 'AUTH' } ne 'psk' ) {
1774 $confighash { $key }[ 2 ] = $cgiparams { 'CERT_NAME' };
1776 $confighash { $key }[ 3 ] = $cgiparams { 'TYPE' };
1777 if ( $cgiparams { 'AUTH' } eq 'psk' ) {
1778 $confighash { $key }[ 4 ] = 'psk' ;
1779 $confighash { $key }[ 5 ] = $cgiparams { 'PSK' };
1781 $confighash { $key }[ 4 ] = 'cert' ;
1783 if ( $cgiparams { 'TYPE' } eq 'net' ) {
1784 $confighash { $key }[ 11 ] = $cgiparams { 'REMOTE_SUBNET' };
1786 $confighash { $key }[ 7 ] = $cgiparams { 'LOCAL_ID' };
1787 $confighash { $key }[ 8 ] = $cgiparams { 'LOCAL_SUBNET' };
1788 $confighash { $key }[ 9 ] = $cgiparams { 'REMOTE_ID' };
1789 $confighash { $key }[ 10 ] = $cgiparams { 'REMOTE' };
1790 $confighash { $key }[ 25 ] = $cgiparams { 'REMARK' };
1791 $confighash { $key }[ 26 ] = $cgiparams { 'INTERFACE' };
1792 $confighash { $key }[ 27 ] = $cgiparams { 'DPD_ACTION' };
1794 #dont forget advanced value
1795 $confighash { $key }[ 18 ] = $cgiparams { 'IKE_ENCRYPTION' };
1796 $confighash { $key }[ 19 ] = $cgiparams { 'IKE_INTEGRITY' };
1797 $confighash { $key }[ 20 ] = $cgiparams { 'IKE_GROUPTYPE' };
1798 $confighash { $key }[ 16 ] = $cgiparams { 'IKE_LIFETIME' };
1799 $confighash { $key }[ 21 ] = $cgiparams { 'ESP_ENCRYPTION' };
1800 $confighash { $key }[ 22 ] = $cgiparams { 'ESP_INTEGRITY' };
1801 $confighash { $key }[ 23 ] = $cgiparams { 'ESP_GROUPTYPE' };
1802 $confighash { $key }[ 17 ] = $cgiparams { 'ESP_KEYLIFE' };
1803 $confighash { $key }[ 12 ] = 'off' ; # $cgiparams{'AGGRMODE'};
1804 $confighash { $key }[ 13 ] = $cgiparams { 'COMPRESSION' };
1805 $confighash { $key }[ 24 ] = $cgiparams { 'ONLY_PROPOSED' };
1806 $confighash { $key }[ 28 ] = $cgiparams { 'PFS' };
1807 $confighash { $key }[ 14 ] = $cgiparams { 'VHOST' };
1809 #free unused fields!
1810 $confighash { $key }[ 6 ] = 'off' ;
1811 $confighash { $key }[ 15 ] = 'off' ;
1813 & General
:: writehasharray
( "${General::swroot}/vpn/config" , \
%confighash );
1816 system ( '/usr/local/bin/ipsecctrl' , 'S' , $key );
1819 if ( $cgiparams { 'EDIT_ADVANCED' } eq 'on' ) {
1820 $cgiparams { 'KEY' } = $key ;
1821 $cgiparams { 'ACTION' } = $Lang :: tr
{ 'advanced' };
1824 } else { # add new connection
1825 $cgiparams { 'ENABLED' } = 'on' ;
1826 if ( ! - f
"${General::swroot}/private/cakey.pem" ) {
1827 $cgiparams { 'AUTH' } = 'psk' ;
1828 } elsif ( ! - f
"${General::swroot}/ca/cacert.pem" ) {
1829 $cgiparams { 'AUTH' } = 'certfile' ;
1831 $cgiparams { 'AUTH' } = 'certgen' ;
1833 $cgiparams { 'LOCAL_SUBNET' } = " $netsettings {'GREEN_NETADDRESS'}/ $netsettings {'GREEN_NETMASK'}" ;
1834 $cgiparams { 'CERT_EMAIL' } = $vpnsettings { 'ROOTCERT_EMAIL' };
1835 $cgiparams { 'CERT_OU' } = $vpnsettings { 'ROOTCERT_OU' };
1836 $cgiparams { 'CERT_ORGANIZATION' } = $vpnsettings { 'ROOTCERT_ORGANIZATION' };
1837 $cgiparams { 'CERT_CITY' } = $vpnsettings { 'ROOTCERT_CITY' };
1838 $cgiparams { 'CERT_STATE' } = $vpnsettings { 'ROOTCERT_STATE' };
1839 $cgiparams { 'CERT_COUNTRY' } = $vpnsettings { 'ROOTCERT_COUNTRY' };
1841 # choose appropriate dpd action
1842 if ( $cgiparams { 'TYPE' } eq 'host' ) {
1843 $cgiparams { 'DPD_ACTION' } = 'clear' ;
1845 $cgiparams { 'DPD_ACTION' } = 'restart' ;
1848 # Default is yes for 'pfs'
1849 $cgiparams { 'PFS' } = 'on' ;
1852 $cgiparams { 'LOCAL_ID' } = '' ;
1853 $cgiparams { 'REMOTE_ID' } = '' ;
1855 #use default advanced value
1856 $cgiparams { 'IKE_ENCRYPTION' } = 'aes128|3des' ; #[18];
1857 $cgiparams { 'IKE_INTEGRITY' } = 'sha|md5' ; #[19];
1858 $cgiparams { 'IKE_GROUPTYPE' } = '1536|1024' ; #[20];
1859 $cgiparams { 'IKE_LIFETIME' } = '1' ; #[16];
1860 $cgiparams { 'ESP_ENCRYPTION' } = 'aes128|3des' ; #[21];
1861 $cgiparams { 'ESP_INTEGRITY' } = 'sha1|md5' ; #[22];
1862 $cgiparams { 'ESP_GROUPTYPE' } = '' ; #[23];
1863 $cgiparams { 'ESP_KEYLIFE' } = '8' ; #[17];
1864 $cgiparams { 'COMPRESSION' } = 'off' ; #[13];
1865 $cgiparams { 'ONLY_PROPOSED' } = 'off' ; #[24];
1866 $cgiparams { 'PFS' } = 'on' ; #[28];
1867 $cgiparams { 'VHOST' } = 'on' ; #[14];
1871 $checked { 'ENABLED' }{ 'off' } = '' ;
1872 $checked { 'ENABLED' }{ 'on' } = '' ;
1873 $checked { 'ENABLED' }{ $cgiparams { 'ENABLED' }} = "checked='checked'" ;
1875 $checked { 'EDIT_ADVANCED' }{ 'off' } = '' ;
1876 $checked { 'EDIT_ADVANCED' }{ 'on' } = '' ;
1877 $checked { 'EDIT_ADVANCED' }{ $cgiparams { 'EDIT_ADVANCED' }} = "checked='checked'" ;
1879 $checked { 'AUTH' }{ 'psk' } = '' ;
1880 $checked { 'AUTH' }{ 'certreq' } = '' ;
1881 $checked { 'AUTH' }{ 'certgen' } = '' ;
1882 $checked { 'AUTH' }{ 'certfile' } = '' ;
1883 $checked { 'AUTH' }{ 'pkcs12' } = '' ;
1884 $checked { 'AUTH' }{ 'auth-dn' } = '' ;
1885 $checked { 'AUTH' }{ $cgiparams { 'AUTH' }} = "checked='checked'" ;
1887 $selected { 'INTERFACE' }{ 'RED' } = '' ;
1888 $selected { 'INTERFACE' }{ 'ORANGE' } = '' ;
1889 $selected { 'INTERFACE' }{ 'GREEN' } = '' ;
1890 $selected { 'INTERFACE' }{ 'BLUE' } = '' ;
1891 $selected { 'INTERFACE' }{ $cgiparams { 'INTERFACE' }} = "selected='selected'" ;
1893 $selected { 'DPD_ACTION' }{ 'clear' } = '' ;
1894 $selected { 'DPD_ACTION' }{ 'hold' } = '' ;
1895 $selected { 'DPD_ACTION' }{ 'restart' } = '' ;
1896 $selected { 'DPD_ACTION' }{ $cgiparams { 'DPD_ACTION' }} = "selected='selected'" ;
1898 & Header
:: showhttpheaders
();
1899 & Header
:: openpage
( $Lang :: tr
{ 'vpn configuration main' }, 1 , '' );
1900 & Header
:: openbigbox
( '100%' , 'left' , '' , $errormessage );
1901 if ( $errormessage ) {
1902 & Header
:: openbox
( '100%' , 'left' , $Lang :: tr
{ 'error messages' });
1903 print "<class name='base'> $errormessage " ;
1904 print " </class>" ;
1905 & Header
:: closebox
();
1909 & Header
:: openbox
( '100%' , 'left' , " $Lang ::tr{'warning messages'}:" );
1910 print "<class name='base'> $warnmessage " ;
1911 print " </class>" ;
1912 & Header
:: closebox
();
1915 print "<form method='post' enctype='multipart/form-data' action=' $ENV {'SCRIPT_NAME'}'>" ;
1917 <input type='hidden' name='TYPE' value=' $cgiparams {'TYPE'}' />
1918 <input type='hidden' name='IKE_ENCRYPTION' value=' $cgiparams {'IKE_ENCRYPTION'}' />
1919 <input type='hidden' name='IKE_INTEGRITY' value=' $cgiparams {'IKE_INTEGRITY'}' />
1920 <input type='hidden' name='IKE_GROUPTYPE' value=' $cgiparams {'IKE_GROUPTYPE'}' />
1921 <input type='hidden' name='IKE_LIFETIME' value=' $cgiparams {'IKE_LIFETIME'}' />
1922 <input type='hidden' name='ESP_ENCRYPTION' value=' $cgiparams {'ESP_ENCRYPTION'}' />
1923 <input type='hidden' name='ESP_INTEGRITY' value=' $cgiparams {'ESP_INTEGRITY'}' />
1924 <input type='hidden' name='ESP_GROUPTYPE' value=' $cgiparams {'ESP_GROUPTYPE'}' />
1925 <input type='hidden' name='ESP_KEYLIFE' value=' $cgiparams {'ESP_KEYLIFE'}' />
1926 <input type='hidden' name='COMPRESSION' value=' $cgiparams {'COMPRESSION'}' />
1927 <input type='hidden' name='ONLY_PROPOSED' value=' $cgiparams {'ONLY_PROPOSED'}' />
1928 <input type='hidden' name='PFS' value=' $cgiparams {'PFS'}' />
1929 <input type='hidden' name='VHOST' value=' $cgiparams {'VHOST'}' />
1932 if ( $cgiparams { 'KEY' }) {
1933 print "<input type='hidden' name='KEY' value=' $cgiparams {'KEY'}' />" ;
1934 print "<input type='hidden' name='AUTH' value=' $cgiparams {'AUTH'}' />" ;
1937 & Header
:: openbox
( '100%' , 'left' , " $Lang ::tr{'connection'}:" );
1938 print "<table width='100%'>" ;
1939 print "<tr><td width='25%' class='boldbase'> $Lang ::tr{'name'}:</td>" ;
1940 if ( $cgiparams { 'KEY' }) {
1941 print "<td width='25%' class='base'><input type='hidden' name='NAME' value=' $cgiparams {'NAME'}' /><b> $cgiparams {'NAME'}</b></td>" ;
1943 print "<td width='25%'><input type='text' name='NAME' value=' $cgiparams {'NAME'}' size='30' /></td>" ;
1945 print "<td> $Lang ::tr{'enabled'}</td><td><input type='checkbox' name='ENABLED' $checked{'ENABLED'}{'on'} /></td></tr>" ;
1946 print '</tr><td><br /></td><tr>' ;
1950 if ( $cgiparams { 'TYPE' } eq 'host' ) {
1951 $disabled = "disabled='disabled'" ;
1952 $blob = "<img src='/blob.gif' alt='*' />" ;
1955 print "<tr><td> $Lang ::tr{'host ip'}:</td>" ;
1956 print "<td><select name='INTERFACE'>" ;
1957 print "<option value='RED' $selected {'INTERFACE'}{'RED'}>RED ( $vpnsettings {'VPN_IP'})</option>" ;
1958 print "<option value='GREEN' $selected {'INTERFACE'}{'GREEN'}>GREEN ( $netsettings {'GREEN_ADDRESS'})</option>" ;
1959 print "<option value='BLUE' $selected {'INTERFACE'}{'BLUE'}>BLUE ( $netsettings {'BLUE_ADDRESS'})</option>" if ( $netsettings { 'BLUE_DEV' } ne '' );
1960 print "<option value='ORANGE' $selected {'INTERFACE'}{'ORANGE'}>ORANGE ( $netsettings {'ORANGE_ADDRESS'})</option>" if ( $netsettings { 'ORANGE_DEV' } ne '' );
1961 print "</select></td>" ;
1963 <td class='boldbase'> $Lang ::tr{'remote host/ip'}: $blob </td>
1964 <td><input type='text' name='REMOTE' value=' $cgiparams {'REMOTE'}' size='30' /></td>
1966 <td class='boldbase' nowrap='nowrap'> $Lang ::tr{'local subnet'}</td>
1967 <td><input type='text' name='LOCAL_SUBNET' value=' $cgiparams {'LOCAL_SUBNET'}' size='30' /></td>
1968 <td class='boldbase' nowrap='nowrap'> $Lang ::tr{'remote subnet'}</td>
1969 <td><input $disabled type='text' name='REMOTE_SUBNET' value=' $cgiparams {'REMOTE_SUBNET'}' size='30' /></td>
1971 <td class='boldbase'> $Lang ::tr{'vpn local id'}:<br />( $Lang ::tr{'eg'} <tt>@xy.example.com</tt>)</td>
1972 <td><input type='text' name='LOCAL_ID' value=' $cgiparams {'LOCAL_ID'}' /></td>
1973 <td class='boldbase'> $Lang ::tr{'vpn remote id'}:</td>
1974 <td><input type='text' name='REMOTE_ID' value=' $cgiparams {'REMOTE_ID'}' /></td>
1976 </tr><td><br /></td><tr>
1977 <td> $Lang ::tr{'dpd action'}:</td>
1978 <td><select name='DPD_ACTION'>
1979 <option value='clear' $selected {'DPD_ACTION'}{'clear'}>clear</option>
1980 <option value='hold' $selected {'DPD_ACTION'}{'hold'}>hold</option>
1981 <option value='restart' $selected {'DPD_ACTION'}{'restart'}>restart</option>
1982 </select> <a href='http://www.openswan.com/docs/local/README.DPD'>?</a>
1985 <!--http://www.openswan.com/docs/local/README.DPD
1986 http://bugs.xelerance.com/view.php?id=156
1987 restart = clear + reinitiate connection
1989 <td class='boldbase'> $Lang ::tr{'remark title'} <img src='/blob.gif' alt='*' /></td>
1990 <td colspan='3'><input type='text' name='REMARK' value=' $cgiparams {'REMARK'}' size='55' maxlength='50' /></td>
1994 if (! $cgiparams { 'KEY' }) {
1995 print "<tr><td colspan='3'><input type='checkbox' name='EDIT_ADVANCED' $checked {'EDIT_ADVANCED'}{'on'} /> $Lang ::tr{'edit advanced settings when done'}</td></tr>" ;
1998 & Header
:: closebox
();
2000 if ( $cgiparams { 'KEY' } && $cgiparams { 'AUTH' } eq 'psk' ) {
2001 & Header
:: openbox
( '100%' , 'left' , $Lang :: tr
{ 'authentication' });
2003 <table width='100%' cellpadding='0' cellspacing='5' border='0'>
2004 <tr><td class='base' width='50%'> $Lang ::tr{'use a pre-shared key'}</td>
2005 <td class='base' width='50%'><input type='password' name='PSK' size='30' value=' $cgiparams {'PSK'}' /></td>
2010 & Header
:: closebox
();
2011 } elsif (! $cgiparams { 'KEY' }) {
2012 my $pskdisabled = ( $vpnsettings { 'VPN_IP' } eq ' %defaultroute ' ) ?
"disabled='disabled'" : '' ;
2013 $cgiparams { 'PSK' } = $Lang :: tr
{ 'vpn incompatible use of defaultroute' } if ( $pskdisabled );
2014 my $cakeydisabled = ( ! - f
"${General::swroot}/private/cakey.pem" ) ?
"disabled='disabled'" : '' ;
2015 $cgiparams { 'CERT_NAME' } = $Lang :: tr
{ 'vpn no full pki' } if ( $cakeydisabled );
2016 my $cacrtdisabled = ( ! - f
"${General::swroot}/ca/cacert.pem" ) ?
"disabled='disabled'" : '' ;
2018 & Header
:: openbox
( '100%' , 'left' , $Lang :: tr
{ 'authentication' });
2020 <table width='100%' cellpadding='0' cellspacing='5' border='0'>
2021 <tr><td width='5%'><input type='radio' name='AUTH' value='psk' $checked {'AUTH'}{'psk'} $pskdisabled /></td>
2022 <td class='base' width='55%'> $Lang ::tr{'use a pre-shared key'}</td>
2023 <td class='base' width='40%'><input type='password' name='PSK' size='30' value=' $cgiparams {'PSK'}' $pskdisabled /></td></tr>
2024 <tr><td colspan='3' bgcolor='#000000'></td></tr>
2025 <tr><td><input type='radio' name='AUTH' value='certreq' $checked {'AUTH'}{'certreq'} $cakeydisabled /></td>
2026 <td class='base'><hr /> $Lang ::tr{'upload a certificate request'}</td>
2027 <td class='base' rowspan='3' valign='middle'><input type='file' name='FH' size='30' $cacrtdisabled /></td></tr>
2028 <tr><td><input type='radio' name='AUTH' value='certfile' $checked {'AUTH'}{'certfile'} $cacrtdisabled /></td>
2029 <td class='base'> $Lang ::tr{'upload a certificate'}</td></tr>
2030 <tr><td><input type='radio' name='AUTH' value='pkcs12' $cacrtdisabled /></td>
2031 <td class='base'> $Lang ::tr{'upload p12 file'} $Lang ::tr{'pkcs12 file password'}:<input type='password' name='P12_PASS'/></td></tr>
2032 <tr><td><input type='radio' name='AUTH' value='auth-dn' $checked {'AUTH'}{'auth-dn'} $cacrtdisabled /></td>
2033 <td class='base'><hr /> $Lang ::tr{'vpn auth-dn'}</td></tr>
2034 <tr><td colspan='3' bgcolor='#000000'></td></tr>
2035 <tr><td><input type='radio' name='AUTH' value='certgen' $checked {'AUTH'}{'certgen'} $cakeydisabled /></td>
2036 <td class='base'><hr /> $Lang ::tr{'generate a certificate'}</td><td> </td></tr>
2038 <td class='base'> $Lang ::tr{'users fullname or system hostname'}:</td>
2039 <td class='base' nowrap='nowrap'><input type='text' name='CERT_NAME' value=' $cgiparams {'CERT_NAME'}' size='32' $cakeydisabled /></td></tr>
2041 <td class='base'> $Lang ::tr{'users email'}: <img src='/blob.gif' alt='*' /></td>
2042 <td class='base' nowrap='nowrap'><input type='text' name='CERT_EMAIL' value=' $cgiparams {'CERT_EMAIL'}' size='32' $cakeydisabled /></td></tr>
2044 <td class='base'> $Lang ::tr{'users department'}: <img src='/blob.gif' alt='*' /></td>
2045 <td class='base' nowrap='nowrap'><input type='text' name='CERT_OU' value=' $cgiparams {'CERT_OU'}' size='32' $cakeydisabled /></td></tr>
2047 <td class='base'> $Lang ::tr{'organization name'}: <img src='/blob.gif' alt='*' /></td>
2048 <td class='base' nowrap='nowrap'><input type='text' name='CERT_ORGANIZATION' value=' $cgiparams {'CERT_ORGANIZATION'}' size='32' $cakeydisabled /></td></tr>
2050 <td class='base'> $Lang ::tr{'city'}: <img src='/blob.gif' alt='*' /></td>
2051 <td class='base' nowrap='nowrap'><input type='text' name='CERT_CITY' value=' $cgiparams {'CERT_CITY'}' size='32' $cakeydisabled /></td></tr>
2053 <td class='base'> $Lang ::tr{'state or province'}: <img src='/blob.gif' alt='*' /></td>
2054 <td class='base' nowrap='nowrap'><input type='text' name='CERT_STATE' value=' $cgiparams {'CERT_STATE'}' size='32' $cakeydisabled /></td></tr>
2056 <td class='base'> $Lang ::tr{'country'}:</td>
2057 <td class='base'><select name='CERT_COUNTRY' $cakeydisabled >
2060 foreach my $country ( sort keys %{ Countries
:: countries
}) {
2061 print " \t\t\t <option value=' $Countries ::countries{ $country }'" ;
2062 if ( $Countries :: countries
{ $country } eq $cgiparams { 'CERT_COUNTRY' } ) {
2063 print " selected='selected'" ;
2065 print "> $country </option> \n " ;
2070 <tr><td> </td><td class='base'> $Lang ::tr{'vpn subjectaltname'} (subjectAltName=email:*,URI:*,DNS:*,RID:*)<img src='/blob.gif' alt='*' /></td>
2071 <td class='base' nowrap='nowrap'><input type='text' name='SUBJECTALTNAME' value=' $cgiparams {'SUBJECTALTNAME'}' size='32' $cakeydisabled /></td></tr>
2073 <td class='base'> $Lang ::tr{'pkcs12 file password'}:</td>
2074 <td class='base' nowrap='nowrap'><input type='password' name='CERT_PASS1' value=' $cgiparams {'CERT_PASS1'}' size='32' $cakeydisabled /></td></tr>
2075 <tr><td> </td><td class='base'> $Lang ::tr{'pkcs12 file password'}:( $Lang ::tr{'confirmation'})</td>
2076 <td class='base' nowrap='nowrap'><input type='password' name='CERT_PASS2' value=' $cgiparams {'CERT_PASS2'}' size='32' $cakeydisabled /></td></tr>
2080 & Header
:: closebox
();
2083 print "<div align='center'><input type='submit' name='ACTION' value=' $Lang ::tr{'save'}' />" ;
2084 if ( $cgiparams { 'KEY' }) {
2085 print "<input type='submit' name='ACTION' value=' $Lang ::tr{'advanced'}' />" ;
2087 print "<input type='submit' name='ACTION' value=' $Lang ::tr{'cancel'}' /></div></form>" ;
2088 & Header
:: closebigbox
();
2089 & Header
:: closepage
();
2096 ### Advanced settings
2098 if (( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'advanced' }) ||
2099 ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'save' } && $cgiparams { 'ADVANCED' } eq 'yes' )) {
2100 & General
:: readhash
( "${General::swroot}/vpn/settings" , \
%vpnsettings );
2101 & General
:: readhasharray
( "${General::swroot}/vpn/config" , \
%confighash );
2102 if (! $confighash { $cgiparams { 'KEY' }}) {
2103 $errormessage = $Lang :: tr
{ 'invalid key' };
2107 if ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'save' }) {
2108 # I didn't read any incompatibilities here....
2109 #if ($cgiparams{'VHOST'} eq 'on' && $cgiparams{'COMPRESSION'} eq 'on') {
2110 # $errormessage = $Lang::tr{'cannot enable both nat traversal and compression'};
2111 # goto ADVANCED_ERROR;
2113 my @temp = split ( '\|' , $cgiparams { 'IKE_ENCRYPTION' });
2115 $errormessage = $Lang :: tr
{ 'invalid input' };
2116 goto ADVANCED_ERROR
;
2118 foreach my $val ( @temp ) {
2119 if ( $val !~ /^(aes256|aes128|3des)$/ ) {
2120 $errormessage = $Lang :: tr
{ 'invalid input' };
2121 goto ADVANCED_ERROR
;
2124 @temp = split ( '\|' , $cgiparams { 'IKE_INTEGRITY' });
2126 $errormessage = $Lang :: tr
{ 'invalid input' };
2127 goto ADVANCED_ERROR
;
2129 foreach my $val ( @temp ) {
2130 if ( $val !~ /^(sha2_512|sha2_256|sha|md5)$/ ) {
2131 $errormessage = $Lang :: tr
{ 'invalid input' };
2132 goto ADVANCED_ERROR
;
2135 @temp = split ( '\|' , $cgiparams { 'IKE_GROUPTYPE' });
2137 $errormessage = $Lang :: tr
{ 'invalid input' };
2138 goto ADVANCED_ERROR
;
2140 foreach my $val ( @temp ) {
2141 if ( $val !~ /^(1024|1536|2048|3072|4096|6144|8192)$/ ) {
2142 $errormessage = $Lang :: tr
{ 'invalid input' };
2143 goto ADVANCED_ERROR
;
2146 if ( $cgiparams { 'IKE_LIFETIME' } !~ /^\d+$/ ) {
2147 $errormessage = $Lang :: tr
{ 'invalid input for ike lifetime' };
2148 goto ADVANCED_ERROR
;
2150 if ( $cgiparams { 'IKE_LIFETIME' } < 1 || $cgiparams { 'IKE_LIFETIME' } > 8 ) {
2151 $errormessage = $Lang :: tr
{ 'ike lifetime should be between 1 and 8 hours' };
2152 goto ADVANCED_ERROR
;
2154 @temp = split ( '\|' , $cgiparams { 'ESP_ENCRYPTION' });
2156 $errormessage = $Lang :: tr
{ 'invalid input' };
2157 goto ADVANCED_ERROR
;
2159 foreach my $val ( @temp ) {
2160 if ( $val !~ /^(aes256|aes128|3des)$/ ) {
2161 $errormessage = $Lang :: tr
{ 'invalid input' };
2162 goto ADVANCED_ERROR
;
2165 @temp = split ( '\|' , $cgiparams { 'ESP_INTEGRITY' });
2167 $errormessage = $Lang :: tr
{ 'invalid input' };
2168 goto ADVANCED_ERROR
;
2170 foreach my $val ( @temp ) {
2171 if ( $val !~ /^(sha2_512|sha2_256|sha1|md5)$/ ) {
2172 $errormessage = $Lang :: tr
{ 'invalid input' };
2173 goto ADVANCED_ERROR
;
2176 if ( $cgiparams { 'ESP_GROUPTYPE' } ne '' &&
2177 $cgiparams { 'ESP_GROUPTYPE' } !~ /^modp(1024|1536|2048|3072|4096)$/ ) {
2178 $errormessage = $Lang :: tr
{ 'invalid input' };
2179 goto ADVANCED_ERROR
;
2182 if ( $cgiparams { 'ESP_KEYLIFE' } !~ /^\d+$/ ) {
2183 $errormessage = $Lang :: tr
{ 'invalid input for esp keylife' };
2184 goto ADVANCED_ERROR
;
2186 if ( $cgiparams { 'ESP_KEYLIFE' } < 1 || $cgiparams { 'ESP_KEYLIFE' } > 24 ) {
2187 $errormessage = $Lang :: tr
{ 'esp keylife should be between 1 and 24 hours' };
2188 goto ADVANCED_ERROR
;
2192 ( $cgiparams { 'COMPRESSION' } !~ /^(|on|off)$/ ) ||
2193 ( $cgiparams { 'ONLY_PROPOSED' } !~ /^(|on|off)$/ ) ||
2194 ( $cgiparams { 'PFS' } !~ /^(|on|off)$/ ) ||
2195 ( $cgiparams { 'VHOST' } !~ /^(|on|off)$/ )
2197 $errormessage = $Lang :: tr
{ 'invalid input' };
2198 goto ADVANCED_ERROR
;
2201 $confighash { $cgiparams { 'KEY' }}[ 18 ] = $cgiparams { 'IKE_ENCRYPTION' };
2202 $confighash { $cgiparams { 'KEY' }}[ 19 ] = $cgiparams { 'IKE_INTEGRITY' };
2203 $confighash { $cgiparams { 'KEY' }}[ 20 ] = $cgiparams { 'IKE_GROUPTYPE' };
2204 $confighash { $cgiparams { 'KEY' }}[ 16 ] = $cgiparams { 'IKE_LIFETIME' };
2205 $confighash { $cgiparams { 'KEY' }}[ 21 ] = $cgiparams { 'ESP_ENCRYPTION' };
2206 $confighash { $cgiparams { 'KEY' }}[ 22 ] = $cgiparams { 'ESP_INTEGRITY' };
2207 $confighash { $cgiparams { 'KEY' }}[ 23 ] = $cgiparams { 'ESP_GROUPTYPE' };
2208 $confighash { $cgiparams { 'KEY' }}[ 17 ] = $cgiparams { 'ESP_KEYLIFE' };
2209 $confighash { $cgiparams { 'KEY' }}[ 12 ] = 'off' ; #$cgiparams{'AGGRMODE'};
2210 $confighash { $cgiparams { 'KEY' }}[ 13 ] = $cgiparams { 'COMPRESSION' };
2211 $confighash { $cgiparams { 'KEY' }}[ 24 ] = $cgiparams { 'ONLY_PROPOSED' };
2212 $confighash { $cgiparams { 'KEY' }}[ 28 ] = $cgiparams { 'PFS' };
2213 $confighash { $cgiparams { 'KEY' }}[ 14 ] = $cgiparams { 'VHOST' };
2214 & General
:: writehasharray
( "${General::swroot}/vpn/config" , \
%confighash );
2217 system ( '/usr/local/bin/ipsecctrl' , 'S' , $cgiparams { 'KEY' });
2222 $cgiparams { 'IKE_ENCRYPTION' } = $confighash { $cgiparams { 'KEY' }}[ 18 ];
2223 $cgiparams { 'IKE_INTEGRITY' } = $confighash { $cgiparams { 'KEY' }}[ 19 ];
2224 $cgiparams { 'IKE_GROUPTYPE' } = $confighash { $cgiparams { 'KEY' }}[ 20 ];
2225 $cgiparams { 'IKE_LIFETIME' } = $confighash { $cgiparams { 'KEY' }}[ 16 ];
2226 $cgiparams { 'ESP_ENCRYPTION' } = $confighash { $cgiparams { 'KEY' }}[ 21 ];
2227 $cgiparams { 'ESP_INTEGRITY' } = $confighash { $cgiparams { 'KEY' }}[ 22 ];
2228 $cgiparams { 'ESP_GROUPTYPE' } = $confighash { $cgiparams { 'KEY' }}[ 23 ];
2229 $cgiparams { 'ESP_KEYLIFE' } = $confighash { $cgiparams { 'KEY' }}[ 17 ];
2230 $cgiparams { 'COMPRESSION' } = $confighash { $cgiparams { 'KEY' }}[ 13 ];
2231 $cgiparams { 'ONLY_PROPOSED' } = $confighash { $cgiparams { 'KEY' }}[ 24 ];
2232 $cgiparams { 'PFS' } = $confighash { $cgiparams { 'KEY' }}[ 28 ];
2233 $cgiparams { 'VHOST' } = $confighash { $cgiparams { 'KEY' }}[ 14 ];
2235 if ( $confighash { $cgiparams { 'KEY' }}[ 3 ] eq 'net' || $confighash { $cgiparams { 'KEY' }}[ 10 ]) {
2236 $cgiparams { 'VHOST' } = 'off' ;
2241 $checked { 'IKE_ENCRYPTION' }{ 'aes256' } = '' ;
2242 $checked { 'IKE_ENCRYPTION' }{ 'aes128' } = '' ;
2243 $checked { 'IKE_ENCRYPTION' }{ '3des' } = '' ;
2244 my @temp = split ( '\|' , $cgiparams { 'IKE_ENCRYPTION' });
2245 foreach my $key ( @temp ) { $checked { 'IKE_ENCRYPTION' }{ $key } = "selected='selected'" ; }
2246 $checked { 'IKE_INTEGRITY' }{ 'sha2_512' } = '' ;
2247 $checked { 'IKE_INTEGRITY' }{ 'sha2_256' } = '' ;
2248 $checked { 'IKE_INTEGRITY' }{ 'sha' } = '' ;
2249 $checked { 'IKE_INTEGRITY' }{ 'md5' } = '' ;
2250 @temp = split ( '\|' , $cgiparams { 'IKE_INTEGRITY' });
2251 foreach my $key ( @temp ) { $checked { 'IKE_INTEGRITY' }{ $key } = "selected='selected'" ; }
2252 $checked { 'IKE_GROUPTYPE' }{ '768' } = '' ;
2253 $checked { 'IKE_GROUPTYPE' }{ '1024' } = '' ;
2254 $checked { 'IKE_GROUPTYPE' }{ '1536' } = '' ;
2255 $checked { 'IKE_GROUPTYPE' }{ '2048' } = '' ;
2256 $checked { 'IKE_GROUPTYPE' }{ '3072' } = '' ;
2257 $checked { 'IKE_GROUPTYPE' }{ '4096' } = '' ;
2258 $checked { 'IKE_GROUPTYPE' }{ '6144' } = '' ;
2259 $checked { 'IKE_GROUPTYPE' }{ '8192' } = '' ;
2260 @temp = split ( '\|' , $cgiparams { 'IKE_GROUPTYPE' });
2261 foreach my $key ( @temp ) { $checked { 'IKE_GROUPTYPE' }{ $key } = "selected='selected'" ; }
2263 # 768 is not supported by strongswan
2264 $checked { 'IKE_GROUPTYPE' }{ '768' } = '' ;
2267 $checked { 'ESP_ENCRYPTION' }{ 'aes256' } = '' ;
2268 $checked { 'ESP_ENCRYPTION' }{ 'aes128' } = '' ;
2269 $checked { 'ESP_ENCRYPTION' }{ '3des' } = '' ;
2270 @temp = split ( '\|' , $cgiparams { 'ESP_ENCRYPTION' });
2271 foreach my $key ( @temp ) { $checked { 'ESP_ENCRYPTION' }{ $key } = "selected='selected'" ; }
2272 $checked { 'ESP_INTEGRITY' }{ 'sha2_512' } = '' ;
2273 $checked { 'ESP_INTEGRITY' }{ 'sha2_256' } = '' ;
2274 $checked { 'ESP_INTEGRITY' }{ 'sha1' } = '' ;
2275 $checked { 'ESP_INTEGRITY' }{ 'md5' } = '' ;
2276 @temp = split ( '\|' , $cgiparams { 'ESP_INTEGRITY' });
2277 foreach my $key ( @temp ) { $checked { 'ESP_INTEGRITY' }{ $key } = "selected='selected'" ; }
2278 $checked { 'ESP_GROUPTYPE' }{ $cgiparams { 'ESP_GROUPTYPE' }} = "selected='selected'" ;
2280 $checked { 'COMPRESSION' } = $cgiparams { 'COMPRESSION' } eq 'on' ?
"checked='checked'" : '' ;
2281 $checked { 'ONLY_PROPOSED' } = $cgiparams { 'ONLY_PROPOSED' } eq 'on' ?
"checked='checked'" : '' ;
2282 $checked { 'PFS' } = $cgiparams { 'PFS' } eq 'on' ?
"checked='checked'" : '' ;
2283 $checked { 'VHOST' } = $cgiparams { 'VHOST' } eq 'on' ?
"checked='checked'" : '' ;
2285 & Header
:: showhttpheaders
();
2286 & Header
:: openpage
( $Lang :: tr
{ 'vpn configuration main' }, 1 , '' );
2287 & Header
:: openbigbox
( '100%' , 'left' , '' , $errormessage );
2289 if ( $errormessage ) {
2290 & Header
:: openbox
( '100%' , 'left' , $Lang :: tr
{ 'error messages' });
2291 print "<class name='base'> $errormessage " ;
2292 print " </class>" ;
2293 & Header
:: closebox
();
2297 & Header
:: openbox
( '100%' , 'left' , $Lang :: tr
{ 'warning messages' });
2298 print "<class name='base'> $warnmessage " ;
2299 print " </class>" ;
2300 & Header
:: closebox
();
2303 & Header
:: openbox
( '100%' , 'left' , " $Lang ::tr{'advanced'}:" );
2305 <form method='post' enctype='multipart/form-data' action=' $ENV {'SCRIPT_NAME'}'>
2306 <input type='hidden' name='ADVANCED' value='yes' />
2307 <input type='hidden' name='KEY' value=' $cgiparams {'KEY'}' />
2309 <table width='100%'>
2310 <tr><td class='boldbase' align='right' valign='top'> $Lang ::tr{'ike encryption'}</td><td class='boldbase' valign='top'>
2311 <select name='IKE_ENCRYPTION' multiple='multiple' size='4'>
2312 <option value='aes256' $checked {'IKE_ENCRYPTION'}{'aes256'}>AES (256 bit)</option>
2313 <option value='aes128' $checked {'IKE_ENCRYPTION'}{'aes128'}>AES (128 bit)</option>
2314 <option value='3des' $checked {'IKE_ENCRYPTION'}{'3des'}>3DES</option>
2317 <td class='boldbase' align='right' valign='top'> $Lang ::tr{'ike integrity'}</td><td class='boldbase' valign='top'>
2318 <select name='IKE_INTEGRITY' multiple='multiple' size='4'>
2319 <option value='sha' $checked {'IKE_INTEGRITY'}{'sha'}>SHA</option>
2320 <option value='md5' $checked {'IKE_INTEGRITY'}{'md5'}>MD5</option>
2323 <td class='boldbase' align='right' valign='top'> $Lang ::tr{'ike grouptype'}</td><td class='boldbase' valign='top'>
2324 <select name='IKE_GROUPTYPE' multiple='multiple' size='4'>
2325 <option value='8192' $checked {'IKE_GROUPTYPE'}{'8192'}>MODP-8192</option>
2326 <option value='6144' $checked {'IKE_GROUPTYPE'}{'6144'}>MODP-6144</option>
2327 <option value='4096' $checked {'IKE_GROUPTYPE'}{'4096'}>MODP-4096</option>
2328 <option value='3072' $checked {'IKE_GROUPTYPE'}{'3072'}>MODP-3072</option>
2329 <option value='2048' $checked {'IKE_GROUPTYPE'}{'2048'}>MODP-2048</option>
2330 <option value='1536' $checked {'IKE_GROUPTYPE'}{'1536'}>MODP-1536</option>
2331 <option value='1024' $checked {'IKE_GROUPTYPE'}{'1024'}>MODP-1024</option>
2334 <td class='boldbase' align='right' valign='top'> $Lang ::tr{'ike lifetime'}</td><td class='boldbase' valign='top'>
2335 <input type='text' name='IKE_LIFETIME' value=' $cgiparams {'IKE_LIFETIME'}' size='5' /> $Lang ::tr{'hours'}</td>
2338 <td colspan='1'><hr /></td>
2340 <td class='boldbase' align='right' valign='top'> $Lang ::tr{'esp encryption'}</td><td class='boldbase' valign='top'>
2341 <select name='ESP_ENCRYPTION' multiple='multiple' size='4'>
2342 <option value='aes256' $checked {'ESP_ENCRYPTION'}{'aes256'}>AES (256 bit)</option>
2343 <option value='aes128' $checked {'ESP_ENCRYPTION'}{'aes128'}>AES (128 bit)</option>
2344 <option value='3des' $checked {'ESP_ENCRYPTION'}{'3des'}>3DES</option>
2346 <td class='boldbase' align='right' valign='top'> $Lang ::tr{'esp integrity'}</td><td class='boldbase' valign='top'>
2347 <select name='ESP_INTEGRITY' multiple='multiple' size='4'>
2348 <option value='sha1' $checked {'ESP_INTEGRITY'}{'sha1'}>SHA1</option>
2349 <option value='md5' $checked {'ESP_INTEGRITY'}{'md5'}>MD5</option></select></td>
2351 <td class='boldbase' align='right' valign='top'> $Lang ::tr{'esp grouptype'}</td><td class='boldbase' valign='top'>
2352 <select name='ESP_GROUPTYPE'>
2353 <option value=''> $Lang ::tr{'phase1 group'}</option></select></td>
2355 <td class='boldbase' align='right' valign='top'> $Lang ::tr{'esp keylife'}</td><td class='boldbase' valign='top'>
2356 <input type='text' name='ESP_KEYLIFE' value=' $cgiparams {'ESP_KEYLIFE'}' size='5' /> $Lang ::tr{'hours'}</td>
2358 <td colspan='1'><hr /></td>
2360 <td colspan='5'><input type='checkbox' name='ONLY_PROPOSED' $checked {'ONLY_PROPOSED'} />
2361 IKE+ESP: $Lang ::tr{'use only proposed settings'}</td>
2363 <td colspan='5'><input type='checkbox' name='PFS' $checked {'PFS'} />
2364 $Lang ::tr{'pfs yes no'}</td>
2365 <td align='right'><input type='submit' name='ACTION' value=' $Lang ::tr{'save'}' /></td>
2367 <td colspan='5'><input type='checkbox' name='COMPRESSION' $checked {'COMPRESSION'} />
2368 $Lang ::tr{'vpn payload compression'}</td>
2369 <td align='right'><input type='submit' name='ACTION' value=' $Lang ::tr{'cancel'}' /></td>
2373 if ( $confighash { $cgiparams { 'KEY' }}[ 3 ] eq 'net' ) {
2374 print "<tr><td><input type='hidden' name='VHOST' value='off' /></td></tr>" ;
2375 } elsif ( $confighash { $cgiparams { 'KEY' }}[ 10 ]) {
2376 print "<tr><td colspan='5'><input type='checkbox' name='VHOST' $checked {'VHOST'} disabled='disabled' />" ;
2377 print " $Lang ::tr{'vpn vhost'}</td></tr>" ;
2379 print "<tr><td colspan='5'><input type='checkbox' name='VHOST' $checked {'VHOST'} />" ;
2380 print " $Lang ::tr{'vpn vhost'}</td></tr>" ;
2383 print "</table></form>" ;
2384 & Header
:: closebox
();
2385 & Header
:: closebigbox
();
2386 & Header
:: closepage
();
2393 ### Default status page
2398 & General
:: readhash
( "${General::swroot}/vpn/settings" , \
%cgiparams );
2399 & General
:: readhasharray
( "${General::swroot}/vpn/caconfig" , \
%cahash );
2400 & General
:: readhasharray
( "${General::swroot}/vpn/config" , \
%confighash );
2401 $cgiparams { 'CA_NAME' } = '' ;
2403 my @status = `/usr/local/bin/ipsecctrl I 2>/dev/null` ;
2405 # suggest a default name for this side
2406 if ( $cgiparams { 'VPN_IP' } eq '' && - e
"${General::swroot}/red/active" ) {
2407 if ( open ( IPADDR
, "${General::swroot}/red/local-ipaddress" )) {
2408 my $ipaddr = < IPADDR
>;
2411 $cgiparams { 'VPN_IP' } = ( gethostbyaddr ( pack ( "C4" , split ( /\./ , $ipaddr )), 2 ))[ 0 ];
2412 if ( $cgiparams { 'VPN_IP' } eq '' ) {
2413 $cgiparams { 'VPN_IP' } = $ipaddr ;
2417 # no IP found, use %defaultroute
2418 $cgiparams { 'VPN_IP' } = ' %defaultroute ' if ( $cgiparams { 'VPN_IP' } eq '' );
2420 $cgiparams { 'VPN_DELAYED_START' } = 0 if (! defined ( $cgiparams { 'VPN_DELAYED_START' }));
2421 $checked { 'VPN_WATCH' } = $cgiparams { 'VPN_WATCH' } eq 'on' ?
"checked='checked'" : '' ;
2422 map ( $checked { $_ } = $cgiparams { $_ } eq 'on' ?
"checked='checked'" : '' ,
2423 ( 'ENABLED' , 'DBG_CRYPT' , 'DBG_PARSING' , 'DBG_EMITTING' , 'DBG_CONTROL' ,
2427 & Header
:: showhttpheaders
();
2428 & Header
:: openpage
( $Lang :: tr
{ 'vpn configuration main' }, 1 , '' );
2429 & Header
:: openbigbox
( '100%' , 'left' , '' , $errormessage );
2431 if ( $errormessage ) {
2432 & Header
:: openbox
( '100%' , 'left' , $Lang :: tr
{ 'error messages' });
2433 print "<class name='base'> $errormessage \n " ;
2434 print " </class> \n " ;
2435 & Header
:: closebox
();
2438 & Header
:: openbox
( '100%' , 'left' , $Lang :: tr
{ 'global settings' });
2440 <form method='post' action=' $ENV {'SCRIPT_NAME'}'>
2441 <table width='100%'>
2443 <td width='20%' class='base' nowrap='nowrap'> $Lang ::tr{'vpn red name'}:</td>
2444 <td width='20%'><input type='text' name='VPN_IP' value=' $cgiparams {'VPN_IP'}' /></td>
2445 <td width='20%' class='base'> $Lang ::tr{'enabled'}<input type='checkbox' name='ENABLED' $checked {'ENABLED'} /></td>
2451 <td class='base' nowrap='nowrap'> $Lang ::tr{'override mtu'}: <img src='/blob.gif' alt='*' /></td>
2452 <td ><input type='text' name='VPN_OVERRIDE_MTU' value=' $cgiparams {'VPN_OVERRIDE_MTU'}' /></td>
2458 <td class='base' nowrap='nowrap'> $Lang ::tr{'vpn delayed start'}: <img src='/blob.gif' alt='*' /><img src='/blob.gif' alt='*' /></td>
2459 <td ><input type='text' name='VPN_DELAYED_START' value=' $cgiparams {'VPN_DELAYED_START'}' /></td>
2462 <p> $Lang ::tr{'vpn watch'}:<input type='checkbox' name='VPN_WATCH' $checked {'VPN_WATCH'} /></p>
2463 <p>PLUTO DEBUG =
2464 crypt:<input type='checkbox' name='DBG_CRYPT' $checked {'DBG_CRYPT'} />,
2465 parsing:<input type='checkbox' name='DBG_PARSING' $checked {'DBG_PARSING'} />,
2466 emitting:<input type='checkbox' name='DBG_EMITTING' $checked {'DBG_EMITTING'} />,
2467 control:<input type='checkbox' name='DBG_CONTROL' $checked {'DBG_CONTROL'} />,
2468 dns:<input type='checkbox' name='DBG_DNS' $checked {'DBG_DNS'} />
2470 <table width='100%'>
2472 <td class='base' valign='top'><img src='/blob.gif' alt='*' /></td>
2473 <td width='70%' class='base' valign='top'> $Lang ::tr{'this field may be blank'}</td>
2476 <td class='base' valign='top' nowrap='nowrap'><img src='/blob.gif' alt='*' /><img src='/blob.gif' alt='*' /> </td>
2477 <td class='base'> <font class='base'> $Lang ::tr{'vpn delayed start help'}</font></td>
2478 <td width='30%' align='center' class='base'><input type='submit' name='ACTION' value=' $Lang ::tr{'save'}' /></td>
2484 & Header
:: closebox
();
2486 & Header
:: openbox
( '100%' , 'left' , $Lang :: tr
{ 'connection status and controlc' });
2488 <table width='100%' border='0' cellspacing='1' cellpadding='0'>
2490 <td width='10%' class='boldbase' align='center'><b> $Lang ::tr{'name'}</b></td>
2491 <td width='22%' class='boldbase' align='center'><b> $Lang ::tr{'type'}</b></td>
2492 <td width='23%' class='boldbase' align='center'><b> $Lang ::tr{'common name'}</b></td>
2493 <td width='30%' class='boldbase' align='center'><b> $Lang ::tr{'remark'}</b></td>
2494 <td width='10%' class='boldbase' align='center'><b> $Lang ::tr{'status'}</b></td>
2495 <td class='boldbase' align='center' colspan='6'><b> $Lang ::tr{'action'}</b></td>
2501 foreach my $key ( keys %confighash ) {
2502 if ( $confighash { $key }[ 0 ] eq 'on' ) { $gif = 'on.gif' ; } else { $gif = 'off.gif' ; }
2505 print "<tr bgcolor=' $color {'color20'}'> \n " ;
2507 print "<tr bgcolor=' $color {'color22'}'> \n " ;
2509 print "<td align='center' nowrap='nowrap'> $confighash { $key }[1]</td>" ;
2510 print "<td align='center' nowrap='nowrap'>" . $Lang :: tr
{ " $confighash { $key }[3]" } . " (" . $Lang :: tr
{ " $confighash { $key }[4]" } . ")</td>" ;
2511 if ( $confighash { $key }[ 2 ] eq ' %auth -dn' ) {
2512 print "<td align='left' nowrap='nowrap'> $confighash { $key }[9]</td>" ;
2513 } elsif ( $confighash { $key }[ 4 ] eq 'cert' ) {
2514 print "<td align='left' nowrap='nowrap'> $confighash { $key }[2]</td>" ;
2516 print "<td align='left'> </td>" ;
2518 print "<td align='center'> $confighash { $key }[25]</td>" ;
2520 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>" ;
2521 foreach my $line ( @status ) {
2522 if ( $line =~ /\"$confighash{$key}[1]\".*IPsec SA established/ ) {
2523 $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>" ;
2526 # move to blueif really down
2527 if ( $confighash { $key }[ 0 ] eq 'off' && $active =~ /${Header::colourred}/ ) {
2528 $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>" ;
2531 <td align='center'> $active </td>
2533 <form method='post' action=' $ENV {'SCRIPT_NAME'}'>
2534 <input type='image' name=' $Lang ::tr{'restart'}' src='/images/reload.gif' alt=' $Lang ::tr{'restart'}' title=' $Lang ::tr{'restart'}' />
2535 <input type='hidden' name='ACTION' value=' $Lang ::tr{'restart'}' />
2536 <input type='hidden' name='KEY' value=' $key ' />
2541 if (( $confighash { $key }[ 4 ] eq 'cert' ) && ( $confighash { $key }[ 2 ] ne ' %auth -dn' )) {
2544 <form method='post' action=' $ENV {'SCRIPT_NAME'}'>
2545 <input type='image' name=' $Lang ::tr{'show certificate'}' src='/images/info.gif' alt=' $Lang ::tr{'show certificate'}' title=' $Lang ::tr{'show certificate'}' />
2546 <input type='hidden' name='ACTION' value=' $Lang ::tr{'show certificate'}' />
2547 <input type='hidden' name='KEY' value=' $key ' />
2552 print "<td width='2%'> </td>" ;
2554 if ( $confighash { $key }[ 4 ] eq 'cert' && - f
"${General::swroot}/certs/ $confighash { $key }[1].p12" ) {
2557 <form method='post' action=' $ENV {'SCRIPT_NAME'}'>
2558 <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'}' />
2559 <input type='hidden' name='ACTION' value=' $Lang ::tr{'download pkcs12 file'}' />
2560 <input type='hidden' name='KEY' value=' $key ' />
2564 ; } elsif (( $confighash { $key }[ 4 ] eq 'cert' ) && ( $confighash { $key }[ 2 ] ne ' %auth -dn' )) {
2567 <form method='post' action=' $ENV {'SCRIPT_NAME'}'>
2568 <input type='image' name=' $Lang ::tr{'download certificate'}' src='/images/floppy.gif' alt=' $Lang ::tr{'download certificate'}' title=' $Lang ::tr{'download certificate'}' />
2569 <input type='hidden' name='ACTION' value=' $Lang ::tr{'download certificate'}' />
2570 <input type='hidden' name='KEY' value=' $key ' />
2575 print "<td width='2%'> </td>" ;
2579 <form method='post' action=' $ENV {'SCRIPT_NAME'}'>
2580 <input type='image' name=' $Lang ::tr{'toggle enable disable'}' src='/images/ $gif ' alt=' $Lang ::tr{'toggle enable disable'}' title=' $Lang ::tr{'toggle enable disable'}' />
2581 <input type='hidden' name='ACTION' value=' $Lang ::tr{'toggle enable disable'}' />
2582 <input type='hidden' name='KEY' value=' $key ' />
2587 <form method='post' action=' $ENV {'SCRIPT_NAME'}'>
2588 <input type='hidden' name='ACTION' value=' $Lang ::tr{'edit'}' />
2589 <input type='image' name=' $Lang ::tr{'edit'}' src='/images/edit.gif' alt=' $Lang ::tr{'edit'}' title=' $Lang ::tr{'edit'}' />
2590 <input type='hidden' name='KEY' value=' $key ' />
2593 <td align='center' >
2594 <form method='post' action=' $ENV {'SCRIPT_NAME'}'>
2595 <input type='hidden' name='ACTION' value=' $Lang ::tr{'remove'}' />
2596 <input type='image' name=' $Lang ::tr{'remove'}' src='/images/delete.gif' alt=' $Lang ::tr{'remove'}' title=' $Lang ::tr{'remove'}' />
2597 <input type='hidden' name='KEY' value=' $key ' />
2607 # If the config file contains entries, print Key to action icons
2612 <td class='boldbase'> <b> $Lang ::tr{'legend'}:</b></td>
2613 <td> <img src='/images/on.gif' alt=' $Lang ::tr{'click to disable'}' /></td>
2614 <td class='base'> $Lang ::tr{'click to disable'}</td>
2615 <td> <img src='/images/info.gif' alt=' $Lang ::tr{'show certificate'}' /></td>
2616 <td class='base'> $Lang ::tr{'show certificate'}</td>
2617 <td> <img src='/images/edit.gif' alt=' $Lang ::tr{'edit'}' /></td>
2618 <td class='base'> $Lang ::tr{'edit'}</td>
2619 <td> <img src='/images/delete.gif' alt=' $Lang ::tr{'remove'}' /></td>
2620 <td class='base'> $Lang ::tr{'remove'}</td>
2624 <td> <img src='/images/off.gif' alt='?OFF' /></td>
2625 <td class='base'> $Lang ::tr{'click to enable'}</td>
2626 <td> <img src='/images/floppy.gif' alt='?FLOPPY' /></td>
2627 <td class='base'> $Lang ::tr{'download certificate'}</td>
2628 <td> <img src='/images/reload.gif' alt='?RELOAD'/></td>
2629 <td class='base'> $Lang ::tr{'restart'}</td>
2637 <table width='100%'>
2638 <tr><td align='center' colspan='9'>
2639 <form method='post' action=' $ENV {'SCRIPT_NAME'}'>
2640 <input type='submit' name='ACTION' value=' $Lang ::tr{'add'}' />
2646 & Header
:: closebox
();
2648 & Header
:: openbox
( '100%' , 'left' , " $Lang ::tr{'certificate authorities'}:" );
2650 <table width='100%' border='0' cellspacing='1' cellpadding='0'>
2652 <td width='25%' class='boldbase' align='center'><b> $Lang ::tr{'name'}</b></td>
2653 <td width='65%' class='boldbase' align='center'><b> $Lang ::tr{'subject'}</b></td>
2654 <td width='10%' class='boldbase' colspan='3' align='center'><b> $Lang ::tr{'action'}</b></td>
2658 if (- f
"${General::swroot}/ca/cacert.pem" ) {
2659 my $casubject = & Header
:: cleanhtml
( getsubjectfromcert
( "${General::swroot}/ca/cacert.pem" ));
2662 <tr bgcolor=' $color {'color22'}'>
2663 <td class='base'> $Lang ::tr{'root certificate'}</td>
2664 <td class='base'> $casubject </td>
2665 <td width='3%' align='center'>
2666 <form method='post' action=' $ENV {'SCRIPT_NAME'}'>
2667 <input type='hidden' name='ACTION' value=' $Lang ::tr{'show root certificate'}' />
2668 <input type='image' name=' $Lang ::tr{'edit'}' src='/images/info.gif' alt=' $Lang ::tr{'show root certificate'}' title=' $Lang ::tr{'show root certificate'}' />
2671 <td width='3%' align='center'>
2672 <form method='post' action=' $ENV {'SCRIPT_NAME'}'>
2673 <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'}' />
2674 <input type='hidden' name='ACTION' value=' $Lang ::tr{'download root certificate'}' />
2677 <td width='4%'> </td></tr>
2681 # display rootcert generation buttons
2683 <tr bgcolor=' $color {'color22'}'>
2684 <td class='base'> $Lang ::tr{'root certificate'}:</td>
2685 <td class='base'> $Lang ::tr{'not present'}</td>
2686 <td colspan='3'> </td></tr>
2691 if (- f
"${General::swroot}/certs/hostcert.pem" ) {
2692 my $hostsubject = & Header
:: cleanhtml
( getsubjectfromcert
( "${General::swroot}/certs/hostcert.pem" ));
2695 <tr bgcolor=' $color {'color20'}'>
2696 <td class='base'> $Lang ::tr{'host certificate'}</td>
2697 <td class='base'> $hostsubject </td>
2698 <td width='3%' align='center'>
2699 <form method='post' action=' $ENV {'SCRIPT_NAME'}'>
2700 <input type='hidden' name='ACTION' value=' $Lang ::tr{'show host certificate'}' />
2701 <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'}' />
2704 <td width='3%' align='center'>
2705 <form method='post' action=' $ENV {'SCRIPT_NAME'}'>
2706 <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'}' />
2707 <input type='hidden' name='ACTION' value=' $Lang ::tr{'download host certificate'}' />
2710 <td width='4%'> </td></tr>
2716 <tr bgcolor=' $color {'color20'}'>
2717 <td width='25%' class='base'> $Lang ::tr{'host certificate'}:</td>
2718 <td class='base'> $Lang ::tr{'not present'}</td>
2719 <td colspan='3'> </td></tr>
2725 if ( keys %cahash > 0 ) {
2726 foreach my $key ( keys %cahash ) {
2727 if ( $rowcolor ++ % 2 ) {
2728 print "<tr bgcolor=' $color {'color20'}'> \n " ;
2730 print "<tr bgcolor=' $color {'color22'}'> \n " ;
2732 print "<td class='base'> $cahash { $key }[0]</td> \n " ;
2733 print "<td class='base'> $cahash { $key }[1]</td> \n " ;
2736 <form method='post' name='cafrm${key}a' action=' $ENV {'SCRIPT_NAME'}'>
2737 <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'}' />
2738 <input type='hidden' name='ACTION' value=' $Lang ::tr{'show ca certificate'}' />
2739 <input type='hidden' name='KEY' value=' $key ' />
2743 <form method='post' name='cafrm${key}b' action=' $ENV {'SCRIPT_NAME'}'>
2744 <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'}' />
2745 <input type='hidden' name='ACTION' value=' $Lang ::tr{'download ca certificate'}' />
2746 <input type='hidden' name='KEY' value=' $key ' />
2750 <form method='post' name='cafrm${key}c' action=' $ENV {'SCRIPT_NAME'}'>
2751 <input type='hidden' name='ACTION' value=' $Lang ::tr{'remove ca certificate'}' />
2752 <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'}' />
2753 <input type='hidden' name='KEY' value=' $key ' />
2763 # If the file contains entries, print Key to action icons
2764 if ( - f
"${General::swroot}/ca/cacert.pem" ) {
2767 <td class='boldbase'> <b> $Lang ::tr{'legend'}:</b></td>
2768 <td> <img src='/images/info.gif' alt=' $Lang ::tr{'show certificate'}' /></td>
2769 <td class='base'> $Lang ::tr{'show certificate'}</td>
2770 <td> <img src='/images/floppy.gif' alt=' $Lang ::tr{'download certificate'}' /></td>
2771 <td class='base'> $Lang ::tr{'download certificate'}</td>
2776 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>" ;
2779 <form method='post' enctype='multipart/form-data' action=' $ENV {'SCRIPT_NAME'}'>
2780 <table width='100%' border='0' cellspacing='1' cellpadding='0'>
2783 <td class='base' nowrap='nowrap'> $Lang ::tr{'ca name'}:</td>
2784 <td nowrap='nowrap'><input type='text' name='CA_NAME' value=' $cgiparams {'CA_NAME'}' size='15' /> </td>
2785 <td nowrap='nowrap'><input type='file' name='FH' size='30' /></td>
2786 <td nowrap='nowrap'><input type='submit' name='ACTION' value=' $Lang ::tr{'upload ca certificate'}' /></td>
2789 <td colspan='3'> $Lang ::tr{'resetting the vpn configuration will remove the root ca, the host certificate and all certificate based connections'}:</td>
2790 <td><input type='submit' name='ACTION' value=' $Lang ::tr{'remove x509'}' /></td>
2796 & Header
:: closebox
();
2797 & Header
:: closebigbox
();
2798 & Header
:: closepage
();