]>
git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blob - html/cgi-bin/vpnmain.cgi
5 use File
:: Temp qw
/ tempfile tempdir / ;
8 # enable only the following on debugging purpose
10 #use CGI::Carp 'fatalsToBrowser';
12 require '/var/ipfire/general-functions.pl' ;
13 require "${General::swroot}/lang.pl" ;
14 require "${General::swroot}/header.pl" ;
15 require "${General::swroot}/countries.pl" ;
17 #workaround to suppress a warning when a variable is used only once
18 my @dummy = ( ${ Header
:: colourgreen
}, ${ Header
:: colourblue
} );
22 ### Initialize variables
24 my $sleepDelay = 4 ; # after a call to ipsecctrl S or R, wait this delay (seconds) before reading status
25 # (let the ipsec do its job)
34 my $errormessage = '' ;
36 & General
:: readhash
( "${General::swroot}/ethernet/settings" , \
%netsettings );
37 $cgiparams { 'ENABLED' } = 'off' ;
38 $cgiparams { 'EDIT_ADVANCED' } = 'off' ;
39 $cgiparams { 'ACTION' } = '' ;
40 $cgiparams { 'CA_NAME' } = '' ;
41 $cgiparams { 'DBG_CRYPT' } = '' ;
42 $cgiparams { 'DBG_PARSING' } = '' ;
43 $cgiparams { 'DBG_EMITTING' } = '' ;
44 $cgiparams { 'DBG_CONTROL' } = '' ;
45 $cgiparams { 'DBG_KLIPS' } = '' ;
46 $cgiparams { 'DBG_DNS' } = '' ;
47 $cgiparams { 'DBG_NAT_T' } = '' ;
48 $cgiparams { 'KEY' } = '' ;
49 $cgiparams { 'TYPE' } = '' ;
50 $cgiparams { 'ADVANCED' } = '' ;
51 $cgiparams { 'INTERFACE' } = '' ;
52 $cgiparams { 'NAME' } = '' ;
53 $cgiparams { 'LOCAL_SUBNET' } = '' ;
54 $cgiparams { 'REMOTE_SUBNET' } = '' ;
55 $cgiparams { 'REMOTE' } = '' ;
56 $cgiparams { 'LOCAL_ID' } = '' ;
57 $cgiparams { 'REMOTE_ID' } = '' ;
58 $cgiparams { 'REMARK' } = '' ;
59 $cgiparams { 'PSK' } = '' ;
60 $cgiparams { 'CERT_NAME' } = '' ;
61 $cgiparams { 'CERT_EMAIL' } = '' ;
62 $cgiparams { 'CERT_OU' } = '' ;
63 $cgiparams { 'CERT_ORGANIZATION' } = '' ;
64 $cgiparams { 'CERT_CITY' } = '' ;
65 $cgiparams { 'CERT_STATE' } = '' ;
66 $cgiparams { 'CERT_COUNTRY' } = '' ;
67 $cgiparams { 'SUBJECTALTNAME' } = '' ;
68 $cgiparams { 'CERT_PASS1' } = '' ;
69 $cgiparams { 'CERT_PASS2' } = '' ;
70 $cgiparams { 'ROOTCERT_HOSTNAME' } = '' ;
71 $cgiparams { 'ROOTCERT_COUNTRY' } = '' ;
72 $cgiparams { 'P12_PASS' } = '' ;
73 $cgiparams { 'ROOTCERT_ORGANIZATION' } = '' ;
74 $cgiparams { 'ROOTCERT_HOSTNAME' } = '' ;
75 $cgiparams { 'ROOTCERT_EMAIL' } = '' ;
76 $cgiparams { 'ROOTCERT_OU' } = '' ;
77 $cgiparams { 'ROOTCERT_CITY' } = '' ;
78 $cgiparams { 'ROOTCERT_STATE' } = '' ;
80 & Header
:: getcgihash
( \
%cgiparams , { 'wantfile' => 1 , 'filevar' => 'FH' });
87 unless ( $hostname ) { return "No hostname" };
88 my $res = new Net
:: DNS
:: Resolver
;
89 my $query = $res -> search ( " $hostname " );
91 foreach my $rr ( $query -> answer ) {
92 ## Potential bug - we are only looking at A records:
93 return 0 if $rr -> type eq "A" ;
96 return $res -> errorstring ;
100 ### Just return true is one interface is vpn enabled
103 return ( $vpnsettings { 'ENABLED' } eq 'on' );
106 ### old version: maintain serial number to one, without explication.
107 ### this : let the counter go, so that each cert is numbered.
111 if ( open ( FILE
, ">${General::swroot}/certs/serial" )) {
115 if ( open ( FILE
, ">${General::swroot}/certs/index.txt" )) {
119 unlink ( "${General::swroot}/certs/index.txt.old" );
120 unlink ( "${General::swroot}/certs/serial.old" );
121 unlink ( "${General::swroot}/certs/01.pem" );
123 sub newcleanssldatabase
125 if (! - s
"${General::swroot}/certs/serial" ) {
126 open ( FILE
, ">${General::swroot}/certs/serial" );
130 if (! - s
">${General::swroot}/certs/index.txt" ) {
131 system ( "touch ${General::swroot}/certs/index.txt" );
133 unlink ( "${General::swroot}/certs/index.txt.old" );
134 unlink ( "${General::swroot}/certs/serial.old" );
135 # unlink ("${General::swroot}/certs/01.pem"); numbering evolves. Wrong place to delete
139 ### Call openssl and return errormessage if any
143 my $retssl = `/usr/bin/openssl $opt 2>&1` ; #redirect stderr
145 foreach my $line ( split ( /\n/ , $retssl )) {
146 & General
:: log ( "ipsec" , " $line " ) if ( 0 ); # 1 for verbose logging
147 $ret .= '<br>' . $line if ( $line =~ /error|unknown/ );
150 $ret = & Header
:: cleanhtml
( $ret );
152 return $ret ?
" $Lang ::tr{'openssl produced an error'}: $ret " : '' ;
155 ### Obtain a CN from given cert
157 sub getCNfromcert
($) {
158 #&General::log("ipsec", "Extracting name from $_[0]...");
159 my $temp = `/usr/bin/openssl x509 -text -in $_ [0]` ;
160 $temp =~ /Subject:.*CN=(.*)[\n]/ ;
162 $temp =~ s
+/ Email
+, E
+;
163 $temp =~ s/ ST=/ S=/ ;
169 ### Obtain Subject from given cert
171 sub getsubjectfromcert
($) {
172 #&General::log("ipsec", "Extracting subject from $_[0]...");
173 my $temp = `/usr/bin/openssl x509 -text -in $_ [0]` ;
174 $temp =~ /Subject: (.*)[\n]/ ;
176 $temp =~ s
+/ Email
+, E
+;
177 $temp =~ s/ ST=/ S=/ ;
181 ### Combine local subnet and connection name to make a unique name for each connection section
182 ### (this sub is not used now)
184 sub makeconnname
($) {
188 $subnet =~ /^(.*?)\/ (.* ?
)$/; # $1=IP $2=mask
189 my $ip = unpack ( 'N' , & Socket
:: inet_aton
( $1 ));
190 if ( length ( $2 ) > 2 ) {
191 my $mm = unpack ( 'N' , & Socket
:: inet_aton
( $2 ));
192 while ( ( $mm & 1 )== 0 ) {
199 return sprintf ( " %s - %X " , $conn , $ip );
202 ### Write a config file.
204 ###Type=Host : GUI can choose the interface used (RED,GREEN,BLUE) and
205 ### the side is always defined as 'left'.
206 ### configihash[14]: 'VHOST' is allowed
209 sub writeipsecfiles
{
210 my %lconfighash = ();
211 my %lvpnsettings = ();
212 & General
:: readhasharray
( "${General::swroot}/vpn/config" , \
%lconfighash );
213 & General
:: readhash
( "${General::swroot}/vpn/settings" , \
%lvpnsettings );
215 open ( CONF
, ">${General::swroot}/vpn/ipsec.conf" ) or die "Unable to open ${General::swroot}/vpn/ipsec.conf: $!" ;
216 open ( SECRETS
, ">${General::swroot}/vpn/ipsec.secrets" ) or die "Unable to open ${General::swroot}/vpn/ipsec.secrets: $!" ;
219 print CONF
"version 2 \n\n " ;
220 print CONF
"config setup \n " ;
221 #create an ipsec Interface for each 'enabled' ones
222 #loop trought configuration and add physical interfaces to the list
223 my $interfaces = " \t interfaces= \" " ;
224 foreach my $key ( keys %lconfighash ) {
225 next if ( $lconfighash { $key }[ 0 ] ne 'on' );
226 $interfaces .= " %defaultroute " if ( $interfaces !~ /defaultroute/ && $lconfighash { $key }[ 26 ] eq 'RED' );
227 $interfaces .= "ipsec1= $netsettings {'GREEN_DEV'} " if ( $interfaces !~ /ipsec1/ && $lconfighash { $key }[ 26 ] eq 'GREEN' );
228 $interfaces .= "ipsec2= $netsettings {'BLUE_DEV'} " if ( $interfaces !~ /ipsec2/ && $lconfighash { $key }[ 26 ] eq 'BLUE' );
229 $interfaces .= "ipsec3= $netsettings {'ORANGE_DEV'} " if ( $interfaces !~ /ipsec3/ && $lconfighash { $key }[ 26 ] eq 'ORANGE' );
231 print CONF
$interfaces . " \"\n " ;
233 my $plutodebug = '' ; # build debug list
234 map ( $plutodebug .= $lvpnsettings { $_ } eq 'on' ?
lc ( substr ( $_ , 4 )). ' ' : '' ,
235 ( 'DBG_CRYPT' , 'DBG_PARSING' , 'DBG_EMITTING' , 'DBG_CONTROL' ,
236 'DBG_KLIPS' , 'DBG_DNS' , 'DBG_NAT_T' ));
237 $plutodebug = 'none' if $plutodebug eq '' ; # if nothing selected, use 'none'.
238 print CONF
" \t klipsdebug= \" none \"\n " ;
239 print CONF
" \t plutodebug= \" $plutodebug \"\n " ;
240 # deprecated in ipsec.conf version 2
241 #print CONF "\tplutoload=%search\n";
242 #print CONF "\tplutostart=%search\n";
243 print CONF
" \t uniqueids=yes \n " ;
244 print CONF
" \t nat_traversal=yes \n " ;
245 print CONF
" \t overridemtu= $lvpnsettings {'VPN_OVERRIDE_MTU'} \n " if ( $lvpnsettings { 'VPN_OVERRIDE_MTU' } ne '' );
246 print CONF
" \t virtual_private= %v4 :10.0.0.0/8, %v4 :172.16.0.0/12, %v4 :192.168.0.0/16" ;
247 print CONF
", %v4 :! $netsettings {'GREEN_NETADDRESS'}/ $netsettings {'GREEN_NETMASK'}" ;
248 if ( length ( $netsettings { 'ORANGE_DEV' }) > 2 ) {
249 print CONF
", %v4 :! $netsettings {'ORANGE_NETADDRESS'}/ $netsettings {'ORANGE_NETMASK'}" ;
251 if ( length ( $netsettings { 'BLUE_DEV' }) > 2 ) {
252 print CONF
", %v4 :! $netsettings {'BLUE_NETADDRESS'}/ $netsettings {'BLUE_NETMASK'}" ;
254 foreach my $key ( keys %lconfighash ) {
255 if ( $lconfighash { $key }[ 3 ] eq 'net' ) {
256 print CONF
", %v4 :! $lconfighash { $key }[11]" ;
260 print CONF
"conn %default \n " ;
261 print CONF
" \t keyingtries=0 \n " ;
262 print CONF
" \t disablearrivalcheck=no \n " ;
265 if (- f
"${General::swroot}/certs/hostkey.pem" ) {
266 print SECRETS
": RSA ${General::swroot}/certs/hostkey.pem \n "
268 my $last_secrets = '' ; # old the less specifics connections
270 foreach my $key ( keys %lconfighash ) {
271 next if ( $lconfighash { $key }[ 0 ] ne 'on' );
273 #remote peer is not set? => use '%any'
274 $lconfighash { $key }[ 10 ] = ' %any ' if ( $lconfighash { $key }[ 10 ] eq '' );
277 if ( $lconfighash { $key }[ 26 ] eq 'BLUE' ) {
278 $localside = $netsettings { 'BLUE_ADDRESS' };
279 } elsif ( $lconfighash { $key }[ 26 ] eq 'GREEN' ) {
280 $localside = $netsettings { 'GREEN_ADDRESS' };
281 } elsif ( $lconfighash { $key }[ 26 ] eq 'ORANGE' ) {
282 $localside = $netsettings { 'ORANGE_ADDRESS' };
284 $localside = $lvpnsettings { 'VPN_IP' };
287 print CONF
"conn $lconfighash { $key }[1] # $lconfighash { $key }[26] \n " ;
288 print CONF
" \t left= $localside \n " ;
289 print CONF
" \t leftnexthop= %defaultroute \n " if ( $lconfighash { $key }[ 26 ] eq 'RED' && $lvpnsettings { 'VPN_IP' } ne ' %defaultroute ' );
290 print CONF
" \t leftsubnet= $lconfighash { $key }[8] \n " ;
292 print CONF
" \t right= $lconfighash { $key }[10] \n " ;
293 if ( $lconfighash { $key }[ 3 ] eq 'net' ) {
294 print CONF
" \t rightsubnet= $lconfighash { $key }[11] \n " ;
295 print CONF
" \t rightnexthop= %defaultroute \n " ;
296 } elsif ( $lconfighash { $key }[ 10 ] eq ' %any ' && $lconfighash { $key }[ 14 ] eq 'on' ) { #vhost allowed for roadwarriors?
297 print CONF
" \t rightsubnet=vhost: %no , %priv \n " ;
300 # Local Cert and Remote Cert (unless auth is DN dn-auth)
301 if ( $lconfighash { $key }[ 4 ] eq 'cert' ) {
302 print CONF
" \t leftcert=${General::swroot}/certs/hostcert.pem \n " ;
303 print CONF
" \t rightcert=${General::swroot}/certs/ $lconfighash { $key }[1]cert.pem \n " if ( $lconfighash { $key }[ 2 ] ne ' %auth -dn' );
306 # Local and Remote IDs
307 print CONF
" \t leftid= \" $lconfighash { $key }[7] \"\n " if ( $lconfighash { $key }[ 7 ]);
308 print CONF
" \t rightid= \" $lconfighash { $key }[9] \"\n " if ( $lconfighash { $key }[ 9 ]);
311 if ( $lconfighash { $key }[ 18 ] && $lconfighash { $key }[ 19 ] && $lconfighash { $key }[ 20 ]) {
313 my @encs = split ( '\|' , $lconfighash { $key }[ 18 ]);
314 my @ints = split ( '\|' , $lconfighash { $key }[ 19 ]);
315 my @groups = split ( '\|' , $lconfighash { $key }[ 20 ]);
317 foreach my $i ( @encs ) {
318 foreach my $j ( @ints ) {
319 foreach my $k ( @groups ) {
320 if ( $comma != 0 ) { print CONF
"," ; } else { $comma = 1 ; }
321 print CONF
" $i - $j -modp $k " ;
325 if ( $lconfighash { $key }[ 24 ] eq 'on' ) { #only proposed algorythms?
331 if ( $lconfighash { $key }[ 21 ] && $lconfighash { $key }[ 22 ]) {
333 my @encs = split ( '\|' , $lconfighash { $key }[ 21 ]);
334 my @ints = split ( '\|' , $lconfighash { $key }[ 22 ]);
336 foreach my $i ( @encs ) {
337 foreach my $j ( @ints ) {
338 if ( $comma != 0 ) { print CONF
"," ; } else { $comma = 1 ; }
342 if ( $lconfighash { $key }[ 24 ] eq 'on' ) { #only proposed algorythms?
348 if ( $lconfighash { $key }[ 23 ]) {
349 print CONF
" \t pfsgroup= $lconfighash { $key }[23] \n " ;
353 print CONF
" \t ikelifetime= $lconfighash { $key }[16]h \n " if ( $lconfighash { $key }[ 16 ]);
354 print CONF
" \t keylife= $lconfighash { $key }[17]h \n " if ( $lconfighash { $key }[ 17 ]);
357 print CONF
" \t aggrmode=yes \n " if ( $lconfighash { $key }[ 12 ] eq 'on' );
360 print CONF
" \t compress=yes \n " if ( $lconfighash { $key }[ 13 ] eq 'on' );
362 # Dead Peer Detection
363 print CONF
" \t dpddelay=30 \n " ;
364 print CONF
" \t dpdtimeout=120 \n " ;
365 print CONF
" \t dpdaction= $lconfighash { $key }[27] \n " ;
368 print CONF
" \t pfs=" . ( $lconfighash { $key }[ 28 ] eq 'on' ?
"yes \n " : "no \n " );
370 # Build Authentication details: LEFTid RIGHTid : PSK psk
372 if ( $lconfighash { $key }[ 4 ] eq 'psk' ) {
373 $psk_line = ( $lconfighash { $key }[ 7 ] ?
$lconfighash { $key }[ 7 ] : $localside ) . " " ;
374 $psk_line .= $lconfighash { $key }[ 9 ] ?
$lconfighash { $key }[ 9 ] : $lconfighash { $key }[ 10 ]; #remoteid or remote address?
375 $psk_line .= " : PSK ' $lconfighash { $key }[5]' \n " ;
376 # if the line contains %any, it is less specific than two IP or ID, so move it at end of file.
377 if ( $psk_line =~ /%any/ ) {
378 $last_secrets .= $psk_line ;
380 print SECRETS
$psk_line ;
382 print CONF
" \t authby=secret \n " ;
384 print CONF
" \t authby=rsasig \n " ;
385 print CONF
" \t leftrsasigkey= %cert \n " ;
386 print CONF
" \t rightrsasigkey= %cert \n " ;
389 # Automatically start only if a net-to-net connection
390 if ( $lconfighash { $key }[ 3 ] eq 'host' ) {
391 print CONF
" \t auto=add \n " ;
393 print CONF
" \t auto=start \n " ;
397 print SECRETS
$last_secrets if ( $last_secrets );
403 ### Save main settings
405 if ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'save' } && $cgiparams { 'TYPE' } eq '' && $cgiparams { 'KEY' } eq '' ) {
406 & General
:: readhash
( "${General::swroot}/vpn/settings" , \
%vpnsettings );
407 unless (& General
:: validfqdn
( $cgiparams { 'VPN_IP' }) || & General
:: validip
( $cgiparams { 'VPN_IP' })
408 || $cgiparams { 'VPN_IP' } eq ' %defaultroute ' ) {
409 $errormessage = $Lang :: tr
{ 'invalid input for hostname' };
413 unless ( $cgiparams { 'VPN_DELAYED_START' } =~ /^[0-9]{1,3}$/ ) { #allow 0-999 seconds !
414 $errormessage = $Lang :: tr
{ 'invalid time period' };
418 unless ( $cgiparams { 'VPN_OVERRIDE_MTU' } =~ /^(|[0-9]{1,5})$/ ) { #allow 0-99999
419 $errormessage = $Lang :: tr
{ 'vpn mtu invalid' };
423 unless ( $cgiparams { 'VPN_WATCH' } =~ /^(|off|on)$/ ) {
424 $errormessage = $Lang :: tr
{ 'invalid input' };
428 map ( $vpnsettings { $_ } = $cgiparams { $_ },
429 ( 'ENABLED' , 'DBG_CRYPT' , 'DBG_PARSING' , 'DBG_EMITTING' , 'DBG_CONTROL' ,
430 'DBG_KLIPS' , 'DBG_DNS' , 'DBG_NAT_T' ));
432 $vpnsettings { 'VPN_IP' } = $cgiparams { 'VPN_IP' };
433 $vpnsettings { 'VPN_DELAYED_START' } = $cgiparams { 'VPN_DELAYED_START' };
434 $vpnsettings { 'VPN_OVERRIDE_MTU' } = $cgiparams { 'VPN_OVERRIDE_MTU' };
435 $vpnsettings { 'VPN_WATCH' } = $cgiparams { 'VPN_WATCH' };
436 & General
:: writehash
( "${General::swroot}/vpn/settings" , \
%vpnsettings );
439 system ( '/usr/local/bin/ipsecctrl' , 'S' );
441 system ( '/usr/local/bin/ipsecctrl' , 'D' );
448 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'remove x509' } && $cgiparams { 'AREUSURE' } eq 'yes' ) {
449 & General
:: readhasharray
( "${General::swroot}/vpn/config" , \
%confighash );
451 foreach my $key ( keys %confighash ) {
452 if ( $confighash { $key }[ 4 ] eq 'cert' ) {
453 delete $confighash { $key };
456 while ( my $file = glob ( "${General::swroot}/{ca,certs,crls,private}/*" )) {
460 if ( open ( FILE
, ">${General::swroot}/vpn/caconfig" )) {
464 & General
:: writehasharray
( "${General::swroot}/vpn/config" , \
%confighash );
466 system ( '/usr/local/bin/ipsecctrl' , 'R' );
472 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'remove x509' }) {
473 & Header
:: showhttpheaders
();
474 & Header
:: openpage
( $Lang :: tr
{ 'vpn configuration main' }, 1 , '' );
475 & Header
:: openbigbox
( '100%' , 'left' , '' , '' );
476 & Header
:: openbox
( '100%' , 'left' , $Lang :: tr
{ 'are you sure' });
478 <form method='post' action=' $ENV {'SCRIPT_NAME'}'>
482 <input type='hidden' name='AREUSURE' value='yes' />
483 <b><font color='${Header::colourred}'> $Lang ::tr{'capswarning'}</font></b>:
484 $Lang ::tr{'resetting the vpn configuration will remove the root ca, the host certificate and all certificate based connections'}</td>
487 <input type='submit' name='ACTION' value=' $Lang ::tr{'remove x509'}' />
488 <input type='submit' name='ACTION' value=' $Lang ::tr{'cancel'}' /></td>
495 & Header
:: closebigbox
();
496 & Header
:: closepage
();
500 ### Upload CA Certificate
502 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'upload ca certificate' }) {
503 & General
:: readhasharray
( "${General::swroot}/vpn/caconfig" , \
%cahash );
505 if ( $cgiparams { 'CA_NAME' } !~ /^[a-zA-Z0-9]+$/ ) {
506 $errormessage = $Lang :: tr
{ 'name must only contain characters' };
510 if ( length ( $cgiparams { 'CA_NAME' }) > 60 ) {
511 $errormessage = $Lang :: tr
{ 'name too long' };
515 if ( $cgiparams { 'CA_NAME' } eq 'ca' ) {
516 $errormessage = $Lang :: tr
{ 'name is invalid' };
517 goto UPLOAD_CA_ERROR
;
520 # Check if there is no other entry with this name
521 foreach my $key ( keys %cahash ) {
522 if ( $cahash { $key }[ 0 ] eq $cgiparams { 'CA_NAME' }) {
523 $errormessage = $Lang :: tr
{ 'a ca certificate with this name already exists' };
528 if ( ref ( $cgiparams { 'FH' }) ne 'Fh' ) {
529 $errormessage = $Lang :: tr
{ 'there was no file upload' };
532 # Move uploaded ca to a temporary file
533 ( my $fh , my $filename ) = tempfile
( );
534 if ( copy
( $cgiparams { 'FH' }, $fh ) != 1 ) {
538 my $temp = `/usr/bin/openssl x509 -text -in $filename ` ;
539 if ( $temp !~ /CA:TRUE/i ) {
540 $errormessage = $Lang :: tr
{ 'not a valid ca certificate' };
544 move
( $filename , "${General::swroot}/ca/ $cgiparams {'CA_NAME'}cert.pem" );
546 $errormessage = " $Lang ::tr{'certificate file move failed'}: $!" ;
552 my $key = & General
:: findhasharraykey
( \
%cahash );
553 $cahash { $key }[ 0 ] = $cgiparams { 'CA_NAME' };
554 $cahash { $key }[ 1 ] = & Header
:: cleanhtml
( getsubjectfromcert
( "${General::swroot}/ca/ $cgiparams {'CA_NAME'}cert.pem" ));
555 & General
:: writehasharray
( "${General::swroot}/vpn/caconfig" , \
%cahash );
556 system ( '/usr/local/bin/ipsecctrl' , 'R' );
562 ### Display ca certificate
564 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'show ca certificate' }) {
565 & General
:: readhasharray
( "${General::swroot}/vpn/caconfig" , \
%cahash );
567 if ( - f
"${General::swroot}/ca/ $cahash { $cgiparams {'KEY'}}[0]cert.pem" ) {
568 & Header
:: showhttpheaders
();
569 & Header
:: openpage
( $Lang :: tr
{ 'vpn configuration main' }, 1 , '' );
570 & Header
:: openbigbox
( '100%' , 'left' , '' , '' );
571 & Header
:: openbox
( '100%' , 'left' , " $Lang ::tr{'ca certificate'}:" );
572 my $output = `/usr/bin/openssl x509 -text -in ${General::swroot}/ca/ $cahash { $cgiparams {'KEY'}}[0]cert.pem` ;
573 $output = & Header
:: cleanhtml
( $output , "y" );
574 print "<pre> $output </pre> \n " ;
576 print "<div align='center'><a href='/cgi-bin/vpnmain.cgi'> $Lang ::tr{'back'}</a></div>" ;
577 & Header
:: closebigbox
();
578 & Header
:: closepage
();
581 $errormessage = $Lang :: tr
{ 'invalid key' };
585 ### Export ca certificate to browser
587 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'download ca certificate' }) {
588 & General
:: readhasharray
( "${General::swroot}/vpn/caconfig" , \
%cahash );
590 if ( - f
"${General::swroot}/ca/ $cahash { $cgiparams {'KEY'}}[0]cert.pem" ) {
591 print "Content-Type: application/force-download \n " ;
592 print "Content-Type: application/octet-stream \r\n " ;
593 print "Content-Disposition: attachment; filename= $cahash { $cgiparams {'KEY'}}[0]cert.pem \r\n\r\n " ;
594 print `/usr/bin/openssl x509 -in ${General::swroot}/ca/ $cahash { $cgiparams {'KEY'}}[0]cert.pem` ;
597 $errormessage = $Lang :: tr
{ 'invalid key' };
601 ### Remove ca certificate (step 2)
603 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'remove ca certificate' } && $cgiparams { 'AREUSURE' } eq 'yes' ) {
604 & General
:: readhasharray
( "${General::swroot}/vpn/config" , \
%confighash );
605 & General
:: readhasharray
( "${General::swroot}/vpn/caconfig" , \
%cahash );
607 if ( - f
"${General::swroot}/ca/ $cahash { $cgiparams {'KEY'}}[0]cert.pem" ) {
608 foreach my $key ( keys %confighash ) {
609 my $test = `/usr/bin/openssl verify -CAfile ${General::swroot}/ca/ $cahash { $cgiparams {'KEY'}}[0]cert.pem ${General::swroot}/certs/ $confighash { $key }[1]cert.pem` ;
610 if ( $test =~ /: OK/ ) {
612 system ( '/usr/local/bin/ipsecctrl' , 'D' , $key ) if (& vpnenabled
);
613 unlink ( "${General::swroot}/certs/ $confighash { $key }[1]cert.pem" );
614 unlink ( "${General::swroot}/certs/ $confighash { $key }[1].p12" );
615 delete $confighash { $key };
616 & General
:: writehasharray
( "${General::swroot}/vpn/config" , \
%confighash );
620 unlink ( "${General::swroot}/ca/ $cahash { $cgiparams {'KEY'}}[0]cert.pem" );
621 delete $cahash { $cgiparams { 'KEY' }};
622 & General
:: writehasharray
( "${General::swroot}/vpn/caconfig" , \
%cahash );
623 system ( '/usr/local/bin/ipsecctrl' , 'R' );
626 $errormessage = $Lang :: tr
{ 'invalid key' };
629 ### Remove ca certificate (step 1)
631 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'remove ca certificate' }) {
632 & General
:: readhasharray
( "${General::swroot}/vpn/config" , \
%confighash );
633 & General
:: readhasharray
( "${General::swroot}/vpn/caconfig" , \
%cahash );
635 my $assignedcerts = 0 ;
636 if ( - f
"${General::swroot}/ca/ $cahash { $cgiparams {'KEY'}}[0]cert.pem" ) {
637 foreach my $key ( keys %confighash ) {
638 my $test = `/usr/bin/openssl verify -CAfile ${General::swroot}/ca/ $cahash { $cgiparams {'KEY'}}[0]cert.pem ${General::swroot}/certs/ $confighash { $key }[1]cert.pem` ;
639 if ( $test =~ /: OK/ ) {
643 if ( $assignedcerts ) {
644 & Header
:: showhttpheaders
();
645 & Header
:: openpage
( $Lang :: tr
{ 'vpn configuration main' }, 1 , '' );
646 & Header
:: openbigbox
( '100%' , 'left' , '' , '' );
647 & Header
:: openbox
( '100%' , 'left' , $Lang :: tr
{ 'are you sure' });
649 <form method='post' action=' $ENV {'SCRIPT_NAME'}'>
653 <input type='hidden' name='KEY' value=' $cgiparams {'KEY'}' />
654 <input type='hidden' name='AREUSURE' value='yes' /></td>
657 <b><font color='${Header::colourred}'> $Lang ::tr{'capswarning'}</font></b>
658 $Lang ::tr{'connections are associated with this ca. deleting the ca will delete these connections as well.'}</td>
661 <input type='submit' name='ACTION' value=' $Lang ::tr{'remove ca certificate'}' />
662 <input type='submit' name='ACTION' value=' $Lang ::tr{'cancel'}' /></td>
669 & Header
:: closebigbox
();
670 & Header
:: closepage
();
673 unlink ( "${General::swroot}/ca/ $cahash { $cgiparams {'KEY'}}[0]cert.pem" );
674 delete $cahash { $cgiparams { 'KEY' }};
675 & General
:: writehasharray
( "${General::swroot}/vpn/caconfig" , \
%cahash );
676 system ( '/usr/local/bin/ipsecctrl' , 'R' );
680 $errormessage = $Lang :: tr
{ 'invalid key' };
684 ### Display root certificate
686 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'show root certificate' } ||
687 $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'show host certificate' }) {
689 & Header
:: showhttpheaders
();
690 & Header
:: openpage
( $Lang :: tr
{ 'vpn configuration main' }, 1 , '' );
691 & Header
:: openbigbox
( '100%' , 'left' , '' , '' );
692 if ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'show root certificate' }) {
693 & Header
:: openbox
( '100%' , 'left' , " $Lang ::tr{'root certificate'}:" );
694 $output = `/usr/bin/openssl x509 -text -in ${General::swroot}/ca/cacert.pem` ;
696 & Header
:: openbox
( '100%' , 'left' , " $Lang ::tr{'host certificate'}:" );
697 $output = `/usr/bin/openssl x509 -text -in ${General::swroot}/certs/hostcert.pem` ;
699 $output = & Header
:: cleanhtml
( $output , "y" );
700 print "<pre> $output </pre> \n " ;
702 print "<div align='center'><a href='/cgi-bin/vpnmain.cgi'> $Lang ::tr{'back'}</a></div>" ;
703 & Header
:: closebigbox
();
704 & Header
:: closepage
();
708 ### Export root certificate to browser
710 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'download root certificate' }) {
711 if ( - f
"${General::swroot}/ca/cacert.pem" ) {
712 print "Content-Type: application/force-download \n " ;
713 print "Content-Disposition: attachment; filename=cacert.pem \r\n\r\n " ;
714 print `/usr/bin/openssl x509 -in ${General::swroot}/ca/cacert.pem` ;
718 ### Export host certificate to browser
720 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'download host certificate' }) {
721 if ( - f
"${General::swroot}/certs/hostcert.pem" ) {
722 print "Content-Type: application/force-download \n " ;
723 print "Content-Disposition: attachment; filename=hostcert.pem \r\n\r\n " ;
724 print `/usr/bin/openssl x509 -in ${General::swroot}/certs/hostcert.pem` ;
728 ### Form for generating/importing the caroot+host certificate
730 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'generate root/host certificates' } ||
731 $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'upload p12 file' }) {
733 if (- f
"${General::swroot}/ca/cacert.pem" ) {
734 $errormessage = $Lang :: tr
{ 'valid root certificate already exists' };
738 & General
:: readhash
( "${General::swroot}/vpn/settings" , \
%vpnsettings );
739 # fill in initial values
740 if ( $cgiparams { 'ROOTCERT_HOSTNAME' } eq '' ) {
741 if (- e
"${General::swroot}/red/active" && open ( IPADDR
, "${General::swroot}/red/local-ipaddress" )) {
742 my $ipaddr = < IPADDR
>;
745 $cgiparams { 'ROOTCERT_HOSTNAME' } = ( gethostbyaddr ( pack ( "C4" , split ( /\./ , $ipaddr )), 2 ))[ 0 ];
746 if ( $cgiparams { 'ROOTCERT_HOSTNAME' } eq '' ) {
747 $cgiparams { 'ROOTCERT_HOSTNAME' } = $ipaddr ;
750 $cgiparams { 'ROOTCERT_COUNTRY' } = $vpnsettings { 'ROOTCERT_COUNTRY' } if (! $cgiparams { 'ROOTCERT_COUNTRY' });
751 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'upload p12 file' }) {
752 & General
:: log ( "ipsec" , "Importing from p12..." );
754 if ( ref ( $cgiparams { 'FH' }) ne 'Fh' ) {
755 $errormessage = $Lang :: tr
{ 'there was no file upload' };
759 # Move uploaded certificate request to a temporary file
760 ( my $fh , my $filename ) = tempfile
( );
761 if ( copy
( $cgiparams { 'FH' }, $fh ) != 1 ) {
766 # Extract the CA certificate from the file
767 & General
:: log ( "ipsec" , "Extracting caroot from p12..." );
768 if ( open ( STDIN
, "-|" )) {
769 my $opt = " pkcs12 -cacerts -nokeys" ;
770 $opt .= " -in $filename " ;
771 $opt .= " -out /tmp/newcacert" ;
772 $errormessage = & callssl
( $opt );
774 print " $cgiparams {'P12_PASS'} \n " ;
778 # Extract the Host certificate from the file
779 if (! $errormessage ) {
780 & General
:: log ( "ipsec" , "Extracting host cert from p12..." );
781 if ( open ( STDIN
, "-|" )) {
782 my $opt = " pkcs12 -clcerts -nokeys" ;
783 $opt .= " -in $filename " ;
784 $opt .= " -out /tmp/newhostcert" ;
785 $errormessage = & callssl
( $opt );
787 print " $cgiparams {'P12_PASS'} \n " ;
792 # Extract the Host key from the file
793 if (! $errormessage ) {
794 & General
:: log ( "ipsec" , "Extracting private key from p12..." );
795 if ( open ( STDIN
, "-|" )) {
796 my $opt = " pkcs12 -nocerts -nodes" ;
797 $opt .= " -in $filename " ;
798 $opt .= " -out /tmp/newhostkey" ;
799 $errormessage = & callssl
( $opt );
801 print " $cgiparams {'P12_PASS'} \n " ;
806 if (! $errormessage ) {
807 & General
:: log ( "ipsec" , "Moving cacert..." );
808 move
( "/tmp/newcacert" , "${General::swroot}/ca/cacert.pem" );
809 $errormessage = " $Lang ::tr{'certificate file move failed'}: $!" if ($ ?
ne 0 );
812 if (! $errormessage ) {
813 & General
:: log ( "ipsec" , "Moving host cert..." );
814 move
( "/tmp/newhostcert" , "${General::swroot}/certs/hostcert.pem" );
815 $errormessage = " $Lang ::tr{'certificate file move failed'}: $!" if ($ ?
ne 0 );
818 if (! $errormessage ) {
819 & General
:: log ( "ipsec" , "Moving private key..." );
820 move
( "/tmp/newhostkey" , "${General::swroot}/certs/hostkey.pem" );
821 $errormessage = " $Lang ::tr{'certificate file move failed'}: $!" if ($ ?
ne 0 );
826 unlink ( '/tmp/newcacert' );
827 unlink ( '/tmp/newhostcert' );
828 unlink ( '/tmp/newhostkey' );
830 unlink ( "${General::swroot}/ca/cacert.pem" );
831 unlink ( "${General::swroot}/certs/hostcert.pem" );
832 unlink ( "${General::swroot}/certs/hostkey.pem" );
836 # Create empty CRL cannot be done because we don't have
837 # the private key for this CAROOT
838 # IPFire can only import certificates
840 & General
:: log ( "ipsec" , "p12 import completed!" );
842 goto ROOTCERT_SUCCESS
;
844 } elsif ( $cgiparams { 'ROOTCERT_COUNTRY' } ne '' ) {
846 # Validate input since the form was submitted
847 if ( $cgiparams { 'ROOTCERT_ORGANIZATION' } eq '' ){
848 $errormessage = $Lang :: tr
{ 'organization cant be empty' };
851 if ( length ( $cgiparams { 'ROOTCERT_ORGANIZATION' }) > 60 ) {
852 $errormessage = $Lang :: tr
{ 'organization too long' };
855 if ( $cgiparams { 'ROOTCERT_ORGANIZATION' } !~ /^[a-zA-Z0-9 ,\.\-_]*$/ ) {
856 $errormessage = $Lang :: tr
{ 'invalid input for organization' };
859 if ( $cgiparams { 'ROOTCERT_HOSTNAME' } eq '' ){
860 $errormessage = $Lang :: tr
{ 'hostname cant be empty' };
863 unless (& General
:: validfqdn
( $cgiparams { 'ROOTCERT_HOSTNAME' }) || & General
:: validip
( $cgiparams { 'ROOTCERT_HOSTNAME' })) {
864 $errormessage = $Lang :: tr
{ 'invalid input for hostname' };
867 if ( $cgiparams { 'ROOTCERT_EMAIL' } ne '' && (! & General
:: validemail
( $cgiparams { 'ROOTCERT_EMAIL' }))) {
868 $errormessage = $Lang :: tr
{ 'invalid input for e-mail address' };
871 if ( length ( $cgiparams { 'ROOTCERT_EMAIL' }) > 40 ) {
872 $errormessage = $Lang :: tr
{ 'e-mail address too long' };
875 if ( $cgiparams { 'ROOTCERT_OU' } ne '' && $cgiparams { 'ROOTCERT_OU' } !~ /^[a-zA-Z0-9 ,\.\-_]*$/ ) {
876 $errormessage = $Lang :: tr
{ 'invalid input for department' };
879 if ( $cgiparams { 'ROOTCERT_CITY' } ne '' && $cgiparams { 'ROOTCERT_CITY' } !~ /^[a-zA-Z0-9 ,\.\-_]*$/ ) {
880 $errormessage = $Lang :: tr
{ 'invalid input for city' };
883 if ( $cgiparams { 'ROOTCERT_STATE' } ne '' && $cgiparams { 'ROOTCERT_STATE' } !~ /^[a-zA-Z0-9 ,\.\-_]*$/ ) {
884 $errormessage = $Lang :: tr
{ 'invalid input for state or province' };
887 if ( $cgiparams { 'ROOTCERT_COUNTRY' } !~ /^[A-Z]*$/ ) {
888 $errormessage = $Lang :: tr
{ 'invalid input for country' };
891 #the exact syntax is a list comma separated of
892 # email:any-validemail
893 # URI: a uniform resource indicator
894 # DNS: a DNS domain name
895 # RID: a registered OBJECT IDENTIFIER
897 # example: email:franck@foo.com,IP:10.0.0.10,DNS:franck.foo.com
899 if ( $cgiparams { 'SUBJECTALTNAME' } ne '' && $cgiparams { 'SUBJECTALTNAME' } !~ /^(email|URI|DNS|RID|IP):[a-zA-Z0-9 :\/ , \
. \
- _@
]*$/) {
900 $errormessage = $Lang :: tr
{ 'vpn altname syntax' };
904 # Copy the cgisettings to vpnsettings and save the configfile
905 $vpnsettings { 'ROOTCERT_ORGANIZATION' } = $cgiparams { 'ROOTCERT_ORGANIZATION' };
906 $vpnsettings { 'ROOTCERT_HOSTNAME' } = $cgiparams { 'ROOTCERT_HOSTNAME' };
907 $vpnsettings { 'ROOTCERT_EMAIL' } = $cgiparams { 'ROOTCERT_EMAIL' };
908 $vpnsettings { 'ROOTCERT_OU' } = $cgiparams { 'ROOTCERT_OU' };
909 $vpnsettings { 'ROOTCERT_CITY' } = $cgiparams { 'ROOTCERT_CITY' };
910 $vpnsettings { 'ROOTCERT_STATE' } = $cgiparams { 'ROOTCERT_STATE' };
911 $vpnsettings { 'ROOTCERT_COUNTRY' } = $cgiparams { 'ROOTCERT_COUNTRY' };
912 & General
:: writehash
( "${General::swroot}/vpn/settings" , \
%vpnsettings );
914 # Replace empty strings with a .
915 ( my $ou = $cgiparams { 'ROOTCERT_OU' }) =~ s/^\s*$/\./ ;
916 ( my $city = $cgiparams { 'ROOTCERT_CITY' }) =~ s/^\s*$/\./ ;
917 ( my $state = $cgiparams { 'ROOTCERT_STATE' }) =~ s/^\s*$/\./ ;
919 # Create the CA certificate
920 if (! $errormessage ) {
921 & General
:: log ( "ipsec" , "Creating cacert..." );
922 if ( open ( STDIN
, "-|" )) {
923 my $opt = " req -x509 -nodes -rand /proc/interrupts:/proc/net/rt_cache" ;
924 $opt .= " -days 999999" ;
925 $opt .= " -newkey rsa:2048" ;
926 $opt .= " -keyout ${General::swroot}/private/cakey.pem" ;
927 $opt .= " -out ${General::swroot}/ca/cacert.pem" ;
929 $errormessage = & callssl
( $opt );
931 print " $cgiparams {'ROOTCERT_COUNTRY'} \n " ;
934 print " $cgiparams {'ROOTCERT_ORGANIZATION'} \n " ;
936 print " $cgiparams {'ROOTCERT_ORGANIZATION'} CA \n " ;
937 print " $cgiparams {'ROOTCERT_EMAIL'} \n " ;
942 # Create the Host certificate request
943 if (! $errormessage ) {
944 & General
:: log ( "ipsec" , "Creating host cert..." );
945 if ( open ( STDIN
, "-|" )) {
946 my $opt = " req -nodes -rand /proc/interrupts:/proc/net/rt_cache" ;
947 $opt .= " -newkey rsa:1024" ;
948 $opt .= " -keyout ${General::swroot}/certs/hostkey.pem" ;
949 $opt .= " -out ${General::swroot}/certs/hostreq.pem" ;
950 $errormessage = & callssl
( $opt );
952 print " $cgiparams {'ROOTCERT_COUNTRY'} \n " ;
955 print " $cgiparams {'ROOTCERT_ORGANIZATION'} \n " ;
957 print " $cgiparams {'ROOTCERT_HOSTNAME'} \n " ;
958 print " $cgiparams {'ROOTCERT_EMAIL'} \n " ;
965 # Sign the host certificate request
966 if (! $errormessage ) {
967 & General
:: log ( "ipsec" , "Self signing host cert..." );
969 #No easy way for specifying the contain of subjectAltName without writing a config file...
970 my ( $fh , $v3extname ) = tempfile
( '/tmp/XXXXXXXX' );
972 basicConstraints=CA:FALSE
973 nsComment="OpenSSL Generated Certificate"
974 subjectKeyIdentifier=hash
975 authorityKeyIdentifier=keyid,issuer:always
978 print $fh "subjectAltName= $cgiparams {'SUBJECTALTNAME'}" if ( $cgiparams { 'SUBJECTALTNAME' });
981 my $opt = " ca -days 999999" ;
982 $opt .= " -batch -notext" ;
983 $opt .= " -in ${General::swroot}/certs/hostreq.pem" ;
984 $opt .= " -out ${General::swroot}/certs/hostcert.pem" ;
985 $opt .= " -extfile $v3extname " ;
986 $errormessage = & callssl
( $opt );
987 unlink ( "${General::swroot}/certs/hostreq.pem" ); #no more needed
991 # Create an empty CRL
992 if (! $errormessage ) {
993 & General
:: log ( "ipsec" , "Creating emptycrl..." );
994 my $opt = " ca -gencrl" ;
995 $opt .= " -out ${General::swroot}/crls/cacrl.pem" ;
996 $errormessage = & callssl
( $opt );
999 # Successfully build CA / CERT!
1000 if (! $errormessage ) {
1001 & cleanssldatabase
();
1002 goto ROOTCERT_SUCCESS
;
1006 unlink ( "${General::swroot}/ca/cacert.pem" );
1007 unlink ( "${General::swroot}/certs/hostkey.pem" );
1008 unlink ( "${General::swroot}/certs/hostcert.pem" );
1009 unlink ( "${General::swroot}/crls/cacrl.pem" );
1010 & cleanssldatabase
();
1014 & Header
:: showhttpheaders
();
1015 & Header
:: openpage
( $Lang :: tr
{ 'vpn configuration main' }, 1 , '' );
1016 & Header
:: openbigbox
( '100%' , 'left' , '' , $errormessage );
1017 if ( $errormessage ) {
1018 & Header
:: openbox
( '100%' , 'left' , $Lang :: tr
{ 'error messages' });
1019 print "<class name='base'> $errormessage " ;
1020 print " </class>" ;
1021 & Header
:: closebox
();
1023 & Header
:: openbox
( '100%' , 'left' , " $Lang ::tr{'generate root/host certificates'}:" );
1025 <form method='post' enctype='multipart/form-data' action=' $ENV {'SCRIPT_NAME'}'>
1026 <table width='100%' border='0' cellspacing='1' cellpadding='0'>
1027 <tr><td width='40%' class='base'> $Lang ::tr{'organization name'}:</td>
1028 <td width='60%' class='base' nowrap='nowrap'><input type='text' name='ROOTCERT_ORGANIZATION' value=' $cgiparams {'ROOTCERT_ORGANIZATION'}' size='32' /></td></tr>
1029 <tr><td class='base'> $Lang ::tr{'IPFires hostname'}:</td>
1030 <td class='base' nowrap='nowrap'><input type='text' name='ROOTCERT_HOSTNAME' value=' $cgiparams {'ROOTCERT_HOSTNAME'}' size='32' /></td></tr>
1031 <tr><td class='base'> $Lang ::tr{'your e-mail'}: <img src='/blob.gif' alt='*' /></td>
1032 <td class='base' nowrap='nowrap'><input type='text' name='ROOTCERT_EMAIL' value=' $cgiparams {'ROOTCERT_EMAIL'}' size='32' /></td></tr>
1033 <tr><td class='base'> $Lang ::tr{'your department'}: <img src='/blob.gif' alt='*' /></td>
1034 <td class='base' nowrap='nowrap'><input type='text' name='ROOTCERT_OU' value=' $cgiparams {'ROOTCERT_OU'}' size='32' /></td></tr>
1035 <tr><td class='base'> $Lang ::tr{'city'}: <img src='/blob.gif' alt='*' /></td>
1036 <td class='base' nowrap='nowrap'><input type='text' name='ROOTCERT_CITY' value=' $cgiparams {'ROOTCERT_CITY'}' size='32' /></td></tr>
1037 <tr><td class='base'> $Lang ::tr{'state or province'}: <img src='/blob.gif' alt='*' /></td>
1038 <td class='base' nowrap='nowrap'><input type='text' name='ROOTCERT_STATE' value=' $cgiparams {'ROOTCERT_STATE'}' size='32' /></td></tr>
1039 <tr><td class='base'> $Lang ::tr{'country'}:</td>
1040 <td class='base'><select name='ROOTCERT_COUNTRY'>
1043 foreach my $country ( sort keys %{ Countries
:: countries
}) {
1044 print "<option value=' $Countries ::countries{ $country }'" ;
1045 if ( $Countries :: countries
{ $country } eq $cgiparams { 'ROOTCERT_COUNTRY' } ) {
1046 print " selected='selected'" ;
1048 print "> $country </option>" ;
1052 <tr><td class='base'> $Lang ::tr{'vpn subjectaltname'} (subjectAltName=email:*,URI:*,DNS:*,RID:*) <img src='/blob.gif' alt='*' /></td>
1053 <td class='base' nowrap='nowrap'><input type='text' name='SUBJECTALTNAME' value=' $cgiparams {'SUBJECTALTNAME'}' size='32' /></td></tr>
1055 <td><br /><input type='submit' name='ACTION' value=' $Lang ::tr{'generate root/host certificates'}' /><br /><br /></td></tr>
1056 <tr><td class='base' colspan='2' align='left'>
1057 <b><font color='${Header::colourred}'> $Lang ::tr{'capswarning'}</font></b>:
1058 $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'}
1060 <tr><td colspan='2'><hr /></td></tr>
1061 <tr><td class='base' nowrap='nowrap'> $Lang ::tr{'upload p12 file'}:</td>
1062 <td nowrap='nowrap'><input type='file' name='FH' size='32' /></td></tr>
1063 <tr><td class='base'> $Lang ::tr{'pkcs12 file password'}: <img src='/blob.gif' alt='*' /></td>
1064 <td class='base' nowrap='nowrap'><input type='password' name='P12_PASS' value=' $cgiparams {'P12_PASS'}' size='32' /></td></tr>
1066 <td><input type='submit' name='ACTION' value=' $Lang ::tr{'upload p12 file'}' /></td></tr>
1067 <tr><td class='base' colspan='2' align='left'>
1068 <img src='/blob.gif' alt='*' /> $Lang ::tr{'this field may be blank'}</td></tr>
1072 & Header
:: closebox
();
1073 & Header
:: closebigbox
();
1074 & Header
:: closepage
();
1079 system ( '/usr/local/bin/ipsecctrl' , 'S' );
1084 ### Export PKCS12 file to browser
1086 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'download pkcs12 file' }) {
1087 & General
:: readhasharray
( "${General::swroot}/vpn/config" , \
%confighash );
1088 print "Content-Type: application/force-download \n " ;
1089 print "Content-Disposition: attachment; filename=" . $confighash { $cgiparams { 'KEY' }}[ 1 ] . ".p12 \r\n " ;
1090 print "Content-Type: application/octet-stream \r\n\r\n " ;
1091 print `/bin/cat ${General::swroot}/certs/ $confighash { $cgiparams {'KEY'}}[1].p12` ;
1095 ### Display certificate
1097 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'show certificate' }) {
1098 & General
:: readhasharray
( "${General::swroot}/vpn/config" , \
%confighash );
1100 if ( - f
"${General::swroot}/certs/ $confighash { $cgiparams {'KEY'}}[1]cert.pem" ) {
1101 & Header
:: showhttpheaders
();
1102 & Header
:: openpage
( $Lang :: tr
{ 'vpn configuration main' }, 1 , '' );
1103 & Header
:: openbigbox
( '100%' , 'left' , '' , '' );
1104 & Header
:: openbox
( '100%' , 'left' , " $Lang ::tr{'cert'}:" );
1105 my $output = `/usr/bin/openssl x509 -text -in ${General::swroot}/certs/ $confighash { $cgiparams {'KEY'}}[1]cert.pem` ;
1106 $output = & Header
:: cleanhtml
( $output , "y" );
1107 print "<pre> $output </pre> \n " ;
1108 & Header
:: closebox
();
1109 print "<div align='center'><a href='/cgi-bin/vpnmain.cgi'> $Lang ::tr{'back'}</a></div>" ;
1110 & Header
:: closebigbox
();
1111 & Header
:: closepage
();
1116 ### Export Certificate to browser
1118 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'download certificate' }) {
1119 & General
:: readhasharray
( "${General::swroot}/vpn/config" , \
%confighash );
1121 if ( - f
"${General::swroot}/certs/ $confighash { $cgiparams {'KEY'}}[1]cert.pem" ) {
1122 print "Content-Type: application/force-download \n " ;
1123 print "Content-Disposition: attachment; filename=" . $confighash { $cgiparams { 'KEY' }}[ 1 ] . "cert.pem \n\n " ;
1124 print `/bin/cat ${General::swroot}/certs/ $confighash { $cgiparams {'KEY'}}[1]cert.pem` ;
1129 ### Enable/Disable connection
1131 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'toggle enable disable' }) {
1133 & General
:: readhash
( "${General::swroot}/vpn/settings" , \
%vpnsettings );
1134 & General
:: readhasharray
( "${General::swroot}/vpn/config" , \
%confighash );
1136 if ( $confighash { $cgiparams { 'KEY' }}) {
1137 if ( $confighash { $cgiparams { 'KEY' }}[ 0 ] eq 'off' ) {
1138 $confighash { $cgiparams { 'KEY' }}[ 0 ] = 'on' ;
1139 & General
:: writehasharray
( "${General::swroot}/vpn/config" , \
%confighash );
1141 system ( '/usr/local/bin/ipsecctrl' , 'S' , $cgiparams { 'KEY' }) if (& vpnenabled
);
1143 system ( '/usr/local/bin/ipsecctrl' , 'D' , $cgiparams { 'KEY' }) if (& vpnenabled
);
1144 $confighash { $cgiparams { 'KEY' }}[ 0 ] = 'off' ;
1145 & General
:: writehasharray
( "${General::swroot}/vpn/config" , \
%confighash );
1150 $errormessage = $Lang :: tr
{ 'invalid key' };
1154 ### Restart connection
1156 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'restart' }) {
1157 & General
:: readhash
( "${General::swroot}/vpn/settings" , \
%vpnsettings );
1158 & General
:: readhasharray
( "${General::swroot}/vpn/config" , \
%confighash );
1160 if ( $confighash { $cgiparams { 'KEY' }}) {
1162 system ( '/usr/local/bin/ipsecctrl' , 'S' , $cgiparams { 'KEY' });
1166 $errormessage = $Lang :: tr
{ 'invalid key' };
1170 ### Remove connection
1172 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'remove' }) {
1173 & General
:: readhash
( "${General::swroot}/vpn/settings" , \
%vpnsettings );
1174 & General
:: readhasharray
( "${General::swroot}/vpn/config" , \
%confighash );
1176 if ( $confighash { $cgiparams { 'KEY' }}) {
1177 system ( '/usr/local/bin/ipsecctrl' , 'D' , $cgiparams { 'KEY' }) if (& vpnenabled
);
1178 unlink ( "${General::swroot}/certs/ $confighash { $cgiparams {'KEY'}}[1]cert.pem" );
1179 unlink ( "${General::swroot}/certs/ $confighash { $cgiparams {'KEY'}}[1].p12" );
1180 delete $confighash { $cgiparams { 'KEY' }};
1181 & General
:: writehasharray
( "${General::swroot}/vpn/config" , \
%confighash );
1184 $errormessage = $Lang :: tr
{ 'invalid key' };
1188 ### Choose between adding a host-net or net-net connection
1190 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'add' } && $cgiparams { 'TYPE' } eq '' ) {
1191 & Header
:: showhttpheaders
();
1192 & Header
:: openpage
( $Lang :: tr
{ 'vpn configuration main' }, 1 , '' );
1193 & Header
:: openbigbox
( '100%' , 'left' , '' , '' );
1194 & Header
:: openbox
( '100%' , 'left' , $Lang :: tr
{ 'connection type' });
1196 <form method='post' action=' $ENV {'SCRIPT_NAME'}'>
1197 <b> $Lang ::tr{'connection type'}:</b><br />
1199 <tr><td><input type='radio' name='TYPE' value='host' checked='checked' /></td>
1200 <td class='base'> $Lang ::tr{'host to net vpn'}</td>
1202 <td><input type='radio' name='TYPE' value='net' /></td>
1203 <td class='base'> $Lang ::tr{'net to net vpn'}</td>
1205 <td align='center' colspan='2'><input type='submit' name='ACTION' value=' $Lang ::tr{'add'}' /></td>
1210 & Header
:: closebox
();
1211 & Header
:: closebigbox
();
1212 & Header
:: closepage
();
1215 ### Adding/Editing/Saving a connection
1217 } elsif (( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'add' }) ||
1218 ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'edit' }) ||
1219 ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'save' } && $cgiparams { 'ADVANCED' } eq '' )) {
1221 & General
:: readhash
( "${General::swroot}/vpn/settings" , \
%vpnsettings );
1222 & General
:: readhasharray
( "${General::swroot}/vpn/caconfig" , \
%cahash );
1223 & General
:: readhasharray
( "${General::swroot}/vpn/config" , \
%confighash );
1225 if ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'edit' }) {
1226 if (! $confighash { $cgiparams { 'KEY' }}[ 0 ]) {
1227 $errormessage = $Lang :: tr
{ 'invalid key' };
1230 $cgiparams { 'ENABLED' } = $confighash { $cgiparams { 'KEY' }}[ 0 ];
1231 $cgiparams { 'NAME' } = $confighash { $cgiparams { 'KEY' }}[ 1 ];
1232 $cgiparams { 'TYPE' } = $confighash { $cgiparams { 'KEY' }}[ 3 ];
1233 $cgiparams { 'AUTH' } = $confighash { $cgiparams { 'KEY' }}[ 4 ];
1234 $cgiparams { 'PSK' } = $confighash { $cgiparams { 'KEY' }}[ 5 ];
1235 #$cgiparams{'free'} = $confighash{$cgiparams{'KEY'}}[6];
1236 $cgiparams { 'LOCAL_ID' } = $confighash { $cgiparams { 'KEY' }}[ 7 ];
1237 $cgiparams { 'LOCAL_SUBNET' } = $confighash { $cgiparams { 'KEY' }}[ 8 ];
1238 $cgiparams { 'REMOTE_ID' } = $confighash { $cgiparams { 'KEY' }}[ 9 ];
1239 $cgiparams { 'REMOTE' } = $confighash { $cgiparams { 'KEY' }}[ 10 ];
1240 $cgiparams { 'REMOTE_SUBNET' } = $confighash { $cgiparams { 'KEY' }}[ 11 ];
1241 $cgiparams { 'REMARK' } = $confighash { $cgiparams { 'KEY' }}[ 25 ];
1242 $cgiparams { 'INTERFACE' } = $confighash { $cgiparams { 'KEY' }}[ 26 ];
1243 $cgiparams { 'DPD_ACTION' } = $confighash { $cgiparams { 'KEY' }}[ 27 ];
1244 $cgiparams { 'IKE_ENCRYPTION' } = $confighash { $cgiparams { 'KEY' }}[ 18 ];
1245 $cgiparams { 'IKE_INTEGRITY' } = $confighash { $cgiparams { 'KEY' }}[ 19 ];
1246 $cgiparams { 'IKE_GROUPTYPE' } = $confighash { $cgiparams { 'KEY' }}[ 20 ];
1247 $cgiparams { 'IKE_LIFETIME' } = $confighash { $cgiparams { 'KEY' }}[ 16 ];
1248 $cgiparams { 'ESP_ENCRYPTION' } = $confighash { $cgiparams { 'KEY' }}[ 21 ];
1249 $cgiparams { 'ESP_INTEGRITY' } = $confighash { $cgiparams { 'KEY' }}[ 22 ];
1250 $cgiparams { 'ESP_GROUPTYPE' } = $confighash { $cgiparams { 'KEY' }}[ 23 ];
1251 $cgiparams { 'ESP_KEYLIFE' } = $confighash { $cgiparams { 'KEY' }}[ 17 ];
1252 $cgiparams { 'AGGRMODE' } = $confighash { $cgiparams { 'KEY' }}[ 12 ];
1253 $cgiparams { 'COMPRESSION' } = $confighash { $cgiparams { 'KEY' }}[ 13 ];
1254 $cgiparams { 'ONLY_PROPOSED' } = $confighash { $cgiparams { 'KEY' }}[ 24 ];
1255 $cgiparams { 'PFS' } = $confighash { $cgiparams { 'KEY' }}[ 28 ];
1256 $cgiparams { 'VHOST' } = $confighash { $cgiparams { 'KEY' }}[ 14 ];
1258 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'save' }) {
1259 $cgiparams { 'REMARK' } = & Header
:: cleanhtml
( $cgiparams { 'REMARK' });
1260 if ( $cgiparams { 'TYPE' } !~ /^(host|net)$/ ) {
1261 $errormessage = $Lang :: tr
{ 'connection type is invalid' };
1265 if ( $cgiparams { 'NAME' } !~ /^[a-zA-Z0-9]+$/ ) {
1266 $errormessage = $Lang :: tr
{ 'name must only contain characters' };
1270 if ( $cgiparams { 'NAME' } =~ /^(host|01|block|private|clear|packetdefault)$/ ) {
1271 $errormessage = $Lang :: tr
{ 'name is invalid' };
1275 if ( length ( $cgiparams { 'NAME' }) > 60 ) {
1276 $errormessage = $Lang :: tr
{ 'name too long' };
1280 # Check if there is no other entry with this name
1281 if (! $cgiparams { 'KEY' }) { #only for add
1282 foreach my $key ( keys %confighash ) {
1283 if ( $confighash { $key }[ 1 ] eq $cgiparams { 'NAME' }) {
1284 $errormessage = $Lang :: tr
{ 'a connection with this name already exists' };
1290 if (( $cgiparams { 'TYPE' } eq 'net' ) && (! $cgiparams { 'REMOTE' })) {
1291 $errormessage = $Lang :: tr
{ 'invalid input for remote host/ip' };
1295 if ( $cgiparams { 'REMOTE' }) {
1296 if (! & General
:: validip
( $cgiparams { 'REMOTE' })) {
1297 if (! & General
:: validfqdn
( $cgiparams { 'REMOTE' })) {
1298 $errormessage = $Lang :: tr
{ 'invalid input for remote host/ip' };
1301 if (& valid_dns_host
( $cgiparams { 'REMOTE' })) {
1302 $warnmessage = " $Lang ::tr{'check vpn lr'} $cgiparams {'REMOTE'}. $Lang ::tr{'dns check failed'}" ;
1308 unless (& General
:: validipandmask
( $cgiparams { 'LOCAL_SUBNET' })) {
1309 $errormessage = $Lang :: tr
{ 'local subnet is invalid' };
1313 # Allow only one roadwarrior/psk without remote IP-address
1314 if ( $cgiparams { 'REMOTE' } eq '' && $cgiparams { 'AUTH' } eq 'psk' ) {
1315 foreach my $key ( keys %confighash ) {
1316 if ( ( $cgiparams { 'KEY' } ne $key ) &&
1317 ( $confighash { $key }[ 4 ] eq 'psk' ) &&
1318 ( $confighash { $key }[ 10 ] eq '' ) ) {
1319 $errormessage = $Lang :: tr
{ 'you can only define one roadwarrior connection when using pre-shared key authentication' };
1324 if (( $cgiparams { 'TYPE' } eq 'net' ) && (! & General
:: validipandmask
( $cgiparams { 'REMOTE_SUBNET' }))) {
1325 $errormessage = $Lang :: tr
{ 'remote subnet is invalid' };
1329 if ( $cgiparams { 'ENABLED' } !~ /^(on|off)$/ ) {
1330 $errormessage = $Lang :: tr
{ 'invalid input' };
1333 if ( $cgiparams { 'EDIT_ADVANCED' } !~ /^(on|off)$/ ) {
1334 $errormessage = $Lang :: tr
{ 'invalid input' };
1338 # Allow nothing or a string (DN,FDQN,) beginning with @
1339 # with no comma but slashes between RID eg @O=FR/C=Paris/OU=myhome/CN=franck
1340 if ( ( $cgiparams { 'LOCAL_ID' } !~ /^(|[\w.-]*@[\w. =*\/ -]+| \d\
. \d\
. \d\
. \d
)$/) ||
1341 ( $cgiparams { 'REMOTE_ID' } !~ /^(|[\w.-]*@[\w. =*\/ -]+| \d\
. \d\
. \d\
. \d
)$/) ||
1342 (( $cgiparams { 'REMOTE_ID' } eq $cgiparams { 'LOCAL_ID' }) && ( $cgiparams { 'LOCAL_ID' } ne '' ))
1344 $errormessage = $Lang :: tr
{ 'invalid local-remote id' } . '<br />' .
1345 'DER_ASN1_DN: @c =FR/ou=Paris/ou=Home/cn=*<br />' .
1346 'FQDN: @ipfire .org<br />' .
1347 'USER_FQDN: info @ipfire .org<br />' .
1348 'IPV4_ADDR: @123 .123.123.123' ;
1351 # If Auth is DN, verify existance of Remote ID.
1352 if ( $cgiparams { 'REMOTE_ID' } eq '' && (
1353 $cgiparams { 'AUTH' } eq 'auth-dn' || # while creation
1354 $confighash { $cgiparams { 'KEY' }}[ 2 ] eq ' %auth -dn' )){ # while editing
1355 $errormessage = $Lang :: tr
{ 'vpn missing remote id' };
1359 if ( $cgiparams { 'AUTH' } eq 'psk' ) {
1360 if (! length ( $cgiparams { 'PSK' }) ) {
1361 $errormessage = $Lang :: tr
{ 'pre-shared key is too short' };
1364 if ( $cgiparams { 'PSK' } =~ /'/ ) {
1365 $cgiparams { 'PSK' } =~ tr/'/ / ;
1366 $errormessage = $Lang :: tr
{ 'invalid characters found in pre-shared key' };
1369 } elsif ( $cgiparams { 'AUTH' } eq 'certreq' ) {
1370 if ( $cgiparams { 'KEY' }) {
1371 $errormessage = $Lang :: tr
{ 'cant change certificates' };
1374 if ( ref ( $cgiparams { 'FH' }) ne 'Fh' ) {
1375 $errormessage = $Lang :: tr
{ 'there was no file upload' };
1379 # Move uploaded certificate request to a temporary file
1380 ( my $fh , my $filename ) = tempfile
( );
1381 if ( copy
( $cgiparams { 'FH' }, $fh ) != 1 ) {
1386 # Sign the certificate request
1387 & General
:: log ( "ipsec" , "Signing your cert $cgiparams {'NAME'}..." );
1388 my $opt = " ca -days 999999" ;
1389 $opt .= " -batch -notext" ;
1390 $opt .= " -in $filename " ;
1391 $opt .= " -out ${General::swroot}/certs/ $cgiparams {'NAME'}cert.pem" ;
1393 if ( $errormessage = & callssl
( $opt ) ) {
1395 unlink ( "${General::swroot}/certs/ $cgiparams {'NAME'}cert.pem" );
1396 & cleanssldatabase
();
1400 & cleanssldatabase
();
1403 $cgiparams { 'CERT_NAME' } = getCNfromcert
( "${General::swroot}/certs/ $cgiparams {'NAME'}cert.pem" );
1404 if ( $cgiparams { 'CERT_NAME' } eq '' ) {
1405 $errormessage = $Lang :: tr
{ 'could not retrieve common name from certificate' };
1408 } elsif ( $cgiparams { 'AUTH' } eq 'pkcs12' ) {
1409 & General
:: log ( "ipsec" , "Importing from p12..." );
1411 if ( ref ( $cgiparams { 'FH' }) ne 'Fh' ) {
1412 $errormessage = $Lang :: tr
{ 'there was no file upload' };
1413 goto ROOTCERT_ERROR
;
1416 # Move uploaded certificate request to a temporary file
1417 ( my $fh , my $filename ) = tempfile
( );
1418 if ( copy
( $cgiparams { 'FH' }, $fh ) != 1 ) {
1420 goto ROOTCERT_ERROR
;
1423 # Extract the CA certificate from the file
1424 & General
:: log ( "ipsec" , "Extracting caroot from p12..." );
1425 if ( open ( STDIN
, "-|" )) {
1426 my $opt = " pkcs12 -cacerts -nokeys" ;
1427 $opt .= " -in $filename " ;
1428 $opt .= " -out /tmp/newcacert" ;
1429 $errormessage = & callssl
( $opt );
1431 print " $cgiparams {'P12_PASS'} \n " ;
1435 # Extract the Host certificate from the file
1436 if (! $errormessage ) {
1437 & General
:: log ( "ipsec" , "Extracting host cert from p12..." );
1438 if ( open ( STDIN
, "-|" )) {
1439 my $opt = " pkcs12 -clcerts -nokeys" ;
1440 $opt .= " -in $filename " ;
1441 $opt .= " -out /tmp/newhostcert" ;
1442 $errormessage = & callssl
( $opt );
1444 print " $cgiparams {'P12_PASS'} \n " ;
1449 if (! $errormessage ) {
1450 & General
:: log ( "ipsec" , "Moving cacert..." );
1451 #If CA have new subject, add it to our list of CA
1452 my $casubject = & Header
:: cleanhtml
( getsubjectfromcert
( '/tmp/newcacert' ));
1454 foreach my $x ( keys %cahash ) {
1455 $casubject = '' if ( $cahash { $x }[ 1 ] eq $casubject );
1456 unshift ( @names , $cahash { $x }[ 0 ]);
1458 if ( $casubject ) { # a new one!
1459 my $temp = `/usr/bin/openssl x509 -text -in /tmp/newcacert` ;
1460 if ( $temp !~ /CA:TRUE/i ) {
1461 $errormessage = $Lang :: tr
{ 'not a valid ca certificate' };
1463 #compute a name for it
1465 while ( grep ( /Imported-$idx/ , @names ) ) { $idx ++};
1466 $cgiparams { 'CA_NAME' }= "Imported- $idx " ;
1467 $cgiparams { 'CERT_NAME' }=& Header
:: cleanhtml
( getCNfromcert
( '/tmp/newhostcert' ));
1468 move
( "/tmp/newcacert" , "${General::swroot}/ca/ $cgiparams {'CA_NAME'}cert.pem" );
1469 $errormessage = " $Lang ::tr{'certificate file move failed'}: $!" if ($ ?
ne 0 );
1470 if (! $errormessage ) {
1471 my $key = & General
:: findhasharraykey
( \
%cahash );
1472 $cahash { $key }[ 0 ] = $cgiparams { 'CA_NAME' };
1473 $cahash { $key }[ 1 ] = $casubject ;
1474 & General
:: writehasharray
( "${General::swroot}/vpn/caconfig" , \
%cahash );
1475 system ( '/usr/local/bin/ipsecctrl' , 'R' );
1480 if (! $errormessage ) {
1481 & General
:: log ( "ipsec" , "Moving host cert..." );
1482 move
( "/tmp/newhostcert" , "${General::swroot}/certs/ $cgiparams {'NAME'}cert.pem" );
1483 $errormessage = " $Lang ::tr{'certificate file move failed'}: $!" if ($ ?
ne 0 );
1488 unlink ( '/tmp/newcacert' );
1489 unlink ( '/tmp/newhostcert' );
1490 if ( $errormessage ) {
1491 unlink ( "${General::swroot}/ca/ $cgiparams {'CA_NAME'}cert.pem" );
1492 unlink ( "${General::swroot}/certs/ $cgiparams {'NAME'}cert.pem" );
1495 & General
:: log ( "ipsec" , "p12 import completed!" );
1496 } elsif ( $cgiparams { 'AUTH' } eq 'certfile' ) {
1497 if ( $cgiparams { 'KEY' }) {
1498 $errormessage = $Lang :: tr
{ 'cant change certificates' };
1501 if ( ref ( $cgiparams { 'FH' }) ne 'Fh' ) {
1502 $errormessage = $Lang :: tr
{ 'there was no file upload' };
1505 # Move uploaded certificate to a temporary file
1506 ( my $fh , my $filename ) = tempfile
( );
1507 if ( copy
( $cgiparams { 'FH' }, $fh ) != 1 ) {
1512 # Verify the certificate has a valid CA and move it
1513 & General
:: log ( "ipsec" , "Validating imported cert against our known CA..." );
1514 my $validca = 1 ; #assume ok
1515 my $test = `/usr/bin/openssl verify -CAfile ${General::swroot}/ca/cacert.pem $filename ` ;
1516 if ( $test !~ /: OK/ ) {
1518 foreach my $key ( keys %cahash ) {
1519 $test = `/usr/bin/openssl verify -CAfile ${General::swroot}/ca/ $cahash { $key }[0]cert.pem $filename ` ;
1520 if ( $test =~ /: OK/ ) {
1527 $errormessage = $Lang :: tr
{ 'certificate does not have a valid ca associated with it' };
1531 move
( $filename , "${General::swroot}/certs/ $cgiparams {'NAME'}cert.pem" );
1533 $errormessage = " $Lang ::tr{'certificate file move failed'}: $!" ;
1539 $cgiparams { 'CERT_NAME' } = getCNfromcert
( "${General::swroot}/certs/ $cgiparams {'NAME'}cert.pem" );
1540 if ( $cgiparams { 'CERT_NAME' } eq '' ) {
1541 unlink ( "${General::swroot}/certs/ $cgiparams {'NAME'}cert.pem" );
1542 $errormessage = $Lang :: tr
{ 'could not retrieve common name from certificate' };
1545 } elsif ( $cgiparams { 'AUTH' } eq 'certgen' ) {
1546 if ( $cgiparams { 'KEY' }) {
1547 $errormessage = $Lang :: tr
{ 'cant change certificates' };
1550 # Validate input since the form was submitted
1551 if ( length ( $cgiparams { 'CERT_NAME' }) > 60 ) {
1552 $errormessage = $Lang :: tr
{ 'name too long' };
1555 if ( $cgiparams { 'CERT_NAME' } !~ /^[a-zA-Z0-9 ,\.\-_]+$/ ) {
1556 $errormessage = $Lang :: tr
{ 'invalid input for name' };
1559 if ( $cgiparams { 'CERT_EMAIL' } ne '' && (! & General
:: validemail
( $cgiparams { 'CERT_EMAIL' }))) {
1560 $errormessage = $Lang :: tr
{ 'invalid input for e-mail address' };
1563 if ( length ( $cgiparams { 'CERT_EMAIL' }) > 40 ) {
1564 $errormessage = $Lang :: tr
{ 'e-mail address too long' };
1567 if ( $cgiparams { 'CERT_OU' } ne '' && $cgiparams { 'CERT_OU' } !~ /^[a-zA-Z0-9 ,\.\-_]*$/ ) {
1568 $errormessage = $Lang :: tr
{ 'invalid input for department' };
1571 if ( length ( $cgiparams { 'CERT_ORGANIZATION' }) > 60 ) {
1572 $errormessage = $Lang :: tr
{ 'organization too long' };
1575 if ( $cgiparams { 'CERT_ORGANIZATION' } !~ /^[a-zA-Z0-9 ,\.\-_]+$/ ) {
1576 $errormessage = $Lang :: tr
{ 'invalid input for organization' };
1579 if ( $cgiparams { 'CERT_CITY' } ne '' && $cgiparams { 'CERT_CITY' } !~ /^[a-zA-Z0-9 ,\.\-_]*$/ ) {
1580 $errormessage = $Lang :: tr
{ 'invalid input for city' };
1583 if ( $cgiparams { 'CERT_STATE' } ne '' && $cgiparams { 'CERT_STATE' } !~ /^[a-zA-Z0-9 ,\.\-_]*$/ ) {
1584 $errormessage = $Lang :: tr
{ 'invalid input for state or province' };
1587 if ( $cgiparams { 'CERT_COUNTRY' } !~ /^[A-Z]*$/ ) {
1588 $errormessage = $Lang :: tr
{ 'invalid input for country' };
1591 #the exact syntax is a list comma separated of
1592 # email:any-validemail
1593 # URI: a uniform resource indicator
1594 # DNS: a DNS domain name
1595 # RID: a registered OBJECT IDENTIFIER
1597 # example: email:franck@foo.com,IP:10.0.0.10,DNS:franck.foo.com
1599 if ( $cgiparams { 'SUBJECTALTNAME' } ne '' && $cgiparams { 'SUBJECTALTNAME' } !~ /^(email|URI|DNS|RID|IP):[a-zA-Z0-9 :\/ , \
. \
- _@
]*$/) {
1600 $errormessage = $Lang :: tr
{ 'vpn altname syntax' };
1604 if ( length ( $cgiparams { 'CERT_PASS1' }) < 5 ) {
1605 $errormessage = $Lang :: tr
{ 'password too short' };
1608 if ( $cgiparams { 'CERT_PASS1' } ne $cgiparams { 'CERT_PASS2' }) {
1609 $errormessage = $Lang :: tr
{ 'passwords do not match' };
1613 # Replace empty strings with a .
1614 ( my $ou = $cgiparams { 'CERT_OU' }) =~ s/^\s*$/\./ ;
1615 ( my $city = $cgiparams { 'CERT_CITY' }) =~ s/^\s*$/\./ ;
1616 ( my $state = $cgiparams { 'CERT_STATE' }) =~ s/^\s*$/\./ ;
1618 # Create the Host certificate request
1619 & General
:: log ( "ipsec" , "Creating a cert..." );
1621 if ( open ( STDIN
, "-|" )) {
1622 my $opt = " req -nodes -rand /proc/interrupts:/proc/net/rt_cache" ;
1623 $opt .= " -newkey rsa:1024" ;
1624 $opt .= " -keyout ${General::swroot}/certs/ $cgiparams {'NAME'}key.pem" ;
1625 $opt .= " -out ${General::swroot}/certs/ $cgiparams {'NAME'}req.pem" ;
1627 if ( $errormessage = & callssl
( $opt ) ) {
1628 unlink ( "${General::swroot}/certs/ $cgiparams {'NAME'}key.pem" );
1629 unlink ( "${General::swroot}/certs/ $cgiparams {'NAME'}req.pem" );
1633 print " $cgiparams {'CERT_COUNTRY'} \n " ;
1636 print " $cgiparams {'CERT_ORGANIZATION'} \n " ;
1638 print " $cgiparams {'CERT_NAME'} \n " ;
1639 print " $cgiparams {'CERT_EMAIL'} \n " ;
1645 # Sign the host certificate request
1646 & General
:: log ( "ipsec" , "Signing the cert $cgiparams {'NAME'}..." );
1648 #No easy way for specifying the contain of subjectAltName without writing a config file...
1649 my ( $fh , $v3extname ) = tempfile
( '/tmp/XXXXXXXX' );
1651 basicConstraints=CA:FALSE
1652 nsComment="OpenSSL Generated Certificate"
1653 subjectKeyIdentifier=hash
1654 authorityKeyIdentifier=keyid,issuer:always
1657 print $fh "subjectAltName= $cgiparams {'SUBJECTALTNAME'}" if ( $cgiparams { 'SUBJECTALTNAME' });
1660 my $opt = " ca -days 999999 -batch -notext" ;
1661 $opt .= " -in ${General::swroot}/certs/ $cgiparams {'NAME'}req.pem" ;
1662 $opt .= " -out ${General::swroot}/certs/ $cgiparams {'NAME'}cert.pem" ;
1663 $opt .= " -extfile $v3extname " ;
1665 if ( $errormessage = & callssl
( $opt ) ) {
1666 unlink ( $v3extname );
1667 unlink ( "${General::swroot}/certs/ $cgiparams {'NAME'}key.pem" );
1668 unlink ( "${General::swroot}/certs/ $cgiparams {'NAME'}req.pem" );
1669 unlink ( "${General::swroot}/certs/ $cgiparams {'NAME'}cert.pem" );
1670 & cleanssldatabase
();
1673 unlink ( $v3extname );
1674 unlink ( "${General::swroot}/certs/ $cgiparams {'NAME'}req.pem" );
1675 & cleanssldatabase
();
1678 # Create the pkcs12 file
1679 & General
:: log ( "ipsec" , "Packing a pkcs12 file..." );
1680 $opt = " pkcs12 -export" ;
1681 $opt .= " -inkey ${General::swroot}/certs/ $cgiparams {'NAME'}key.pem" ;
1682 $opt .= " -in ${General::swroot}/certs/ $cgiparams {'NAME'}cert.pem" ;
1683 $opt .= " -name \" $cgiparams {'NAME'} \" " ;
1684 $opt .= " -passout pass: $cgiparams {'CERT_PASS1'}" ;
1685 $opt .= " -certfile ${General::swroot}/ca/cacert.pem" ;
1686 $opt .= " -caname \" $vpnsettings {'ROOTCERT_ORGANIZATION'} CA \" " ;
1687 $opt .= " -out ${General::swroot}/certs/ $cgiparams {'NAME'}.p12" ;
1689 if ( $errormessage = & callssl
( $opt ) ) {
1690 unlink ( "${General::swroot}/certs/ $cgiparams {'NAME'}key.pem" );
1691 unlink ( "${General::swroot}/certs/ $cgiparams {'NAME'}cert.pem" );
1692 unlink ( "${General::swroot}/certs/ $cgiparams {'NAME'}.p12" );
1695 unlink ( "${General::swroot}/certs/ $cgiparams {'NAME'}key.pem" );
1697 } elsif ( $cgiparams { 'AUTH' } eq 'cert' ) {
1698 ; # Nothing, just editing
1699 } elsif ( $cgiparams { 'AUTH' } eq 'auth-dn' ) {
1700 $cgiparams { 'CERT_NAME' } = ' %auth -dn' ; # a special value saying 'no cert file'
1702 $errormessage = $Lang :: tr
{ 'invalid input for authentication method' };
1706 # 1)Error message here is not accurate.
1707 # 2)Test is superfluous, openswan can reference same cert multiple times
1708 # 3)Present since initial version (1.3.2.11), it isn't a bug correction
1709 # Check if there is no other entry with this certificate name
1710 #if ((! $cgiparams{'KEY'}) && ($cgiparams{'AUTH'} ne 'psk') && ($cgiparams{'AUTH'} ne 'auth-dn')) {
1711 # foreach my $key (keys %confighash) {
1712 # if ($confighash{$key}[2] eq $cgiparams{'CERT_NAME'}) {
1713 # $errormessage = $Lang::tr{'a connection with this common name already exists'};
1714 # goto VPNCONF_ERROR;
1720 my $key = $cgiparams { 'KEY' };
1722 $key = & General
:: findhasharraykey
( \
%confighash );
1723 foreach my $i ( 0 .. 28 ) { $confighash { $key }[ $i ] = "" ;}
1725 $confighash { $key }[ 0 ] = $cgiparams { 'ENABLED' };
1726 $confighash { $key }[ 1 ] = $cgiparams { 'NAME' };
1727 if ((! $cgiparams { 'KEY' }) && $cgiparams { 'AUTH' } ne 'psk' ) {
1728 $confighash { $key }[ 2 ] = $cgiparams { 'CERT_NAME' };
1730 $confighash { $key }[ 3 ] = $cgiparams { 'TYPE' };
1731 if ( $cgiparams { 'AUTH' } eq 'psk' ) {
1732 $confighash { $key }[ 4 ] = 'psk' ;
1733 $confighash { $key }[ 5 ] = $cgiparams { 'PSK' };
1735 $confighash { $key }[ 4 ] = 'cert' ;
1737 if ( $cgiparams { 'TYPE' } eq 'net' ) {
1738 $confighash { $key }[ 11 ] = $cgiparams { 'REMOTE_SUBNET' };
1740 $confighash { $key }[ 7 ] = $cgiparams { 'LOCAL_ID' };
1741 $confighash { $key }[ 8 ] = $cgiparams { 'LOCAL_SUBNET' };
1742 $confighash { $key }[ 9 ] = $cgiparams { 'REMOTE_ID' };
1743 $confighash { $key }[ 10 ] = $cgiparams { 'REMOTE' };
1744 $confighash { $key }[ 25 ] = $cgiparams { 'REMARK' };
1745 $confighash { $key }[ 26 ] = $cgiparams { 'INTERFACE' };
1746 $confighash { $key }[ 27 ] = $cgiparams { 'DPD_ACTION' };
1748 #dont forget advanced value
1749 $confighash { $key }[ 18 ] = $cgiparams { 'IKE_ENCRYPTION' };
1750 $confighash { $key }[ 19 ] = $cgiparams { 'IKE_INTEGRITY' };
1751 $confighash { $key }[ 20 ] = $cgiparams { 'IKE_GROUPTYPE' };
1752 $confighash { $key }[ 16 ] = $cgiparams { 'IKE_LIFETIME' };
1753 $confighash { $key }[ 21 ] = $cgiparams { 'ESP_ENCRYPTION' };
1754 $confighash { $key }[ 22 ] = $cgiparams { 'ESP_INTEGRITY' };
1755 $confighash { $key }[ 23 ] = $cgiparams { 'ESP_GROUPTYPE' };
1756 $confighash { $key }[ 17 ] = $cgiparams { 'ESP_KEYLIFE' };
1757 $confighash { $key }[ 12 ] = $cgiparams { 'AGGRMODE' };
1758 $confighash { $key }[ 13 ] = $cgiparams { 'COMPRESSION' };
1759 $confighash { $key }[ 24 ] = $cgiparams { 'ONLY_PROPOSED' };
1760 $confighash { $key }[ 28 ] = $cgiparams { 'PFS' };
1761 $confighash { $key }[ 14 ] = $cgiparams { 'VHOST' };
1763 #free unused fields!
1764 $confighash { $key }[ 6 ] = 'off' ;
1765 $confighash { $key }[ 15 ] = 'off' ;
1767 & General
:: writehasharray
( "${General::swroot}/vpn/config" , \
%confighash );
1770 system ( '/usr/local/bin/ipsecctrl' , 'S' , $key );
1773 if ( $cgiparams { 'EDIT_ADVANCED' } eq 'on' ) {
1774 $cgiparams { 'KEY' } = $key ;
1775 $cgiparams { 'ACTION' } = $Lang :: tr
{ 'advanced' };
1778 } else { # add new connection
1779 $cgiparams { 'ENABLED' } = 'on' ;
1780 if ( ! - f
"${General::swroot}/private/cakey.pem" ) {
1781 $cgiparams { 'AUTH' } = 'psk' ;
1782 } elsif ( ! - f
"${General::swroot}/ca/cacert.pem" ) {
1783 $cgiparams { 'AUTH' } = 'certfile' ;
1785 $cgiparams { 'AUTH' } = 'certgen' ;
1787 $cgiparams { 'LOCAL_SUBNET' } = " $netsettings {'GREEN_NETADDRESS'}/ $netsettings {'GREEN_NETMASK'}" ;
1788 $cgiparams { 'CERT_EMAIL' } = $vpnsettings { 'ROOTCERT_EMAIL' };
1789 $cgiparams { 'CERT_OU' } = $vpnsettings { 'ROOTCERT_OU' };
1790 $cgiparams { 'CERT_ORGANIZATION' } = $vpnsettings { 'ROOTCERT_ORGANIZATION' };
1791 $cgiparams { 'CERT_CITY' } = $vpnsettings { 'ROOTCERT_CITY' };
1792 $cgiparams { 'CERT_STATE' } = $vpnsettings { 'ROOTCERT_STATE' };
1793 $cgiparams { 'CERT_COUNTRY' } = $vpnsettings { 'ROOTCERT_COUNTRY' };
1795 # choose appropriate dpd action
1796 if ( $cgiparams { 'TYPE' } eq 'host' ) {
1797 $cgiparams { 'DPD_ACTION' } = 'clear' ;
1799 $cgiparams { 'DPD_ACTION' } = 'restart' ;
1802 # Default is yes for 'pfs'
1803 $cgiparams { 'PFS' } = 'on' ;
1806 $cgiparams { 'LOCAL_ID' } = '' ;
1807 $cgiparams { 'REMOTE_ID' } = '' ;
1809 #use default advanced value
1810 $cgiparams { 'IKE_ENCRYPTION' } = 'aes128|3des' ; #[18];
1811 $cgiparams { 'IKE_INTEGRITY' } = 'sha|md5' ; #[19];
1812 $cgiparams { 'IKE_GROUPTYPE' } = '1536|1024' ; #[20];
1813 $cgiparams { 'IKE_LIFETIME' } = '1' ; #[16];
1814 $cgiparams { 'ESP_ENCRYPTION' } = 'aes128|3des' ; #[21];
1815 $cgiparams { 'ESP_INTEGRITY' } = 'sha1|md5' ; #[22];
1816 $cgiparams { 'ESP_GROUPTYPE' } = '' ; #[23];
1817 $cgiparams { 'ESP_KEYLIFE' } = '8' ; #[17];
1818 $cgiparams { 'AGGRMODE' } = 'off' ; #[12];
1819 $cgiparams { 'COMPRESSION' } = 'off' ; #[13];
1820 $cgiparams { 'ONLY_PROPOSED' } = 'off' ; #[24];
1821 $cgiparams { 'PFS' } = 'on' ; #[28];
1822 $cgiparams { 'VHOST' } = 'on' ; #[14];
1826 $checked { 'ENABLED' }{ 'off' } = '' ;
1827 $checked { 'ENABLED' }{ 'on' } = '' ;
1828 $checked { 'ENABLED' }{ $cgiparams { 'ENABLED' }} = "checked='checked'" ;
1830 $checked { 'EDIT_ADVANCED' }{ 'off' } = '' ;
1831 $checked { 'EDIT_ADVANCED' }{ 'on' } = '' ;
1832 $checked { 'EDIT_ADVANCED' }{ $cgiparams { 'EDIT_ADVANCED' }} = "checked='checked'" ;
1834 $checked { 'AUTH' }{ 'psk' } = '' ;
1835 $checked { 'AUTH' }{ 'certreq' } = '' ;
1836 $checked { 'AUTH' }{ 'certgen' } = '' ;
1837 $checked { 'AUTH' }{ 'certfile' } = '' ;
1838 $checked { 'AUTH' }{ 'pkcs12' } = '' ;
1839 $checked { 'AUTH' }{ 'auth-dn' } = '' ;
1840 $checked { 'AUTH' }{ $cgiparams { 'AUTH' }} = "checked='checked'" ;
1842 $selected { 'INTERFACE' }{ 'RED' } = '' ;
1843 $selected { 'INTERFACE' }{ 'ORANGE' } = '' ;
1844 $selected { 'INTERFACE' }{ 'GREEN' } = '' ;
1845 $selected { 'INTERFACE' }{ 'BLUE' } = '' ;
1846 $selected { 'INTERFACE' }{ $cgiparams { 'INTERFACE' }} = "selected='selected'" ;
1848 $selected { 'DPD_ACTION' }{ 'clear' } = '' ;
1849 $selected { 'DPD_ACTION' }{ 'hold' } = '' ;
1850 $selected { 'DPD_ACTION' }{ 'restart' } = '' ;
1851 $selected { 'DPD_ACTION' }{ $cgiparams { 'DPD_ACTION' }} = "selected='selected'" ;
1853 & Header
:: showhttpheaders
();
1854 & Header
:: openpage
( $Lang :: tr
{ 'vpn configuration main' }, 1 , '' );
1855 & Header
:: openbigbox
( '100%' , 'left' , '' , $errormessage );
1856 if ( $errormessage ) {
1857 & Header
:: openbox
( '100%' , 'left' , $Lang :: tr
{ 'error messages' });
1858 print "<class name='base'> $errormessage " ;
1859 print " </class>" ;
1860 & Header
:: closebox
();
1864 & Header
:: openbox
( '100%' , 'left' , " $Lang ::tr{'warning messages'}:" );
1865 print "<class name='base'> $warnmessage " ;
1866 print " </class>" ;
1867 & Header
:: closebox
();
1870 print "<form method='post' enctype='multipart/form-data' action=' $ENV {'SCRIPT_NAME'}'>" ;
1872 <input type='hidden' name='TYPE' value=' $cgiparams {'TYPE'}' />
1873 <input type='hidden' name='IKE_ENCRYPTION' value=' $cgiparams {'IKE_ENCRYPTION'}' />
1874 <input type='hidden' name='IKE_INTEGRITY' value=' $cgiparams {'IKE_INTEGRITY'}' />
1875 <input type='hidden' name='IKE_GROUPTYPE' value=' $cgiparams {'IKE_GROUPTYPE'}' />
1876 <input type='hidden' name='IKE_LIFETIME' value=' $cgiparams {'IKE_LIFETIME'}' />
1877 <input type='hidden' name='ESP_ENCRYPTION' value=' $cgiparams {'ESP_ENCRYPTION'}' />
1878 <input type='hidden' name='ESP_INTEGRITY' value=' $cgiparams {'ESP_INTEGRITY'}' />
1879 <input type='hidden' name='ESP_GROUPTYPE' value=' $cgiparams {'ESP_GROUPTYPE'}' />
1880 <input type='hidden' name='ESP_KEYLIFE' value=' $cgiparams {'ESP_KEYLIFE'}' />
1881 <input type='hidden' name='AGGRMODE' value=' $cgiparams {'AGGRMODE'}' />
1882 <input type='hidden' name='COMPRESSION' value=' $cgiparams {'COMPRESSION'}' />
1883 <input type='hidden' name='ONLY_PROPOSED' value=' $cgiparams {'ONLY_PROPOSED'}' />
1884 <input type='hidden' name='PFS' value=' $cgiparams {'PFS'}' />
1885 <input type='hidden' name='VHOST' value=' $cgiparams {'VHOST'}' />
1888 if ( $cgiparams { 'KEY' }) {
1889 print "<input type='hidden' name='KEY' value=' $cgiparams {'KEY'}' />" ;
1890 print "<input type='hidden' name='AUTH' value=' $cgiparams {'AUTH'}' />" ;
1893 & Header
:: openbox
( '100%' , 'left' , " $Lang ::tr{'connection'}:" );
1894 print "<table width='100%'>" ;
1895 print "<tr><td width='25%' class='boldbase'> $Lang ::tr{'name'}:</td>" ;
1896 if ( $cgiparams { 'KEY' }) {
1897 print "<td width='25%' class='base'><input type='hidden' name='NAME' value=' $cgiparams {'NAME'}' /><b> $cgiparams {'NAME'}</b></td>" ;
1899 print "<td width='25%'><input type='text' name='NAME' value=' $cgiparams {'NAME'}' size='30' /></td>" ;
1901 print "<td> $Lang ::tr{'enabled'}</td><td><input type='checkbox' name='ENABLED' $checked{'ENABLED'}{'on'} /></td></tr>" ;
1902 print '</tr><td><br /></td><tr>' ;
1906 if ( $cgiparams { 'TYPE' } eq 'host' ) {
1907 $disabled = "disabled='disabled'" ;
1908 $blob = "<img src='/blob.gif' alt='*' />" ;
1911 print "<tr><td> $Lang ::tr{'host ip'}:</td>" ;
1912 print "<td><select name='INTERFACE'>" ;
1913 print "<option value='RED' $selected {'INTERFACE'}{'RED'}>RED ( $vpnsettings {'VPN_IP'})</option>" ;
1914 print "<option value='GREEN' $selected {'INTERFACE'}{'GREEN'}>GREEN ( $netsettings {'GREEN_ADDRESS'})</option>" ;
1915 print "<option value='BLUE' $selected {'INTERFACE'}{'BLUE'}>BLUE ( $netsettings {'BLUE_ADDRESS'})</option>" if ( $netsettings { 'BLUE_DEV' } ne '' );
1916 print "<option value='ORANGE' $selected {'INTERFACE'}{'ORANGE'}>ORANGE ( $netsettings {'ORANGE_ADDRESS'})</option>" if ( $netsettings { 'ORANGE_DEV' } ne '' );
1917 print "</select></td>" ;
1919 <td class='boldbase'> $Lang ::tr{'remote host/ip'}: $blob </td>
1920 <td><input type='text' name='REMOTE' value=' $cgiparams {'REMOTE'}' size='30' /></td>
1922 <td class='boldbase' nowrap='nowrap'> $Lang ::tr{'local subnet'}</td>
1923 <td><input type='text' name='LOCAL_SUBNET' value=' $cgiparams {'LOCAL_SUBNET'}' size='30' /></td>
1924 <td class='boldbase' nowrap='nowrap'> $Lang ::tr{'remote subnet'}</td>
1925 <td><input $disabled type='text' name='REMOTE_SUBNET' value=' $cgiparams {'REMOTE_SUBNET'}' size='30' /></td>
1927 <td class='boldbase'> $Lang ::tr{'vpn local id'}: <img src='/blob.gif' alt='*' />
1928 <br />( $Lang ::tr{'eg'} <tt>@xy.example.com</tt>)</td>
1929 <td><input type='text' name='LOCAL_ID' value=' $cgiparams {'LOCAL_ID'}' /></td>
1930 <td class='boldbase'> $Lang ::tr{'vpn remote id'}: <img src='/blob.gif' alt='*' /></td>
1931 <td><input type='text' name='REMOTE_ID' value=' $cgiparams {'REMOTE_ID'}' /></td>
1933 </tr><td><br /></td><tr>
1934 <td> $Lang ::tr{'dpd action'}:</td>
1935 <td><select name='DPD_ACTION'>
1936 <option value='clear' $selected {'DPD_ACTION'}{'clear'}>clear</option>
1937 <option value='hold' $selected {'DPD_ACTION'}{'hold'}>hold</option>
1938 <option value='restart' $selected {'DPD_ACTION'}{'restart'}>restart</option>
1939 </select> <a href='http://www.openswan.com/docs/local/README.DPD'>?</a>
1942 <!--http://www.openswan.com/docs/local/README.DPD
1943 http://bugs.xelerance.com/view.php?id=156
1944 restart = clear + reinitiate connection
1946 <td class='boldbase'> $Lang ::tr{'remark title'} <img src='/blob.gif' alt='*' /></td>
1947 <td colspan='3'><input type='text' name='REMARK' value=' $cgiparams {'REMARK'}' size='55' maxlength='50' /></td>
1951 if (! $cgiparams { 'KEY' }) {
1952 print "<tr><td colspan='3'><input type='checkbox' name='EDIT_ADVANCED' $checked {'EDIT_ADVANCED'}{'on'} /> $Lang ::tr{'edit advanced settings when done'}</td></tr>" ;
1955 & Header
:: closebox
();
1957 if ( $cgiparams { 'KEY' } && $cgiparams { 'AUTH' } eq 'psk' ) {
1958 & Header
:: openbox
( '100%' , 'left' , $Lang :: tr
{ 'authentication' });
1960 <table width='100%' cellpadding='0' cellspacing='5' border='0'>
1961 <tr><td class='base' width='50%'> $Lang ::tr{'use a pre-shared key'}</td>
1962 <td class='base' width='50%'><input type='text' name='PSK' size='30' value=' $cgiparams {'PSK'}' /></td>
1967 & Header
:: closebox
();
1968 } elsif (! $cgiparams { 'KEY' }) {
1969 my $pskdisabled = ( $vpnsettings { 'VPN_IP' } eq ' %defaultroute ' ) ?
"disabled='disabled'" : '' ;
1970 $cgiparams { 'PSK' } = $Lang :: tr
{ 'vpn incompatible use of defaultroute' } if ( $pskdisabled );
1971 my $cakeydisabled = ( ! - f
"${General::swroot}/private/cakey.pem" ) ?
"disabled='disabled'" : '' ;
1972 $cgiparams { 'CERT_NAME' } = $Lang :: tr
{ 'vpn no full pki' } if ( $cakeydisabled );
1973 my $cacrtdisabled = ( ! - f
"${General::swroot}/ca/cacert.pem" ) ?
"disabled='disabled'" : '' ;
1975 & Header
:: openbox
( '100%' , 'left' , $Lang :: tr
{ 'authentication' });
1977 <table width='100%' cellpadding='0' cellspacing='5' border='0'>
1978 <tr><td width='5%'><input type='radio' name='AUTH' value='psk' $checked {'AUTH'}{'psk'} $pskdisabled /></td>
1979 <td class='base' width='55%'> $Lang ::tr{'use a pre-shared key'}</td>
1980 <td class='base' width='40%'><input type='text' name='PSK' size='30' value=' $cgiparams {'PSK'}' $pskdisabled /></td></tr>
1981 <tr><td colspan='3' bgcolor='#000000'></td></tr>
1982 <tr><td><input type='radio' name='AUTH' value='certreq' $checked {'AUTH'}{'certreq'} $cakeydisabled /></td>
1983 <td class='base'><hr /> $Lang ::tr{'upload a certificate request'}</td>
1984 <td class='base' rowspan='3' valign='middle'><input type='file' name='FH' size='30' $cacrtdisabled /></td></tr>
1985 <tr><td><input type='radio' name='AUTH' value='certfile' $checked {'AUTH'}{'certfile'} $cacrtdisabled /></td>
1986 <td class='base'> $Lang ::tr{'upload a certificate'}</td></tr>
1987 <tr><td><input type='radio' name='AUTH' value='pkcs12' $cacrtdisabled /></td>
1988 <td class='base'> $Lang ::tr{'upload p12 file'} $Lang ::tr{'pkcs12 file password'}:<input type='password' name='P12_PASS'/></td></tr>
1989 <tr><td><input type='radio' name='AUTH' value='auth-dn' $checked {'AUTH'}{'auth-dn'} $cacrtdisabled /></td>
1990 <td class='base'><hr /> $Lang ::tr{'vpn auth-dn'}</td></tr>
1991 <tr><td colspan='3' bgcolor='#000000'></td></tr>
1992 <tr><td><input type='radio' name='AUTH' value='certgen' $checked {'AUTH'}{'certgen'} $cakeydisabled /></td>
1993 <td class='base'><hr /> $Lang ::tr{'generate a certificate'}</td><td> </td></tr>
1995 <td class='base'> $Lang ::tr{'users fullname or system hostname'}:</td>
1996 <td class='base' nowrap='nowrap'><input type='text' name='CERT_NAME' value=' $cgiparams {'CERT_NAME'}' size='32' $cakeydisabled /></td></tr>
1998 <td class='base'> $Lang ::tr{'users email'}: <img src='/blob.gif' alt='*' /></td>
1999 <td class='base' nowrap='nowrap'><input type='text' name='CERT_EMAIL' value=' $cgiparams {'CERT_EMAIL'}' size='32' $cakeydisabled /></td></tr>
2001 <td class='base'> $Lang ::tr{'users department'}: <img src='/blob.gif' alt='*' /></td>
2002 <td class='base' nowrap='nowrap'><input type='text' name='CERT_OU' value=' $cgiparams {'CERT_OU'}' size='32' $cakeydisabled /></td></tr>
2004 <td class='base'> $Lang ::tr{'organization name'}: <img src='/blob.gif' alt='*' /></td>
2005 <td class='base' nowrap='nowrap'><input type='text' name='CERT_ORGANIZATION' value=' $cgiparams {'CERT_ORGANIZATION'}' size='32' $cakeydisabled /></td></tr>
2007 <td class='base'> $Lang ::tr{'city'}: <img src='/blob.gif' alt='*' /></td>
2008 <td class='base' nowrap='nowrap'><input type='text' name='CERT_CITY' value=' $cgiparams {'CERT_CITY'}' size='32' $cakeydisabled /></td></tr>
2010 <td class='base'> $Lang ::tr{'state or province'}: <img src='/blob.gif' alt='*' /></td>
2011 <td class='base' nowrap='nowrap'><input type='text' name='CERT_STATE' value=' $cgiparams {'CERT_STATE'}' size='32' $cakeydisabled /></td></tr>
2013 <td class='base'> $Lang ::tr{'country'}:</td>
2014 <td class='base'><select name='CERT_COUNTRY' $cakeydisabled >
2017 foreach my $country ( sort keys %{ Countries
:: countries
}) {
2018 print " \t\t\t <option value=' $Countries ::countries{ $country }'" ;
2019 if ( $Countries :: countries
{ $country } eq $cgiparams { 'CERT_COUNTRY' } ) {
2020 print " selected='selected'" ;
2022 print "> $country </option> \n " ;
2027 <tr><td> </td><td class='base'> $Lang ::tr{'vpn subjectaltname'} (subjectAltName=email:*,URI:*,DNS:*,RID:*)<img src='/blob.gif' alt='*' /></td>
2028 <td class='base' nowrap='nowrap'><input type='text' name='SUBJECTALTNAME' value=' $cgiparams {'SUBJECTALTNAME'}' size='32' $cakeydisabled /></td></tr>
2030 <td class='base'> $Lang ::tr{'pkcs12 file password'}:</td>
2031 <td class='base' nowrap='nowrap'><input type='password' name='CERT_PASS1' value=' $cgiparams {'CERT_PASS1'}' size='32' $cakeydisabled /></td></tr>
2032 <tr><td> </td><td class='base'> $Lang ::tr{'pkcs12 file password'}:( $Lang ::tr{'confirmation'})</td>
2033 <td class='base' nowrap='nowrap'><input type='password' name='CERT_PASS2' value=' $cgiparams {'CERT_PASS2'}' size='32' $cakeydisabled /></td></tr>
2037 & Header
:: closebox
();
2040 print "<div align='center'><input type='submit' name='ACTION' value=' $Lang ::tr{'save'}' />" ;
2041 if ( $cgiparams { 'KEY' }) {
2042 print "<input type='submit' name='ACTION' value=' $Lang ::tr{'advanced'}' />" ;
2044 print "<input type='submit' name='ACTION' value=' $Lang ::tr{'cancel'}' /></div></form>" ;
2045 & Header
:: closebigbox
();
2046 & Header
:: closepage
();
2053 ### Advanced settings
2055 if (( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'advanced' }) ||
2056 ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'save' } && $cgiparams { 'ADVANCED' } eq 'yes' )) {
2057 & General
:: readhash
( "${General::swroot}/vpn/settings" , \
%vpnsettings );
2058 & General
:: readhasharray
( "${General::swroot}/vpn/config" , \
%confighash );
2059 if (! $confighash { $cgiparams { 'KEY' }}) {
2060 $errormessage = $Lang :: tr
{ 'invalid key' };
2064 if ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'save' }) {
2065 # I didn't read any incompatibilities here....
2066 #if ($cgiparams{'VHOST'} eq 'on' && $cgiparams{'COMPRESSION'} eq 'on') {
2067 # $errormessage = $Lang::tr{'cannot enable both nat traversal and compression'};
2068 # goto ADVANCED_ERROR;
2070 my @temp = split ( '\|' , $cgiparams { 'IKE_ENCRYPTION' });
2072 $errormessage = $Lang :: tr
{ 'invalid input' };
2073 goto ADVANCED_ERROR
;
2075 foreach my $val ( @temp ) {
2076 if ( $val !~ /^(aes256|aes128|3des|twofish256|twofish128|serpent256|serpent128|blowfish256|blowfish128|cast128)$/ ) {
2077 $errormessage = $Lang :: tr
{ 'invalid input' };
2078 goto ADVANCED_ERROR
;
2081 @temp = split ( '\|' , $cgiparams { 'IKE_INTEGRITY' });
2083 $errormessage = $Lang :: tr
{ 'invalid input' };
2084 goto ADVANCED_ERROR
;
2086 foreach my $val ( @temp ) {
2087 if ( $val !~ /^(sha2_512|sha2_256|sha|md5)$/ ) {
2088 $errormessage = $Lang :: tr
{ 'invalid input' };
2089 goto ADVANCED_ERROR
;
2092 @temp = split ( '\|' , $cgiparams { 'IKE_GROUPTYPE' });
2094 $errormessage = $Lang :: tr
{ 'invalid input' };
2095 goto ADVANCED_ERROR
;
2097 foreach my $val ( @temp ) {
2098 if ( $val !~ /^(768|1024|1536|2048|3072|4096|6144|8192)$/ ) {
2099 $errormessage = $Lang :: tr
{ 'invalid input' };
2100 goto ADVANCED_ERROR
;
2103 if ( $cgiparams { 'IKE_LIFETIME' } !~ /^\d+$/ ) {
2104 $errormessage = $Lang :: tr
{ 'invalid input for ike lifetime' };
2105 goto ADVANCED_ERROR
;
2107 if ( $cgiparams { 'IKE_LIFETIME' } < 1 || $cgiparams { 'IKE_LIFETIME' } > 8 ) {
2108 $errormessage = $Lang :: tr
{ 'ike lifetime should be between 1 and 8 hours' };
2109 goto ADVANCED_ERROR
;
2111 @temp = split ( '\|' , $cgiparams { 'ESP_ENCRYPTION' });
2113 $errormessage = $Lang :: tr
{ 'invalid input' };
2114 goto ADVANCED_ERROR
;
2116 foreach my $val ( @temp ) {
2117 if ( $val !~ /^(aes256|aes128|3des|twofish256|twofish128|serpent256|serpent128|blowfish256|blowfish128)$/ ) {
2118 $errormessage = $Lang :: tr
{ 'invalid input' };
2119 goto ADVANCED_ERROR
;
2122 @temp = split ( '\|' , $cgiparams { 'ESP_INTEGRITY' });
2124 $errormessage = $Lang :: tr
{ 'invalid input' };
2125 goto ADVANCED_ERROR
;
2127 foreach my $val ( @temp ) {
2128 if ( $val !~ /^(sha2_512|sha2_256|sha1|md5)$/ ) {
2129 $errormessage = $Lang :: tr
{ 'invalid input' };
2130 goto ADVANCED_ERROR
;
2133 if ( $cgiparams { 'ESP_GROUPTYPE' } ne '' &&
2134 $cgiparams { 'ESP_GROUPTYPE' } !~ /^modp(768|1024|1536|2048|3072|4096)$/ ) {
2135 $errormessage = $Lang :: tr
{ 'invalid input' };
2136 goto ADVANCED_ERROR
;
2139 if ( $cgiparams { 'ESP_KEYLIFE' } !~ /^\d+$/ ) {
2140 $errormessage = $Lang :: tr
{ 'invalid input for esp keylife' };
2141 goto ADVANCED_ERROR
;
2143 if ( $cgiparams { 'ESP_KEYLIFE' } < 1 || $cgiparams { 'ESP_KEYLIFE' } > 24 ) {
2144 $errormessage = $Lang :: tr
{ 'esp keylife should be between 1 and 24 hours' };
2145 goto ADVANCED_ERROR
;
2149 ( $cgiparams { 'AGGRMODE' } !~ /^(|on|off)$/ ) ||
2150 ( $cgiparams { 'COMPRESSION' } !~ /^(|on|off)$/ ) ||
2151 ( $cgiparams { 'ONLY_PROPOSED' } !~ /^(|on|off)$/ ) ||
2152 ( $cgiparams { 'PFS' } !~ /^(|on|off)$/ ) ||
2153 ( $cgiparams { 'VHOST' } !~ /^(|on|off)$/ )
2155 $errormessage = $Lang :: tr
{ 'invalid input' };
2156 goto ADVANCED_ERROR
;
2159 $confighash { $cgiparams { 'KEY' }}[ 18 ] = $cgiparams { 'IKE_ENCRYPTION' };
2160 $confighash { $cgiparams { 'KEY' }}[ 19 ] = $cgiparams { 'IKE_INTEGRITY' };
2161 $confighash { $cgiparams { 'KEY' }}[ 20 ] = $cgiparams { 'IKE_GROUPTYPE' };
2162 $confighash { $cgiparams { 'KEY' }}[ 16 ] = $cgiparams { 'IKE_LIFETIME' };
2163 $confighash { $cgiparams { 'KEY' }}[ 21 ] = $cgiparams { 'ESP_ENCRYPTION' };
2164 $confighash { $cgiparams { 'KEY' }}[ 22 ] = $cgiparams { 'ESP_INTEGRITY' };
2165 $confighash { $cgiparams { 'KEY' }}[ 23 ] = $cgiparams { 'ESP_GROUPTYPE' };
2166 $confighash { $cgiparams { 'KEY' }}[ 17 ] = $cgiparams { 'ESP_KEYLIFE' };
2167 $confighash { $cgiparams { 'KEY' }}[ 12 ] = $cgiparams { 'AGGRMODE' };
2168 $confighash { $cgiparams { 'KEY' }}[ 13 ] = $cgiparams { 'COMPRESSION' };
2169 $confighash { $cgiparams { 'KEY' }}[ 24 ] = $cgiparams { 'ONLY_PROPOSED' };
2170 $confighash { $cgiparams { 'KEY' }}[ 28 ] = $cgiparams { 'PFS' };
2171 $confighash { $cgiparams { 'KEY' }}[ 14 ] = $cgiparams { 'VHOST' };
2172 & General
:: writehasharray
( "${General::swroot}/vpn/config" , \
%confighash );
2175 system ( '/usr/local/bin/ipsecctrl' , 'S' , $cgiparams { 'KEY' });
2180 $cgiparams { 'IKE_ENCRYPTION' } = $confighash { $cgiparams { 'KEY' }}[ 18 ];
2181 $cgiparams { 'IKE_INTEGRITY' } = $confighash { $cgiparams { 'KEY' }}[ 19 ];
2182 $cgiparams { 'IKE_GROUPTYPE' } = $confighash { $cgiparams { 'KEY' }}[ 20 ];
2183 $cgiparams { 'IKE_LIFETIME' } = $confighash { $cgiparams { 'KEY' }}[ 16 ];
2184 $cgiparams { 'ESP_ENCRYPTION' } = $confighash { $cgiparams { 'KEY' }}[ 21 ];
2185 $cgiparams { 'ESP_INTEGRITY' } = $confighash { $cgiparams { 'KEY' }}[ 22 ];
2186 $cgiparams { 'ESP_GROUPTYPE' } = $confighash { $cgiparams { 'KEY' }}[ 23 ];
2187 $cgiparams { 'ESP_KEYLIFE' } = $confighash { $cgiparams { 'KEY' }}[ 17 ];
2188 $cgiparams { 'AGGRMODE' } = $confighash { $cgiparams { 'KEY' }}[ 12 ];
2189 $cgiparams { 'COMPRESSION' } = $confighash { $cgiparams { 'KEY' }}[ 13 ];
2190 $cgiparams { 'ONLY_PROPOSED' } = $confighash { $cgiparams { 'KEY' }}[ 24 ];
2191 $cgiparams { 'PFS' } = $confighash { $cgiparams { 'KEY' }}[ 28 ];
2192 $cgiparams { 'VHOST' } = $confighash { $cgiparams { 'KEY' }}[ 14 ];
2194 if ( $confighash { $cgiparams { 'KEY' }}[ 3 ] eq 'net' || $confighash { $cgiparams { 'KEY' }}[ 10 ]) {
2195 $cgiparams { 'VHOST' } = 'off' ;
2200 $checked { 'IKE_ENCRYPTION' }{ 'aes256' } = '' ;
2201 $checked { 'IKE_ENCRYPTION' }{ 'aes128' } = '' ;
2202 $checked { 'IKE_ENCRYPTION' }{ '3des' } = '' ;
2203 $checked { 'IKE_ENCRYPTION' }{ 'twofish256' } = '' ;
2204 $checked { 'IKE_ENCRYPTION' }{ 'twofish128' } = '' ;
2205 $checked { 'IKE_ENCRYPTION' }{ 'serpent256' } = '' ;
2206 $checked { 'IKE_ENCRYPTION' }{ 'serpent128' } = '' ;
2207 $checked { 'IKE_ENCRYPTION' }{ 'blowfish256' } = '' ;
2208 $checked { 'IKE_ENCRYPTION' }{ 'blowfish128' } = '' ;
2209 $checked { 'IKE_ENCRYPTION' }{ 'cast128' } = '' ;
2210 my @temp = split ( '\|' , $cgiparams { 'IKE_ENCRYPTION' });
2211 foreach my $key ( @temp ) { $checked { 'IKE_ENCRYPTION' }{ $key } = "selected='selected'" ; }
2212 $checked { 'IKE_INTEGRITY' }{ 'sha2_512' } = '' ;
2213 $checked { 'IKE_INTEGRITY' }{ 'sha2_256' } = '' ;
2214 $checked { 'IKE_INTEGRITY' }{ 'sha' } = '' ;
2215 $checked { 'IKE_INTEGRITY' }{ 'md5' } = '' ;
2216 @temp = split ( '\|' , $cgiparams { 'IKE_INTEGRITY' });
2217 foreach my $key ( @temp ) { $checked { 'IKE_INTEGRITY' }{ $key } = "selected='selected'" ; }
2218 $checked { 'IKE_GROUPTYPE' }{ '768' } = '' ;
2219 $checked { 'IKE_GROUPTYPE' }{ '1024' } = '' ;
2220 $checked { 'IKE_GROUPTYPE' }{ '1536' } = '' ;
2221 $checked { 'IKE_GROUPTYPE' }{ '2048' } = '' ;
2222 $checked { 'IKE_GROUPTYPE' }{ '3072' } = '' ;
2223 $checked { 'IKE_GROUPTYPE' }{ '4096' } = '' ;
2224 $checked { 'IKE_GROUPTYPE' }{ '6144' } = '' ;
2225 $checked { 'IKE_GROUPTYPE' }{ '8192' } = '' ;
2226 @temp = split ( '\|' , $cgiparams { 'IKE_GROUPTYPE' });
2227 foreach my $key ( @temp ) { $checked { 'IKE_GROUPTYPE' }{ $key } = "selected='selected'" ; }
2228 $checked { 'ESP_ENCRYPTION' }{ 'aes256' } = '' ;
2229 $checked { 'ESP_ENCRYPTION' }{ 'aes128' } = '' ;
2230 $checked { 'ESP_ENCRYPTION' }{ '3des' } = '' ;
2231 $checked { 'ESP_ENCRYPTION' }{ 'twofish256' } = '' ;
2232 $checked { 'ESP_ENCRYPTION' }{ 'twofish128' } = '' ;
2233 $checked { 'ESP_ENCRYPTION' }{ 'serpent256' } = '' ;
2234 $checked { 'ESP_ENCRYPTION' }{ 'serpent128' } = '' ;
2235 $checked { 'ESP_ENCRYPTION' }{ 'blowfish256' } = '' ;
2236 $checked { 'ESP_ENCRYPTION' }{ 'blowfish128' } = '' ;
2237 @temp = split ( '\|' , $cgiparams { 'ESP_ENCRYPTION' });
2238 foreach my $key ( @temp ) { $checked { 'ESP_ENCRYPTION' }{ $key } = "selected='selected'" ; }
2239 $checked { 'ESP_INTEGRITY' }{ 'sha2_512' } = '' ;
2240 $checked { 'ESP_INTEGRITY' }{ 'sha2_256' } = '' ;
2241 $checked { 'ESP_INTEGRITY' }{ 'sha1' } = '' ;
2242 $checked { 'ESP_INTEGRITY' }{ 'md5' } = '' ;
2243 @temp = split ( '\|' , $cgiparams { 'ESP_INTEGRITY' });
2244 foreach my $key ( @temp ) { $checked { 'ESP_INTEGRITY' }{ $key } = "selected='selected'" ; }
2245 $checked { 'ESP_GROUPTYPE' }{ 'modp768' } = '' ;
2246 $checked { 'ESP_GROUPTYPE' }{ 'modp1024' } = '' ;
2247 $checked { 'ESP_GROUPTYPE' }{ 'modp1536' } = '' ;
2248 $checked { 'ESP_GROUPTYPE' }{ 'modp2048' } = '' ;
2249 $checked { 'ESP_GROUPTYPE' }{ 'modp3072' } = '' ;
2250 $checked { 'ESP_GROUPTYPE' }{ 'modp4096' } = '' ;
2251 $checked { 'ESP_GROUPTYPE' }{ $cgiparams { 'ESP_GROUPTYPE' }} = "selected='selected'" ;
2253 $checked { 'AGGRMODE' } = $cgiparams { 'AGGRMODE' } eq 'on' ?
"checked='checked'" : '' ;
2254 $checked { 'COMPRESSION' } = $cgiparams { 'COMPRESSION' } eq 'on' ?
"checked='checked'" : '' ;
2255 $checked { 'ONLY_PROPOSED' } = $cgiparams { 'ONLY_PROPOSED' } eq 'on' ?
"checked='checked'" : '' ;
2256 $checked { 'PFS' } = $cgiparams { 'PFS' } eq 'on' ?
"checked='checked'" : '' ;
2257 $checked { 'VHOST' } = $cgiparams { 'VHOST' } eq 'on' ?
"checked='checked'" : '' ;
2259 & Header
:: showhttpheaders
();
2260 & Header
:: openpage
( $Lang :: tr
{ 'vpn configuration main' }, 1 , '' );
2261 & Header
:: openbigbox
( '100%' , 'left' , '' , $errormessage );
2263 if ( $errormessage ) {
2264 & Header
:: openbox
( '100%' , 'left' , $Lang :: tr
{ 'error messages' });
2265 print "<class name='base'> $errormessage " ;
2266 print " </class>" ;
2267 & Header
:: closebox
();
2271 & Header
:: openbox
( '100%' , 'left' , $Lang :: tr
{ 'warning messages' });
2272 print "<class name='base'> $warnmessage " ;
2273 print " </class>" ;
2274 & Header
:: closebox
();
2277 & Header
:: openbox
( '100%' , 'left' , " $Lang ::tr{'advanced'}:" );
2279 <form method='post' enctype='multipart/form-data' action=' $ENV {'SCRIPT_NAME'}'>
2280 <input type='hidden' name='ADVANCED' value='yes' />
2281 <input type='hidden' name='KEY' value=' $cgiparams {'KEY'}' />
2283 <table width='100%'>
2284 <tr><td class='boldbase' align='right' valign='top'> $Lang ::tr{'ike encryption'}</td><td class='boldbase' valign='top'>
2285 <select name='IKE_ENCRYPTION' multiple='multiple' size='4'>
2286 <option value='aes256' $checked {'IKE_ENCRYPTION'}{'aes256'}>AES (256 bit)</option>
2287 <option value='aes128' $checked {'IKE_ENCRYPTION'}{'aes128'}>AES (128 bit)</option>
2288 <option value='3des' $checked {'IKE_ENCRYPTION'}{'3des'}>3DES</option>
2289 <option value='twofish256' $checked {'IKE_ENCRYPTION'}{'twofish256'}>Twofish (256 bit)</option>
2290 <option value='twofish128' $checked {'IKE_ENCRYPTION'}{'twofish128'}>Twofish (128 bit)</option>
2291 <option value='serpent256' $checked {'IKE_ENCRYPTION'}{'serpent256'}>Serpent (256 bit)</option>
2292 <option value='serpent128' $checked {'IKE_ENCRYPTION'}{'serpent128'}>Serpent (128 bit)</option>
2293 <option value='blowfish256' $checked {'IKE_ENCRYPTION'}{'blowfish256'}>Blowfish (256 bit)</option>
2294 <option value='blowfish128' $checked {'IKE_ENCRYPTION'}{'blowfish128'}>Blowfish (128 bit)</option>
2295 <option value='cast128' $checked {'IKE_ENCRYPTION'}{'cast128'}>Cast (128 bit)</option>
2298 <td class='boldbase' align='right' valign='top'> $Lang ::tr{'ike integrity'}</td><td class='boldbase' valign='top'>
2299 <select name='IKE_INTEGRITY' multiple='multiple' size='4'>
2300 <option value='sha2_512' $checked {'IKE_INTEGRITY'}{'sha2_512'}>SHA2 (512)</option>
2301 <option value='sha2_256' $checked {'IKE_INTEGRITY'}{'sha2_256'}>SHA2 (256)</option>
2302 <option value='sha' $checked {'IKE_INTEGRITY'}{'sha'}>SHA</option>
2303 <option value='md5' $checked {'IKE_INTEGRITY'}{'md5'}>MD5</option>
2306 <td class='boldbase' align='right' valign='top'> $Lang ::tr{'ike grouptype'}</td><td class='boldbase' valign='top'>
2307 <select name='IKE_GROUPTYPE' multiple='multiple' size='4'>
2308 <option value='8192' $checked {'IKE_GROUPTYPE'}{'8192'}>MODP-8192</option>
2309 <option value='6144' $checked {'IKE_GROUPTYPE'}{'6144'}>MODP-6144</option>
2310 <option value='4096' $checked {'IKE_GROUPTYPE'}{'4096'}>MODP-4096</option>
2311 <option value='3072' $checked {'IKE_GROUPTYPE'}{'3072'}>MODP-3072</option>
2312 <option value='2048' $checked {'IKE_GROUPTYPE'}{'2048'}>MODP-2048</option>
2313 <option value='1536' $checked {'IKE_GROUPTYPE'}{'1536'}>MODP-1536</option>
2314 <option value='1024' $checked {'IKE_GROUPTYPE'}{'1024'}>MODP-1024</option>
2315 <option value='768' $checked {'IKE_GROUPTYPE'}{'768'}>MODP-768</option>
2318 <td class='boldbase' align='right' valign='top'> $Lang ::tr{'ike lifetime'}</td><td class='boldbase' valign='top'>
2319 <input type='text' name='IKE_LIFETIME' value=' $cgiparams {'IKE_LIFETIME'}' size='5' /> $Lang ::tr{'hours'}</td>
2322 <td colspan='1'><hr /></td>
2324 <td class='boldbase' align='right' valign='top'> $Lang ::tr{'esp encryption'}</td><td class='boldbase' valign='top'>
2325 <select name='ESP_ENCRYPTION' multiple='multiple' size='4'>
2326 <option value='aes256' $checked {'ESP_ENCRYPTION'}{'aes256'}>AES (256 bit)</option>
2327 <option value='aes128' $checked {'ESP_ENCRYPTION'}{'aes128'}>AES (128 bit)</option>
2328 <option value='3des' $checked {'ESP_ENCRYPTION'}{'3des'}>3DES</option>
2329 <option value='twofish256' $checked {'ESP_ENCRYPTION'}{'twofish256'}>Twofish (256 bit)</option>
2330 <option value='twofish128' $checked {'ESP_ENCRYPTION'}{'twofish128'}>Twofish (128 bit)</option>
2331 <option value='serpent256' $checked {'ESP_ENCRYPTION'}{'serpent256'}>Serpent (256 bit)</option>
2332 <option value='serpent128' $checked {'ESP_ENCRYPTION'}{'serpent128'}>Serpent (128 bit)</option>
2333 <option value='blowfish256' $checked {'ESP_ENCRYPTION'}{'blowfish256'}>Blowfish (256 bit)</option>
2334 <option value='blowfish128' $checked {'ESP_ENCRYPTION'}{'blowfish128'}>Blowfish (128 bit)</option></select></td>
2336 <td class='boldbase' align='right' valign='top'> $Lang ::tr{'esp integrity'}</td><td class='boldbase' valign='top'>
2337 <select name='ESP_INTEGRITY' multiple='multiple' size='4'>
2338 <option value='sha2_512' $checked {'ESP_INTEGRITY'}{'sha2_512'}>SHA2 (512)</option>
2339 <option value='sha2_256' $checked {'ESP_INTEGRITY'}{'sha2_256'}>SHA2 (256)</option>
2340 <option value='sha1' $checked {'ESP_INTEGRITY'}{'sha1'}>SHA1</option>
2341 <option value='md5' $checked {'ESP_INTEGRITY'}{'md5'}>MD5</option></select></td>
2343 <td class='boldbase' align='right' valign='top'> $Lang ::tr{'esp grouptype'}</td><td class='boldbase' valign='top'>
2344 <select name='ESP_GROUPTYPE'>
2345 <option value=''> $Lang ::tr{'phase1 group'}</option>
2346 <option value='modp4096' $checked {'ESP_GROUPTYPE'}{'modp4096'}>MODP-4096</option>
2347 <option value='modp3072' $checked {'ESP_GROUPTYPE'}{'modp3072'}>MODP-3072</option>
2348 <option value='modp2048' $checked {'ESP_GROUPTYPE'}{'modp2048'}>MODP-2048</option>
2349 <option value='modp1536' $checked {'ESP_GROUPTYPE'}{'modp1536'}>MODP-1536</option>
2350 <option value='modp1024' $checked {'ESP_GROUPTYPE'}{'modp1024'}>MODP-1024</option>
2351 <option value='modp768' $checked {'ESP_GROUPTYPE'}{'modp768'}>MODP-768</option></select></td>
2353 <td class='boldbase' align='right' valign='top'> $Lang ::tr{'esp keylife'}</td><td class='boldbase' valign='top'>
2354 <input type='text' name='ESP_KEYLIFE' value=' $cgiparams {'ESP_KEYLIFE'}' size='5' /> $Lang ::tr{'hours'}</td>
2356 <td colspan='1'><hr /></td>
2358 <td colspan='5'><input type='checkbox' name='ONLY_PROPOSED' $checked {'ONLY_PROPOSED'} />
2359 IKE+ESP: $Lang ::tr{'use only proposed settings'}</td>
2361 <td colspan='5'><input type='checkbox' name='AGGRMODE' $checked {'AGGRMODE'} />
2362 $Lang ::tr{'vpn aggrmode'}</td>
2364 <td colspan='5'><input type='checkbox' name='PFS' $checked {'PFS'} />
2365 $Lang ::tr{'pfs yes no'}</td>
2366 <td align='right'><input type='submit' name='ACTION' value=' $Lang ::tr{'save'}' /></td>
2368 <td colspan='5'><input type='checkbox' name='COMPRESSION' $checked {'COMPRESSION'} />
2369 $Lang ::tr{'vpn payload compression'}</td>
2370 <td align='right'><input type='submit' name='ACTION' value=' $Lang ::tr{'cancel'}' /></td>
2374 if ( $confighash { $cgiparams { 'KEY' }}[ 3 ] eq 'net' ) {
2375 print "<tr><td><input type='hidden' name='VHOST' value='off' /></td></tr>" ;
2376 } elsif ( $confighash { $cgiparams { 'KEY' }}[ 10 ]) {
2377 print "<tr><td colspan='5'><input type='checkbox' name='VHOST' $checked {'VHOST'} disabled='disabled' />" ;
2378 print " $Lang ::tr{'vpn vhost'}</td></tr>" ;
2380 print "<tr><td colspan='5'><input type='checkbox' name='VHOST' $checked {'VHOST'} />" ;
2381 print " $Lang ::tr{'vpn vhost'}</td></tr>" ;
2384 print "</table></form>" ;
2385 & Header
:: closebox
();
2386 & Header
:: closebigbox
();
2387 & Header
:: closepage
();
2394 ### Default status page
2399 & General
:: readhash
( "${General::swroot}/vpn/settings" , \
%cgiparams );
2400 & General
:: readhasharray
( "${General::swroot}/vpn/caconfig" , \
%cahash );
2401 & General
:: readhasharray
( "${General::swroot}/vpn/config" , \
%confighash );
2402 $cgiparams { 'CA_NAME' } = '' ;
2404 my @status = `/usr/sbin/ipsec auto --status` ;
2406 # suggest a default name for this side
2407 if ( $cgiparams { 'VPN_IP' } eq '' && - e
"${General::swroot}/red/active" ) {
2408 if ( open ( IPADDR
, "${General::swroot}/red/local-ipaddress" )) {
2409 my $ipaddr = < IPADDR
>;
2412 $cgiparams { 'VPN_IP' } = ( gethostbyaddr ( pack ( "C4" , split ( /\./ , $ipaddr )), 2 ))[ 0 ];
2413 if ( $cgiparams { 'VPN_IP' } eq '' ) {
2414 $cgiparams { 'VPN_IP' } = $ipaddr ;
2418 # no IP found, use %defaultroute
2419 $cgiparams { 'VPN_IP' } = ' %defaultroute ' if ( $cgiparams { 'VPN_IP' } eq '' );
2421 $cgiparams { 'VPN_DELAYED_START' } = 0 if (! defined ( $cgiparams { 'VPN_DELAYED_START' }));
2422 $checked { 'VPN_WATCH' } = $cgiparams { 'VPN_WATCH' } eq 'on' ?
"checked='checked'" : '' ;
2423 map ( $checked { $_ } = $cgiparams { $_ } eq 'on' ?
"checked='checked'" : '' ,
2424 ( 'ENABLED' , 'DBG_CRYPT' , 'DBG_PARSING' , 'DBG_EMITTING' , 'DBG_CONTROL' ,
2425 'DBG_KLIPS' , 'DBG_DNS' , 'DBG_NAT_T' ));
2428 & Header
:: showhttpheaders
();
2429 & Header
:: openpage
( $Lang :: tr
{ 'vpn configuration main' }, 1 , '' );
2430 & Header
:: openbigbox
( '100%' , 'left' , '' , $errormessage );
2432 if ( $errormessage ) {
2433 & Header
:: openbox
( '100%' , 'left' , $Lang :: tr
{ 'error messages' });
2434 print "<class name='base'> $errormessage \n " ;
2435 print " </class> \n " ;
2436 & Header
:: closebox
();
2439 & Header
:: openbox
( '100%' , 'left' , $Lang :: tr
{ 'global settings' });
2441 <form method='post' action=' $ENV {'SCRIPT_NAME'}'>
2442 <table width='100%'>
2444 <td width='20%' class='base' nowrap='nowrap'> $Lang ::tr{'vpn red name'}:</td>
2445 <td width='20%'><input type='text' name='VPN_IP' value=' $cgiparams {'VPN_IP'}' /></td>
2446 <td width='20%' class='base'> $Lang ::tr{'enabled'}<input type='checkbox' name='ENABLED' $checked {'ENABLED'} /></td>
2452 <td class='base' nowrap='nowrap'> $Lang ::tr{'override mtu'}: <img src='/blob.gif' alt='*' /></td>
2453 <td ><input type='text' name='VPN_OVERRIDE_MTU' value=' $cgiparams {'VPN_OVERRIDE_MTU'}' /></td>
2459 <td class='base' nowrap='nowrap'> $Lang ::tr{'vpn delayed start'}: <img src='/blob.gif' alt='*' /><img src='/blob.gif' alt='*' /></td>
2460 <td ><input type='text' name='VPN_DELAYED_START' value=' $cgiparams {'VPN_DELAYED_START'}' /></td>
2463 <p> $Lang ::tr{'vpn watch'}:<input type='checkbox' name='VPN_WATCH' $checked {'VPN_WATCH'} /></p>
2464 <p>PLUTO DEBUG =
2465 crypt:<input type='checkbox' name='DBG_CRYPT' $checked {'DBG_CRYPT'} />,
2466 parsing:<input type='checkbox' name='DBG_PARSING' $checked {'DBG_PARSING'} />,
2467 emitting:<input type='checkbox' name='DBG_EMITTING' $checked {'DBG_EMITTING'} />,
2468 control:<input type='checkbox' name='DBG_CONTROL' $checked {'DBG_CONTROL'} />,
2469 klips:<input type='checkbox' name='DBG_KLIPS' $checked {'DBG_KLIPS'} />,
2470 dns:<input type='checkbox' name='DBG_DNS' $checked {'DBG_DNS'} />,
2471 nat_t:<input type='checkbox' name='DBG_NAT_T' $checked {'DBG_NAT_T'} /></p>
2474 <table width='100%'>
2476 <td class='base' valign='top'><img src='/blob.gif' alt='*' /></td>
2477 <td width='70%' class='base' valign='top'> $Lang ::tr{'this field may be blank'}</td>
2480 <td class='base' valign='top' nowrap='nowrap'><img src='/blob.gif' alt='*' /><img src='/blob.gif' alt='*' /> </td>
2481 <td class='base'> <font class='base'> $Lang ::tr{'vpn delayed start help'}</font></td>
2482 <td width='30%' align='center' class='base'><input type='submit' name='ACTION' value=' $Lang ::tr{'save'}' /></td>
2488 & Header
:: closebox
();
2490 & Header
:: openbox
( '100%' , 'left' , $Lang :: tr
{ 'connection status and controlc' });
2492 <table width='100%' border='0' cellspacing='1' cellpadding='0'>
2494 <td width='10%' class='boldbase' align='center'><b> $Lang ::tr{'name'}</b></td>
2495 <td width='22%' class='boldbase' align='center'><b> $Lang ::tr{'type'}</b></td>
2496 <td width='23%' class='boldbase' align='center'><b> $Lang ::tr{'common name'}</b></td>
2497 <td width='30%' class='boldbase' align='center'><b> $Lang ::tr{'remark'}</b></td>
2498 <td width='10%' class='boldbase' align='center'><b> $Lang ::tr{'status'}</b></td>
2499 <td class='boldbase' align='center' colspan='6'><b> $Lang ::tr{'action'}</b></td>
2505 foreach my $key ( keys %confighash ) {
2506 if ( $confighash { $key }[ 0 ] eq 'on' ) { $gif = 'on.gif' ; } else { $gif = 'off.gif' ; }
2509 print "<tr bgcolor='${Header::table1colour}'> \n " ;
2511 print "<tr bgcolor='${Header::table2colour}'> \n " ;
2513 print "<td align='center' nowrap='nowrap'> $confighash { $key }[1]</td>" ;
2514 print "<td align='center' nowrap='nowrap'>" . $Lang :: tr
{ " $confighash { $key }[3]" } . " (" . $Lang :: tr
{ " $confighash { $key }[4]" } . ")</td>" ;
2515 if ( $confighash { $key }[ 2 ] eq ' %auth -dn' ) {
2516 print "<td align='left' nowrap='nowrap'> $confighash { $key }[9]</td>" ;
2517 } elsif ( $confighash { $key }[ 4 ] eq 'cert' ) {
2518 print "<td align='left' nowrap='nowrap'> $confighash { $key }[2]</td>" ;
2520 print "<td align='left'> </td>" ;
2522 print "<td align='center'> $confighash { $key }[25]</td>" ;
2524 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>" ;
2525 foreach my $line ( @status ) {
2526 if ( $line =~ /\"$confighash{$key}[1]\".*IPsec SA established/ ) {
2527 $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>" ;
2530 # move to blueif really down
2531 if ( $confighash { $key }[ 0 ] eq 'off' && $active =~ /${Header::colourred}/ ) {
2532 $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>" ;
2535 <td align='center'> $active </td>
2537 <form method='post' action=' $ENV {'SCRIPT_NAME'}'>
2538 <input type='image' name=' $Lang ::tr{'restart'}' src='/images/reload.gif' alt=' $Lang ::tr{'restart'}' title=' $Lang ::tr{'restart'}' />
2539 <input type='hidden' name='ACTION' value=' $Lang ::tr{'restart'}' />
2540 <input type='hidden' name='KEY' value=' $key ' />
2545 if (( $confighash { $key }[ 4 ] eq 'cert' ) && ( $confighash { $key }[ 2 ] ne ' %auth -dn' )) {
2548 <form method='post' action=' $ENV {'SCRIPT_NAME'}'>
2549 <input type='image' name=' $Lang ::tr{'show certificate'}' src='/images/info.gif' alt=' $Lang ::tr{'show certificate'}' title=' $Lang ::tr{'show certificate'}' />
2550 <input type='hidden' name='ACTION' value=' $Lang ::tr{'show certificate'}' />
2551 <input type='hidden' name='KEY' value=' $key ' />
2556 print "<td width='2%'> </td>" ;
2558 if ( $confighash { $key }[ 4 ] eq 'cert' && - f
"${General::swroot}/certs/ $confighash { $key }[1].p12" ) {
2561 <form method='post' action=' $ENV {'SCRIPT_NAME'}'>
2562 <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'}' />
2563 <input type='hidden' name='ACTION' value=' $Lang ::tr{'download pkcs12 file'}' />
2564 <input type='hidden' name='KEY' value=' $key ' />
2568 ; } elsif (( $confighash { $key }[ 4 ] eq 'cert' ) && ( $confighash { $key }[ 2 ] ne ' %auth -dn' )) {
2571 <form method='post' action=' $ENV {'SCRIPT_NAME'}'>
2572 <input type='image' name=' $Lang ::tr{'download certificate'}' src='/images/floppy.gif' alt=' $Lang ::tr{'download certificate'}' title=' $Lang ::tr{'download certificate'}' />
2573 <input type='hidden' name='ACTION' value=' $Lang ::tr{'download certificate'}' />
2574 <input type='hidden' name='KEY' value=' $key ' />
2579 print "<td width='2%'> </td>" ;
2583 <form method='post' action=' $ENV {'SCRIPT_NAME'}'>
2584 <input type='image' name=' $Lang ::tr{'toggle enable disable'}' src='/images/ $gif ' alt=' $Lang ::tr{'toggle enable disable'}' title=' $Lang ::tr{'toggle enable disable'}' />
2585 <input type='hidden' name='ACTION' value=' $Lang ::tr{'toggle enable disable'}' />
2586 <input type='hidden' name='KEY' value=' $key ' />
2591 <form method='post' action=' $ENV {'SCRIPT_NAME'}'>
2592 <input type='hidden' name='ACTION' value=' $Lang ::tr{'edit'}' />
2593 <input type='image' name=' $Lang ::tr{'edit'}' src='/images/edit.gif' alt=' $Lang ::tr{'edit'}' title=' $Lang ::tr{'edit'}' />
2594 <input type='hidden' name='KEY' value=' $key ' />
2597 <td align='center' >
2598 <form method='post' action=' $ENV {'SCRIPT_NAME'}'>
2599 <input type='hidden' name='ACTION' value=' $Lang ::tr{'remove'}' />
2600 <input type='image' name=' $Lang ::tr{'remove'}' src='/images/delete.gif' alt=' $Lang ::tr{'remove'}' title=' $Lang ::tr{'remove'}' />
2601 <input type='hidden' name='KEY' value=' $key ' />
2611 # If the config file contains entries, print Key to action icons
2616 <td class='boldbase'> <b> $Lang ::tr{'legend'}:</b></td>
2617 <td> <img src='/images/on.gif' alt=' $Lang ::tr{'click to disable'}' /></td>
2618 <td class='base'> $Lang ::tr{'click to disable'}</td>
2619 <td> <img src='/images/info.gif' alt=' $Lang ::tr{'show certificate'}' /></td>
2620 <td class='base'> $Lang ::tr{'show certificate'}</td>
2621 <td> <img src='/images/edit.gif' alt=' $Lang ::tr{'edit'}' /></td>
2622 <td class='base'> $Lang ::tr{'edit'}</td>
2623 <td> <img src='/images/delete.gif' alt=' $Lang ::tr{'remove'}' /></td>
2624 <td class='base'> $Lang ::tr{'remove'}</td>
2628 <td> <img src='/images/off.gif' alt='?OFF' /></td>
2629 <td class='base'> $Lang ::tr{'click to enable'}</td>
2630 <td> <img src='/images/floppy.gif' alt='?FLOPPY' /></td>
2631 <td class='base'> $Lang ::tr{'download certificate'}</td>
2632 <td> <img src='/images/reload.gif' alt='?RELOAD'/></td>
2633 <td class='base'> $Lang ::tr{'restart'}</td>
2641 <table width='100%'>
2642 <tr><td align='center' colspan='9'>
2643 <form method='post' action=' $ENV {'SCRIPT_NAME'}'>
2644 <input type='submit' name='ACTION' value=' $Lang ::tr{'add'}' />
2650 & Header
:: closebox
();
2652 & Header
:: openbox
( '100%' , 'left' , " $Lang ::tr{'certificate authorities'}:" );
2654 <table width='100%' border='0' cellspacing='1' cellpadding='0'>
2656 <td width='25%' class='boldbase' align='center'><b> $Lang ::tr{'name'}</b></td>
2657 <td width='65%' class='boldbase' align='center'><b> $Lang ::tr{'subject'}</b></td>
2658 <td width='10%' class='boldbase' colspan='3' align='center'><b> $Lang ::tr{'action'}</b></td>
2662 if (- f
"${General::swroot}/ca/cacert.pem" ) {
2663 my $casubject = & Header
:: cleanhtml
( getsubjectfromcert
( "${General::swroot}/ca/cacert.pem" ));
2666 <tr bgcolor='${Header::table2colour}'>
2667 <td class='base'> $Lang ::tr{'root certificate'}</td>
2668 <td class='base'> $casubject </td>
2669 <td width='3%' align='center'>
2670 <form method='post' action=' $ENV {'SCRIPT_NAME'}'>
2671 <input type='hidden' name='ACTION' value=' $Lang ::tr{'show root certificate'}' />
2672 <input type='image' name=' $Lang ::tr{'edit'}' src='/images/info.gif' alt=' $Lang ::tr{'show root certificate'}' title=' $Lang ::tr{'show root certificate'}' />
2675 <td width='3%' align='center'>
2676 <form method='post' action=' $ENV {'SCRIPT_NAME'}'>
2677 <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'}' />
2678 <input type='hidden' name='ACTION' value=' $Lang ::tr{'download root certificate'}' />
2681 <td width='4%'> </td></tr>
2685 # display rootcert generation buttons
2687 <tr bgcolor='${Header::table2colour}'>
2688 <td class='base'> $Lang ::tr{'root certificate'}:</td>
2689 <td class='base'> $Lang ::tr{'not present'}</td>
2690 <td colspan='3'> </td></tr>
2695 if (- f
"${General::swroot}/certs/hostcert.pem" ) {
2696 my $hostsubject = & Header
:: cleanhtml
( getsubjectfromcert
( "${General::swroot}/certs/hostcert.pem" ));
2699 <tr bgcolor='${Header::table1colour}'>
2700 <td class='base'> $Lang ::tr{'host certificate'}</td>
2701 <td class='base'> $hostsubject </td>
2702 <td width='3%' align='center'>
2703 <form method='post' action=' $ENV {'SCRIPT_NAME'}'>
2704 <input type='hidden' name='ACTION' value=' $Lang ::tr{'show host certificate'}' />
2705 <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'}' />
2708 <td width='3%' align='center'>
2709 <form method='post' action=' $ENV {'SCRIPT_NAME'}'>
2710 <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'}' />
2711 <input type='hidden' name='ACTION' value=' $Lang ::tr{'download host certificate'}' />
2714 <td width='4%'> </td></tr>
2720 <tr bgcolor='${Header::table1colour}'>
2721 <td width='25%' class='base'> $Lang ::tr{'host certificate'}:</td>
2722 <td class='base'> $Lang ::tr{'not present'}</td>
2723 <td colspan='3'> </td></tr>
2729 if ( keys %cahash > 0 ) {
2730 foreach my $key ( keys %cahash ) {
2731 if ( $rowcolor ++ % 2 ) {
2732 print "<tr bgcolor='${Header::table1colour}'> \n " ;
2734 print "<tr bgcolor='${Header::table2colour}'> \n " ;
2736 print "<td class='base'> $cahash { $key }[0]</td> \n " ;
2737 print "<td class='base'> $cahash { $key }[1]</td> \n " ;
2740 <form method='post' name='cafrm${key}a' action=' $ENV {'SCRIPT_NAME'}'>
2741 <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'}' />
2742 <input type='hidden' name='ACTION' value=' $Lang ::tr{'show ca certificate'}' />
2743 <input type='hidden' name='KEY' value=' $key ' />
2747 <form method='post' name='cafrm${key}b' action=' $ENV {'SCRIPT_NAME'}'>
2748 <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'}' />
2749 <input type='hidden' name='ACTION' value=' $Lang ::tr{'download ca certificate'}' />
2750 <input type='hidden' name='KEY' value=' $key ' />
2754 <form method='post' name='cafrm${key}c' action=' $ENV {'SCRIPT_NAME'}'>
2755 <input type='hidden' name='ACTION' value=' $Lang ::tr{'remove ca certificate'}' />
2756 <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'}' />
2757 <input type='hidden' name='KEY' value=' $key ' />
2767 # If the file contains entries, print Key to action icons
2768 if ( - f
"${General::swroot}/ca/cacert.pem" ) {
2771 <td class='boldbase'> <b> $Lang ::tr{'legend'}:</b></td>
2772 <td> <img src='/images/info.gif' alt=' $Lang ::tr{'show certificate'}' /></td>
2773 <td class='base'> $Lang ::tr{'show certificate'}</td>
2774 <td> <img src='/images/floppy.gif' alt=' $Lang ::tr{'download certificate'}' /></td>
2775 <td class='base'> $Lang ::tr{'download certificate'}</td>
2780 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>" ;
2783 <form method='post' enctype='multipart/form-data' action=' $ENV {'SCRIPT_NAME'}'>
2784 <table width='100%' border='0' cellspacing='1' cellpadding='0'>
2787 <td class='base' nowrap='nowrap'> $Lang ::tr{'ca name'}:</td>
2788 <td nowrap='nowrap'><input type='text' name='CA_NAME' value=' $cgiparams {'CA_NAME'}' size='15' /> </td>
2789 <td nowrap='nowrap'><input type='file' name='FH' size='30' /></td>
2790 <td nowrap='nowrap'><input type='submit' name='ACTION' value=' $Lang ::tr{'upload ca certificate'}' /></td>
2793 <td colspan='3'> $Lang ::tr{'resetting the vpn configuration will remove the root ca, the host certificate and all certificate based connections'}:</td>
2794 <td><input type='submit' name='ACTION' value=' $Lang ::tr{'remove x509'}' /></td>
2800 & Header
:: closebox
();
2801 & Header
:: closebigbox
();
2802 & Header
:: closepage
();