]>
git.ipfire.org Git - 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 = '' ;
37 my %mainsettings = ();
38 & General
:: readhash
( "${General::swroot}/main/settings" , \
%mainsettings );
39 & General
:: readhash
( "/srv/web/ipfire/html/themes/" . $mainsettings { 'THEME' }. "/include/colors.txt" , \
%color );
41 & General
:: readhash
( "${General::swroot}/ethernet/settings" , \
%netsettings );
42 $cgiparams { 'ENABLED' } = 'off' ;
43 $cgiparams { 'EDIT_ADVANCED' } = 'off' ;
44 $cgiparams { 'ACTION' } = '' ;
45 $cgiparams { 'CA_NAME' } = '' ;
46 $cgiparams { 'DBG_CRYPT' } = '' ;
47 $cgiparams { 'DBG_PARSING' } = '' ;
48 $cgiparams { 'DBG_EMITTING' } = '' ;
49 $cgiparams { 'DBG_CONTROL' } = '' ;
50 $cgiparams { 'DBG_KLIPS' } = '' ;
51 $cgiparams { 'DBG_DNS' } = '' ;
52 $cgiparams { 'DBG_NAT_T' } = '' ;
53 $cgiparams { 'KEY' } = '' ;
54 $cgiparams { 'TYPE' } = '' ;
55 $cgiparams { 'ADVANCED' } = '' ;
56 $cgiparams { 'INTERFACE' } = '' ;
57 $cgiparams { 'NAME' } = '' ;
58 $cgiparams { 'LOCAL_SUBNET' } = '' ;
59 $cgiparams { 'REMOTE_SUBNET' } = '' ;
60 $cgiparams { 'REMOTE' } = '' ;
61 $cgiparams { 'LOCAL_ID' } = '' ;
62 $cgiparams { 'REMOTE_ID' } = '' ;
63 $cgiparams { 'REMARK' } = '' ;
64 $cgiparams { 'PSK' } = '' ;
65 $cgiparams { 'CERT_NAME' } = '' ;
66 $cgiparams { 'CERT_EMAIL' } = '' ;
67 $cgiparams { 'CERT_OU' } = '' ;
68 $cgiparams { 'CERT_ORGANIZATION' } = '' ;
69 $cgiparams { 'CERT_CITY' } = '' ;
70 $cgiparams { 'CERT_STATE' } = '' ;
71 $cgiparams { 'CERT_COUNTRY' } = '' ;
72 $cgiparams { 'SUBJECTALTNAME' } = '' ;
73 $cgiparams { 'CERT_PASS1' } = '' ;
74 $cgiparams { 'CERT_PASS2' } = '' ;
75 $cgiparams { 'ROOTCERT_HOSTNAME' } = '' ;
76 $cgiparams { 'ROOTCERT_COUNTRY' } = '' ;
77 $cgiparams { 'P12_PASS' } = '' ;
78 $cgiparams { 'ROOTCERT_ORGANIZATION' } = '' ;
79 $cgiparams { 'ROOTCERT_HOSTNAME' } = '' ;
80 $cgiparams { 'ROOTCERT_EMAIL' } = '' ;
81 $cgiparams { 'ROOTCERT_OU' } = '' ;
82 $cgiparams { 'ROOTCERT_CITY' } = '' ;
83 $cgiparams { 'ROOTCERT_STATE' } = '' ;
85 & Header
:: getcgihash
( \
%cgiparams , { 'wantfile' => 1 , 'filevar' => 'FH' });
92 unless ( $hostname ) { return "No hostname" };
93 my $res = new Net
:: DNS
:: Resolver
;
94 my $query = $res -> search ( " $hostname " );
96 foreach my $rr ( $query -> answer ) {
97 ## Potential bug - we are only looking at A records:
98 return 0 if $rr -> type eq "A" ;
101 return $res -> errorstring ;
105 ### Just return true is one interface is vpn enabled
108 return ( $vpnsettings { 'ENABLED' } eq 'on' );
111 ### old version: maintain serial number to one, without explication.
112 ### this : let the counter go, so that each cert is numbered.
116 if ( open ( FILE
, ">${General::swroot}/certs/serial" )) {
120 if ( open ( FILE
, ">${General::swroot}/certs/index.txt" )) {
124 unlink ( "${General::swroot}/certs/index.txt.old" );
125 unlink ( "${General::swroot}/certs/serial.old" );
126 unlink ( "${General::swroot}/certs/01.pem" );
128 sub newcleanssldatabase
130 if (! - s
"${General::swroot}/certs/serial" ) {
131 open ( FILE
, ">${General::swroot}/certs/serial" );
135 if (! - s
">${General::swroot}/certs/index.txt" ) {
136 system ( "touch ${General::swroot}/certs/index.txt" );
138 unlink ( "${General::swroot}/certs/index.txt.old" );
139 unlink ( "${General::swroot}/certs/serial.old" );
140 # unlink ("${General::swroot}/certs/01.pem"); numbering evolves. Wrong place to delete
144 ### Call openssl and return errormessage if any
148 my $retssl = `/usr/bin/openssl $opt 2>&1` ; #redirect stderr
150 foreach my $line ( split ( /\n/ , $retssl )) {
151 & General
:: log ( "ipsec" , " $line " ) if ( 0 ); # 1 for verbose logging
152 $ret .= '<br>' . $line if ( $line =~ /error|unknown/ );
155 $ret = & Header
:: cleanhtml
( $ret );
157 return $ret ?
" $Lang ::tr{'openssl produced an error'}: $ret " : '' ;
160 ### Obtain a CN from given cert
162 sub getCNfromcert
($) {
163 #&General::log("ipsec", "Extracting name from $_[0]...");
164 my $temp = `/usr/bin/openssl x509 -text -in $_ [0]` ;
165 $temp =~ /Subject:.*CN=(.*)[\n]/ ;
167 $temp =~ s
+/ Email
+, E
+;
168 $temp =~ s/ ST=/ S=/ ;
174 ### Obtain Subject from given cert
176 sub getsubjectfromcert
($) {
177 #&General::log("ipsec", "Extracting subject from $_[0]...");
178 my $temp = `/usr/bin/openssl x509 -text -in $_ [0]` ;
179 $temp =~ /Subject: (.*)[\n]/ ;
181 $temp =~ s
+/ Email
+, E
+;
182 $temp =~ s/ ST=/ S=/ ;
186 ### Combine local subnet and connection name to make a unique name for each connection section
187 ### (this sub is not used now)
189 sub makeconnname
($) {
193 $subnet =~ /^(.*?)\/ (.* ?
)$/; # $1=IP $2=mask
194 my $ip = unpack ( 'N' , & Socket
:: inet_aton
( $1 ));
195 if ( length ( $2 ) > 2 ) {
196 my $mm = unpack ( 'N' , & Socket
:: inet_aton
( $2 ));
197 while ( ( $mm & 1 )== 0 ) {
204 return sprintf ( " %s - %X " , $conn , $ip );
207 ### Write a config file.
209 ###Type=Host : GUI can choose the interface used (RED,GREEN,BLUE) and
210 ### the side is always defined as 'left'.
211 ### configihash[14]: 'VHOST' is allowed
214 sub writeipsecfiles
{
215 my %lconfighash = ();
216 my %lvpnsettings = ();
217 & General
:: readhasharray
( "${General::swroot}/vpn/config" , \
%lconfighash );
218 & General
:: readhash
( "${General::swroot}/vpn/settings" , \
%lvpnsettings );
220 open ( CONF
, ">${General::swroot}/vpn/ipsec.conf" ) or die "Unable to open ${General::swroot}/vpn/ipsec.conf: $!" ;
221 open ( SECRETS
, ">${General::swroot}/vpn/ipsec.secrets" ) or die "Unable to open ${General::swroot}/vpn/ipsec.secrets: $!" ;
224 print CONF
"version 2 \n\n " ;
225 print CONF
"config setup \n " ;
226 #create an ipsec Interface for each 'enabled' ones
227 #loop trought configuration and add physical interfaces to the list
228 my $interfaces = " \t interfaces= \" " ;
229 foreach my $key ( keys %lconfighash ) {
230 next if ( $lconfighash { $key }[ 0 ] ne 'on' );
231 $interfaces .= " %defaultroute " if ( $interfaces !~ /defaultroute/ && $lconfighash { $key }[ 26 ] eq 'RED' );
232 $interfaces .= "ipsec1= $netsettings {'GREEN_DEV'} " if ( $interfaces !~ /ipsec1/ && $lconfighash { $key }[ 26 ] eq 'GREEN' );
233 $interfaces .= "ipsec2= $netsettings {'BLUE_DEV'} " if ( $interfaces !~ /ipsec2/ && $lconfighash { $key }[ 26 ] eq 'BLUE' );
234 $interfaces .= "ipsec3= $netsettings {'ORANGE_DEV'} " if ( $interfaces !~ /ipsec3/ && $lconfighash { $key }[ 26 ] eq 'ORANGE' );
236 print CONF
$interfaces . " \"\n " ;
238 my $plutodebug = '' ; # build debug list
239 map ( $plutodebug .= $lvpnsettings { $_ } eq 'on' ?
lc ( substr ( $_ , 4 )). ' ' : '' ,
240 ( 'DBG_CRYPT' , 'DBG_PARSING' , 'DBG_EMITTING' , 'DBG_CONTROL' ,
241 'DBG_KLIPS' , 'DBG_DNS' , 'DBG_NAT_T' ));
242 $plutodebug = 'none' if $plutodebug eq '' ; # if nothing selected, use 'none'.
243 print CONF
" \t klipsdebug= \" none \"\n " ;
244 print CONF
" \t plutodebug= \" $plutodebug \"\n " ;
245 # deprecated in ipsec.conf version 2
246 #print CONF "\tplutoload=%search\n";
247 #print CONF "\tplutostart=%search\n";
248 print CONF
" \t uniqueids=yes \n " ;
249 print CONF
" \t nat_traversal=yes \n " ;
250 print CONF
" \t overridemtu= $lvpnsettings {'VPN_OVERRIDE_MTU'} \n " if ( $lvpnsettings { 'VPN_OVERRIDE_MTU' } ne '' );
251 print CONF
" \t virtual_private= %v4 :10.0.0.0/8, %v4 :172.16.0.0/12, %v4 :192.168.0.0/16" ;
252 print CONF
", %v4 :! $netsettings {'GREEN_NETADDRESS'}/ $netsettings {'GREEN_NETMASK'}" ;
253 if ( length ( $netsettings { 'ORANGE_DEV' }) > 2 ) {
254 print CONF
", %v4 :! $netsettings {'ORANGE_NETADDRESS'}/ $netsettings {'ORANGE_NETMASK'}" ;
256 if ( length ( $netsettings { 'BLUE_DEV' }) > 2 ) {
257 print CONF
", %v4 :! $netsettings {'BLUE_NETADDRESS'}/ $netsettings {'BLUE_NETMASK'}" ;
259 foreach my $key ( keys %lconfighash ) {
260 if ( $lconfighash { $key }[ 3 ] eq 'net' ) {
261 print CONF
", %v4 :! $lconfighash { $key }[11]" ;
265 print CONF
"conn %default \n " ;
266 print CONF
" \t keyingtries=0 \n " ;
267 print CONF
" \t disablearrivalcheck=no \n " ;
270 if (- f
"${General::swroot}/certs/hostkey.pem" ) {
271 print SECRETS
": RSA ${General::swroot}/certs/hostkey.pem \n "
273 my $last_secrets = '' ; # old the less specifics connections
275 foreach my $key ( keys %lconfighash ) {
276 next if ( $lconfighash { $key }[ 0 ] ne 'on' );
278 #remote peer is not set? => use '%any'
279 $lconfighash { $key }[ 10 ] = ' %any ' if ( $lconfighash { $key }[ 10 ] eq '' );
282 if ( $lconfighash { $key }[ 26 ] eq 'BLUE' ) {
283 $localside = $netsettings { 'BLUE_ADDRESS' };
284 } elsif ( $lconfighash { $key }[ 26 ] eq 'GREEN' ) {
285 $localside = $netsettings { 'GREEN_ADDRESS' };
286 } elsif ( $lconfighash { $key }[ 26 ] eq 'ORANGE' ) {
287 $localside = $netsettings { 'ORANGE_ADDRESS' };
289 $localside = $lvpnsettings { 'VPN_IP' };
292 print CONF
"conn $lconfighash { $key }[1] \n " ;
293 print CONF
" \t left= $localside \n " ;
294 print CONF
" \t leftnexthop= %defaultroute \n " if ( $lconfighash { $key }[ 26 ] eq 'RED' && $lvpnsettings { 'VPN_IP' } ne ' %defaultroute ' );
295 print CONF
" \t leftsubnet= $lconfighash { $key }[8] \n " ;
297 print CONF
" \t right= $lconfighash { $key }[10] \n " ;
298 if ( $lconfighash { $key }[ 3 ] eq 'net' ) {
299 print CONF
" \t rightsubnet= $lconfighash { $key }[11] \n " ;
300 print CONF
" \t rightnexthop= %defaultroute \n " ;
301 } elsif ( $lconfighash { $key }[ 10 ] eq ' %any ' && $lconfighash { $key }[ 14 ] eq 'on' ) { #vhost allowed for roadwarriors?
302 print CONF
" \t rightsubnet=vhost: %no , %priv \n " ;
305 # Local Cert and Remote Cert (unless auth is DN dn-auth)
306 if ( $lconfighash { $key }[ 4 ] eq 'cert' ) {
307 print CONF
" \t leftcert=${General::swroot}/certs/hostcert.pem \n " ;
308 print CONF
" \t rightcert=${General::swroot}/certs/ $lconfighash { $key }[1]cert.pem \n " if ( $lconfighash { $key }[ 2 ] ne ' %auth -dn' );
311 # Local and Remote IDs
312 print CONF
" \t leftid= \" $lconfighash { $key }[7] \"\n " if ( $lconfighash { $key }[ 7 ]);
313 print CONF
" \t rightid= \" $lconfighash { $key }[9] \"\n " if ( $lconfighash { $key }[ 9 ]);
316 if ( $lconfighash { $key }[ 18 ] && $lconfighash { $key }[ 19 ] && $lconfighash { $key }[ 20 ]) {
318 my @encs = split ( '\|' , $lconfighash { $key }[ 18 ]);
319 my @ints = split ( '\|' , $lconfighash { $key }[ 19 ]);
320 my @groups = split ( '\|' , $lconfighash { $key }[ 20 ]);
322 foreach my $i ( @encs ) {
323 foreach my $j ( @ints ) {
324 foreach my $k ( @groups ) {
325 if ( $comma != 0 ) { print CONF
"," ; } else { $comma = 1 ; }
326 print CONF
" $i - $j -modp $k " ;
330 if ( $lconfighash { $key }[ 24 ] eq 'on' ) { #only proposed algorythms?
336 if ( $lconfighash { $key }[ 21 ] && $lconfighash { $key }[ 22 ]) {
338 my @encs = split ( '\|' , $lconfighash { $key }[ 21 ]);
339 my @ints = split ( '\|' , $lconfighash { $key }[ 22 ]);
341 foreach my $i ( @encs ) {
342 foreach my $j ( @ints ) {
343 if ( $comma != 0 ) { print CONF
"," ; } else { $comma = 1 ; }
347 if ( $lconfighash { $key }[ 24 ] eq 'on' ) { #only proposed algorythms?
353 if ( $lconfighash { $key }[ 23 ]) {
354 print CONF
" \t pfsgroup= $lconfighash { $key }[23] \n " ;
358 print CONF
" \t ikelifetime= $lconfighash { $key }[16]h \n " if ( $lconfighash { $key }[ 16 ]);
359 print CONF
" \t keylife= $lconfighash { $key }[17]h \n " if ( $lconfighash { $key }[ 17 ]);
362 print CONF
" \t aggrmode=yes \n " if ( $lconfighash { $key }[ 12 ] eq 'on' );
365 print CONF
" \t compress=yes \n " if ( $lconfighash { $key }[ 13 ] eq 'on' );
367 # Dead Peer Detection
368 print CONF
" \t dpddelay=30 \n " ;
369 print CONF
" \t dpdtimeout=120 \n " ;
370 print CONF
" \t dpdaction= $lconfighash { $key }[27] \n " ;
373 print CONF
" \t pfs=" . ( $lconfighash { $key }[ 28 ] eq 'on' ?
"yes \n " : "no \n " );
375 # Build Authentication details: LEFTid RIGHTid : PSK psk
377 if ( $lconfighash { $key }[ 4 ] eq 'psk' ) {
378 $psk_line = ( $lconfighash { $key }[ 7 ] ?
$lconfighash { $key }[ 7 ] : $localside ) . " " ;
379 $psk_line .= $lconfighash { $key }[ 9 ] ?
$lconfighash { $key }[ 9 ] : $lconfighash { $key }[ 10 ]; #remoteid or remote address?
380 $psk_line .= " : PSK ' $lconfighash { $key }[5]' \n " ;
381 # if the line contains %any, it is less specific than two IP or ID, so move it at end of file.
382 if ( $psk_line =~ /%any/ ) {
383 $last_secrets .= $psk_line ;
385 print SECRETS
$psk_line ;
387 print CONF
" \t authby=secret \n " ;
389 print CONF
" \t authby=rsasig \n " ;
390 print CONF
" \t leftrsasigkey= %cert \n " ;
391 print CONF
" \t rightrsasigkey= %cert \n " ;
394 # Automatically start only if a net-to-net connection
395 if ( $lconfighash { $key }[ 3 ] eq 'host' ) {
396 print CONF
" \t auto=add \n " ;
398 print CONF
" \t auto=start \n " ;
402 print SECRETS
$last_secrets if ( $last_secrets );
408 ### Save main settings
410 if ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'save' } && $cgiparams { 'TYPE' } eq '' && $cgiparams { 'KEY' } eq '' ) {
411 & General
:: readhash
( "${General::swroot}/vpn/settings" , \
%vpnsettings );
412 unless (& General
:: validfqdn
( $cgiparams { 'VPN_IP' }) || & General
:: validip
( $cgiparams { 'VPN_IP' })
413 || $cgiparams { 'VPN_IP' } eq ' %defaultroute ' ) {
414 $errormessage = $Lang :: tr
{ 'invalid input for hostname' };
418 unless ( $cgiparams { 'VPN_DELAYED_START' } =~ /^[0-9]{1,3}$/ ) { #allow 0-999 seconds !
419 $errormessage = $Lang :: tr
{ 'invalid time period' };
423 unless ( $cgiparams { 'VPN_OVERRIDE_MTU' } =~ /^(|[0-9]{1,5})$/ ) { #allow 0-99999
424 $errormessage = $Lang :: tr
{ 'vpn mtu invalid' };
428 unless ( $cgiparams { 'VPN_WATCH' } =~ /^(|off|on)$/ ) {
429 $errormessage = $Lang :: tr
{ 'invalid input' };
433 map ( $vpnsettings { $_ } = $cgiparams { $_ },
434 ( 'ENABLED' , 'DBG_CRYPT' , 'DBG_PARSING' , 'DBG_EMITTING' , 'DBG_CONTROL' ,
435 'DBG_KLIPS' , 'DBG_DNS' , 'DBG_NAT_T' ));
437 $vpnsettings { 'VPN_IP' } = $cgiparams { 'VPN_IP' };
438 $vpnsettings { 'VPN_DELAYED_START' } = $cgiparams { 'VPN_DELAYED_START' };
439 $vpnsettings { 'VPN_OVERRIDE_MTU' } = $cgiparams { 'VPN_OVERRIDE_MTU' };
440 $vpnsettings { 'VPN_WATCH' } = $cgiparams { 'VPN_WATCH' };
441 & General
:: writehash
( "${General::swroot}/vpn/settings" , \
%vpnsettings );
444 system ( '/usr/local/bin/ipsecctrl' , 'S' );
446 system ( '/usr/local/bin/ipsecctrl' , 'D' );
453 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'remove x509' } && $cgiparams { 'AREUSURE' } eq 'yes' ) {
454 & General
:: readhasharray
( "${General::swroot}/vpn/config" , \
%confighash );
456 foreach my $key ( keys %confighash ) {
457 if ( $confighash { $key }[ 4 ] eq 'cert' ) {
458 delete $confighash { $key };
461 while ( my $file = glob ( "${General::swroot}/{ca,certs,crls,private}/*" )) {
465 if ( open ( FILE
, ">${General::swroot}/vpn/caconfig" )) {
469 & General
:: writehasharray
( "${General::swroot}/vpn/config" , \
%confighash );
471 system ( '/usr/local/bin/ipsecctrl' , 'R' );
477 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'remove x509' }) {
478 & Header
:: showhttpheaders
();
479 & Header
:: openpage
( $Lang :: tr
{ 'vpn configuration main' }, 1 , '' );
480 & Header
:: openbigbox
( '100%' , 'left' , '' , '' );
481 & Header
:: openbox
( '100%' , 'left' , $Lang :: tr
{ 'are you sure' });
483 <form method='post' action=' $ENV {'SCRIPT_NAME'}'>
487 <input type='hidden' name='AREUSURE' value='yes' />
488 <b><font color='${Header::colourred}'> $Lang ::tr{'capswarning'}</font></b>:
489 $Lang ::tr{'resetting the vpn configuration will remove the root ca, the host certificate and all certificate based connections'}</td>
492 <input type='submit' name='ACTION' value=' $Lang ::tr{'remove x509'}' />
493 <input type='submit' name='ACTION' value=' $Lang ::tr{'cancel'}' /></td>
500 & Header
:: closebigbox
();
501 & Header
:: closepage
();
505 ### Upload CA Certificate
507 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'upload ca certificate' }) {
508 & General
:: readhasharray
( "${General::swroot}/vpn/caconfig" , \
%cahash );
510 if ( $cgiparams { 'CA_NAME' } !~ /^[a-zA-Z0-9]+$/ ) {
511 $errormessage = $Lang :: tr
{ 'name must only contain characters' };
515 if ( length ( $cgiparams { 'CA_NAME' }) > 60 ) {
516 $errormessage = $Lang :: tr
{ 'name too long' };
520 if ( $cgiparams { 'CA_NAME' } eq 'ca' ) {
521 $errormessage = $Lang :: tr
{ 'name is invalid' };
522 goto UPLOAD_CA_ERROR
;
525 # Check if there is no other entry with this name
526 foreach my $key ( keys %cahash ) {
527 if ( $cahash { $key }[ 0 ] eq $cgiparams { 'CA_NAME' }) {
528 $errormessage = $Lang :: tr
{ 'a ca certificate with this name already exists' };
533 if ( ref ( $cgiparams { 'FH' }) ne 'Fh' ) {
534 $errormessage = $Lang :: tr
{ 'there was no file upload' };
537 # Move uploaded ca to a temporary file
538 ( my $fh , my $filename ) = tempfile
( );
539 if ( copy
( $cgiparams { 'FH' }, $fh ) != 1 ) {
543 my $temp = `/usr/bin/openssl x509 -text -in $filename ` ;
544 if ( $temp !~ /CA:TRUE/i ) {
545 $errormessage = $Lang :: tr
{ 'not a valid ca certificate' };
549 move
( $filename , "${General::swroot}/ca/ $cgiparams {'CA_NAME'}cert.pem" );
551 $errormessage = " $Lang ::tr{'certificate file move failed'}: $!" ;
557 my $key = & General
:: findhasharraykey
( \
%cahash );
558 $cahash { $key }[ 0 ] = $cgiparams { 'CA_NAME' };
559 $cahash { $key }[ 1 ] = & Header
:: cleanhtml
( getsubjectfromcert
( "${General::swroot}/ca/ $cgiparams {'CA_NAME'}cert.pem" ));
560 & General
:: writehasharray
( "${General::swroot}/vpn/caconfig" , \
%cahash );
561 system ( '/usr/local/bin/ipsecctrl' , 'R' );
567 ### Display ca certificate
569 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'show ca certificate' }) {
570 & General
:: readhasharray
( "${General::swroot}/vpn/caconfig" , \
%cahash );
572 if ( - f
"${General::swroot}/ca/ $cahash { $cgiparams {'KEY'}}[0]cert.pem" ) {
573 & Header
:: showhttpheaders
();
574 & Header
:: openpage
( $Lang :: tr
{ 'vpn configuration main' }, 1 , '' );
575 & Header
:: openbigbox
( '100%' , 'left' , '' , '' );
576 & Header
:: openbox
( '100%' , 'left' , " $Lang ::tr{'ca certificate'}:" );
577 my $output = `/usr/bin/openssl x509 -text -in ${General::swroot}/ca/ $cahash { $cgiparams {'KEY'}}[0]cert.pem` ;
578 $output = & Header
:: cleanhtml
( $output , "y" );
579 print "<pre> $output </pre> \n " ;
581 print "<div align='center'><a href='/cgi-bin/vpnmain.cgi'> $Lang ::tr{'back'}</a></div>" ;
582 & Header
:: closebigbox
();
583 & Header
:: closepage
();
586 $errormessage = $Lang :: tr
{ 'invalid key' };
590 ### Export ca certificate to browser
592 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'download ca certificate' }) {
593 & General
:: readhasharray
( "${General::swroot}/vpn/caconfig" , \
%cahash );
595 if ( - f
"${General::swroot}/ca/ $cahash { $cgiparams {'KEY'}}[0]cert.pem" ) {
596 print "Content-Type: application/force-download \n " ;
597 print "Content-Type: application/octet-stream \r\n " ;
598 print "Content-Disposition: attachment; filename= $cahash { $cgiparams {'KEY'}}[0]cert.pem \r\n\r\n " ;
599 print `/usr/bin/openssl x509 -in ${General::swroot}/ca/ $cahash { $cgiparams {'KEY'}}[0]cert.pem` ;
602 $errormessage = $Lang :: tr
{ 'invalid key' };
606 ### Remove ca certificate (step 2)
608 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'remove ca certificate' } && $cgiparams { 'AREUSURE' } eq 'yes' ) {
609 & General
:: readhasharray
( "${General::swroot}/vpn/config" , \
%confighash );
610 & General
:: readhasharray
( "${General::swroot}/vpn/caconfig" , \
%cahash );
612 if ( - f
"${General::swroot}/ca/ $cahash { $cgiparams {'KEY'}}[0]cert.pem" ) {
613 foreach my $key ( keys %confighash ) {
614 my $test = `/usr/bin/openssl verify -CAfile ${General::swroot}/ca/ $cahash { $cgiparams {'KEY'}}[0]cert.pem ${General::swroot}/certs/ $confighash { $key }[1]cert.pem` ;
615 if ( $test =~ /: OK/ ) {
617 system ( '/usr/local/bin/ipsecctrl' , 'D' , $key ) if (& vpnenabled
);
618 unlink ( "${General::swroot}/certs/ $confighash { $key }[1]cert.pem" );
619 unlink ( "${General::swroot}/certs/ $confighash { $key }[1].p12" );
620 delete $confighash { $key };
621 & General
:: writehasharray
( "${General::swroot}/vpn/config" , \
%confighash );
625 unlink ( "${General::swroot}/ca/ $cahash { $cgiparams {'KEY'}}[0]cert.pem" );
626 delete $cahash { $cgiparams { 'KEY' }};
627 & General
:: writehasharray
( "${General::swroot}/vpn/caconfig" , \
%cahash );
628 system ( '/usr/local/bin/ipsecctrl' , 'R' );
631 $errormessage = $Lang :: tr
{ 'invalid key' };
634 ### Remove ca certificate (step 1)
636 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'remove ca certificate' }) {
637 & General
:: readhasharray
( "${General::swroot}/vpn/config" , \
%confighash );
638 & General
:: readhasharray
( "${General::swroot}/vpn/caconfig" , \
%cahash );
640 my $assignedcerts = 0 ;
641 if ( - f
"${General::swroot}/ca/ $cahash { $cgiparams {'KEY'}}[0]cert.pem" ) {
642 foreach my $key ( keys %confighash ) {
643 my $test = `/usr/bin/openssl verify -CAfile ${General::swroot}/ca/ $cahash { $cgiparams {'KEY'}}[0]cert.pem ${General::swroot}/certs/ $confighash { $key }[1]cert.pem` ;
644 if ( $test =~ /: OK/ ) {
648 if ( $assignedcerts ) {
649 & Header
:: showhttpheaders
();
650 & Header
:: openpage
( $Lang :: tr
{ 'vpn configuration main' }, 1 , '' );
651 & Header
:: openbigbox
( '100%' , 'left' , '' , '' );
652 & Header
:: openbox
( '100%' , 'left' , $Lang :: tr
{ 'are you sure' });
654 <form method='post' action=' $ENV {'SCRIPT_NAME'}'>
658 <input type='hidden' name='KEY' value=' $cgiparams {'KEY'}' />
659 <input type='hidden' name='AREUSURE' value='yes' /></td>
662 <b><font color='${Header::colourred}'> $Lang ::tr{'capswarning'}</font></b>
663 $Lang ::tr{'connections are associated with this ca. deleting the ca will delete these connections as well.'}</td>
666 <input type='submit' name='ACTION' value=' $Lang ::tr{'remove ca certificate'}' />
667 <input type='submit' name='ACTION' value=' $Lang ::tr{'cancel'}' /></td>
674 & Header
:: closebigbox
();
675 & Header
:: closepage
();
678 unlink ( "${General::swroot}/ca/ $cahash { $cgiparams {'KEY'}}[0]cert.pem" );
679 delete $cahash { $cgiparams { 'KEY' }};
680 & General
:: writehasharray
( "${General::swroot}/vpn/caconfig" , \
%cahash );
681 system ( '/usr/local/bin/ipsecctrl' , 'R' );
685 $errormessage = $Lang :: tr
{ 'invalid key' };
689 ### Display root certificate
691 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'show root certificate' } ||
692 $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'show host certificate' }) {
694 & Header
:: showhttpheaders
();
695 & Header
:: openpage
( $Lang :: tr
{ 'vpn configuration main' }, 1 , '' );
696 & Header
:: openbigbox
( '100%' , 'left' , '' , '' );
697 if ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'show root certificate' }) {
698 & Header
:: openbox
( '100%' , 'left' , " $Lang ::tr{'root certificate'}:" );
699 $output = `/usr/bin/openssl x509 -text -in ${General::swroot}/ca/cacert.pem` ;
701 & Header
:: openbox
( '100%' , 'left' , " $Lang ::tr{'host certificate'}:" );
702 $output = `/usr/bin/openssl x509 -text -in ${General::swroot}/certs/hostcert.pem` ;
704 $output = & Header
:: cleanhtml
( $output , "y" );
705 print "<pre> $output </pre> \n " ;
707 print "<div align='center'><a href='/cgi-bin/vpnmain.cgi'> $Lang ::tr{'back'}</a></div>" ;
708 & Header
:: closebigbox
();
709 & Header
:: closepage
();
713 ### Export root certificate to browser
715 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'download root certificate' }) {
716 if ( - f
"${General::swroot}/ca/cacert.pem" ) {
717 print "Content-Type: application/force-download \n " ;
718 print "Content-Disposition: attachment; filename=cacert.pem \r\n\r\n " ;
719 print `/usr/bin/openssl x509 -in ${General::swroot}/ca/cacert.pem` ;
723 ### Export host certificate to browser
725 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'download host certificate' }) {
726 if ( - f
"${General::swroot}/certs/hostcert.pem" ) {
727 print "Content-Type: application/force-download \n " ;
728 print "Content-Disposition: attachment; filename=hostcert.pem \r\n\r\n " ;
729 print `/usr/bin/openssl x509 -in ${General::swroot}/certs/hostcert.pem` ;
733 ### Form for generating/importing the caroot+host certificate
735 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'generate root/host certificates' } ||
736 $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'upload p12 file' }) {
738 if (- f
"${General::swroot}/ca/cacert.pem" ) {
739 $errormessage = $Lang :: tr
{ 'valid root certificate already exists' };
743 & General
:: readhash
( "${General::swroot}/vpn/settings" , \
%vpnsettings );
744 # fill in initial values
745 if ( $cgiparams { 'ROOTCERT_HOSTNAME' } eq '' ) {
746 if (- e
"${General::swroot}/red/active" && open ( IPADDR
, "${General::swroot}/red/local-ipaddress" )) {
747 my $ipaddr = < IPADDR
>;
750 $cgiparams { 'ROOTCERT_HOSTNAME' } = ( gethostbyaddr ( pack ( "C4" , split ( /\./ , $ipaddr )), 2 ))[ 0 ];
751 if ( $cgiparams { 'ROOTCERT_HOSTNAME' } eq '' ) {
752 $cgiparams { 'ROOTCERT_HOSTNAME' } = $ipaddr ;
755 $cgiparams { 'ROOTCERT_COUNTRY' } = $vpnsettings { 'ROOTCERT_COUNTRY' } if (! $cgiparams { 'ROOTCERT_COUNTRY' });
756 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'upload p12 file' }) {
757 & General
:: log ( "ipsec" , "Importing from p12..." );
759 if ( ref ( $cgiparams { 'FH' }) ne 'Fh' ) {
760 $errormessage = $Lang :: tr
{ 'there was no file upload' };
764 # Move uploaded certificate request to a temporary file
765 ( my $fh , my $filename ) = tempfile
( );
766 if ( copy
( $cgiparams { 'FH' }, $fh ) != 1 ) {
771 # Extract the CA certificate from the file
772 & General
:: log ( "ipsec" , "Extracting caroot from p12..." );
773 if ( open ( STDIN
, "-|" )) {
774 my $opt = " pkcs12 -cacerts -nokeys" ;
775 $opt .= " -in $filename " ;
776 $opt .= " -out /tmp/newcacert" ;
777 $errormessage = & callssl
( $opt );
779 print " $cgiparams {'P12_PASS'} \n " ;
783 # Extract the Host certificate from the file
784 if (! $errormessage ) {
785 & General
:: log ( "ipsec" , "Extracting host cert from p12..." );
786 if ( open ( STDIN
, "-|" )) {
787 my $opt = " pkcs12 -clcerts -nokeys" ;
788 $opt .= " -in $filename " ;
789 $opt .= " -out /tmp/newhostcert" ;
790 $errormessage = & callssl
( $opt );
792 print " $cgiparams {'P12_PASS'} \n " ;
797 # Extract the Host key from the file
798 if (! $errormessage ) {
799 & General
:: log ( "ipsec" , "Extracting private key from p12..." );
800 if ( open ( STDIN
, "-|" )) {
801 my $opt = " pkcs12 -nocerts -nodes" ;
802 $opt .= " -in $filename " ;
803 $opt .= " -out /tmp/newhostkey" ;
804 $errormessage = & callssl
( $opt );
806 print " $cgiparams {'P12_PASS'} \n " ;
811 if (! $errormessage ) {
812 & General
:: log ( "ipsec" , "Moving cacert..." );
813 move
( "/tmp/newcacert" , "${General::swroot}/ca/cacert.pem" );
814 $errormessage = " $Lang ::tr{'certificate file move failed'}: $!" if ($ ?
ne 0 );
817 if (! $errormessage ) {
818 & General
:: log ( "ipsec" , "Moving host cert..." );
819 move
( "/tmp/newhostcert" , "${General::swroot}/certs/hostcert.pem" );
820 $errormessage = " $Lang ::tr{'certificate file move failed'}: $!" if ($ ?
ne 0 );
823 if (! $errormessage ) {
824 & General
:: log ( "ipsec" , "Moving private key..." );
825 move
( "/tmp/newhostkey" , "${General::swroot}/certs/hostkey.pem" );
826 $errormessage = " $Lang ::tr{'certificate file move failed'}: $!" if ($ ?
ne 0 );
831 unlink ( '/tmp/newcacert' );
832 unlink ( '/tmp/newhostcert' );
833 unlink ( '/tmp/newhostkey' );
835 unlink ( "${General::swroot}/ca/cacert.pem" );
836 unlink ( "${General::swroot}/certs/hostcert.pem" );
837 unlink ( "${General::swroot}/certs/hostkey.pem" );
841 # Create empty CRL cannot be done because we don't have
842 # the private key for this CAROOT
843 # IPFire can only import certificates
845 & General
:: log ( "ipsec" , "p12 import completed!" );
847 goto ROOTCERT_SUCCESS
;
849 } elsif ( $cgiparams { 'ROOTCERT_COUNTRY' } ne '' ) {
851 # Validate input since the form was submitted
852 if ( $cgiparams { 'ROOTCERT_ORGANIZATION' } eq '' ){
853 $errormessage = $Lang :: tr
{ 'organization cant be empty' };
856 if ( length ( $cgiparams { 'ROOTCERT_ORGANIZATION' }) > 60 ) {
857 $errormessage = $Lang :: tr
{ 'organization too long' };
860 if ( $cgiparams { 'ROOTCERT_ORGANIZATION' } !~ /^[a-zA-Z0-9 ,\.\-_]*$/ ) {
861 $errormessage = $Lang :: tr
{ 'invalid input for organization' };
864 if ( $cgiparams { 'ROOTCERT_HOSTNAME' } eq '' ){
865 $errormessage = $Lang :: tr
{ 'hostname cant be empty' };
868 unless (& General
:: validfqdn
( $cgiparams { 'ROOTCERT_HOSTNAME' }) || & General
:: validip
( $cgiparams { 'ROOTCERT_HOSTNAME' })) {
869 $errormessage = $Lang :: tr
{ 'invalid input for hostname' };
872 if ( $cgiparams { 'ROOTCERT_EMAIL' } ne '' && (! & General
:: validemail
( $cgiparams { 'ROOTCERT_EMAIL' }))) {
873 $errormessage = $Lang :: tr
{ 'invalid input for e-mail address' };
876 if ( length ( $cgiparams { 'ROOTCERT_EMAIL' }) > 40 ) {
877 $errormessage = $Lang :: tr
{ 'e-mail address too long' };
880 if ( $cgiparams { 'ROOTCERT_OU' } ne '' && $cgiparams { 'ROOTCERT_OU' } !~ /^[a-zA-Z0-9 ,\.\-_]*$/ ) {
881 $errormessage = $Lang :: tr
{ 'invalid input for department' };
884 if ( $cgiparams { 'ROOTCERT_CITY' } ne '' && $cgiparams { 'ROOTCERT_CITY' } !~ /^[a-zA-Z0-9 ,\.\-_]*$/ ) {
885 $errormessage = $Lang :: tr
{ 'invalid input for city' };
888 if ( $cgiparams { 'ROOTCERT_STATE' } ne '' && $cgiparams { 'ROOTCERT_STATE' } !~ /^[a-zA-Z0-9 ,\.\-_]*$/ ) {
889 $errormessage = $Lang :: tr
{ 'invalid input for state or province' };
892 if ( $cgiparams { 'ROOTCERT_COUNTRY' } !~ /^[A-Z]*$/ ) {
893 $errormessage = $Lang :: tr
{ 'invalid input for country' };
896 #the exact syntax is a list comma separated of
897 # email:any-validemail
898 # URI: a uniform resource indicator
899 # DNS: a DNS domain name
900 # RID: a registered OBJECT IDENTIFIER
902 # example: email:franck@foo.com,IP:10.0.0.10,DNS:franck.foo.com
904 if ( $cgiparams { 'SUBJECTALTNAME' } ne '' && $cgiparams { 'SUBJECTALTNAME' } !~ /^(email|URI|DNS|RID|IP):[a-zA-Z0-9 :\/ , \
. \
- _@
]*$/) {
905 $errormessage = $Lang :: tr
{ 'vpn altname syntax' };
909 # Copy the cgisettings to vpnsettings and save the configfile
910 $vpnsettings { 'ROOTCERT_ORGANIZATION' } = $cgiparams { 'ROOTCERT_ORGANIZATION' };
911 $vpnsettings { 'ROOTCERT_HOSTNAME' } = $cgiparams { 'ROOTCERT_HOSTNAME' };
912 $vpnsettings { 'ROOTCERT_EMAIL' } = $cgiparams { 'ROOTCERT_EMAIL' };
913 $vpnsettings { 'ROOTCERT_OU' } = $cgiparams { 'ROOTCERT_OU' };
914 $vpnsettings { 'ROOTCERT_CITY' } = $cgiparams { 'ROOTCERT_CITY' };
915 $vpnsettings { 'ROOTCERT_STATE' } = $cgiparams { 'ROOTCERT_STATE' };
916 $vpnsettings { 'ROOTCERT_COUNTRY' } = $cgiparams { 'ROOTCERT_COUNTRY' };
917 & General
:: writehash
( "${General::swroot}/vpn/settings" , \
%vpnsettings );
919 # Replace empty strings with a .
920 ( my $ou = $cgiparams { 'ROOTCERT_OU' }) =~ s/^\s*$/\./ ;
921 ( my $city = $cgiparams { 'ROOTCERT_CITY' }) =~ s/^\s*$/\./ ;
922 ( my $state = $cgiparams { 'ROOTCERT_STATE' }) =~ s/^\s*$/\./ ;
924 # Create the CA certificate
925 if (! $errormessage ) {
926 & General
:: log ( "ipsec" , "Creating cacert..." );
927 if ( open ( STDIN
, "-|" )) {
928 my $opt = " req -x509 -nodes -rand /proc/interrupts:/proc/net/rt_cache" ;
929 $opt .= " -days 999999" ;
930 $opt .= " -newkey rsa:2048" ;
931 $opt .= " -keyout ${General::swroot}/private/cakey.pem" ;
932 $opt .= " -out ${General::swroot}/ca/cacert.pem" ;
934 $errormessage = & callssl
( $opt );
936 print " $cgiparams {'ROOTCERT_COUNTRY'} \n " ;
939 print " $cgiparams {'ROOTCERT_ORGANIZATION'} \n " ;
941 print " $cgiparams {'ROOTCERT_ORGANIZATION'} CA \n " ;
942 print " $cgiparams {'ROOTCERT_EMAIL'} \n " ;
947 # Create the Host certificate request
948 if (! $errormessage ) {
949 & General
:: log ( "ipsec" , "Creating host cert..." );
950 if ( open ( STDIN
, "-|" )) {
951 my $opt = " req -nodes -rand /proc/interrupts:/proc/net/rt_cache" ;
952 $opt .= " -newkey rsa:1024" ;
953 $opt .= " -keyout ${General::swroot}/certs/hostkey.pem" ;
954 $opt .= " -out ${General::swroot}/certs/hostreq.pem" ;
955 $errormessage = & callssl
( $opt );
957 print " $cgiparams {'ROOTCERT_COUNTRY'} \n " ;
960 print " $cgiparams {'ROOTCERT_ORGANIZATION'} \n " ;
962 print " $cgiparams {'ROOTCERT_HOSTNAME'} \n " ;
963 print " $cgiparams {'ROOTCERT_EMAIL'} \n " ;
970 # Sign the host certificate request
971 if (! $errormessage ) {
972 & General
:: log ( "ipsec" , "Self signing host cert..." );
974 #No easy way for specifying the contain of subjectAltName without writing a config file...
975 my ( $fh , $v3extname ) = tempfile
( '/tmp/XXXXXXXX' );
977 basicConstraints=CA:FALSE
978 nsComment="OpenSSL Generated Certificate"
979 subjectKeyIdentifier=hash
980 authorityKeyIdentifier=keyid,issuer:always
983 print $fh "subjectAltName= $cgiparams {'SUBJECTALTNAME'}" if ( $cgiparams { 'SUBJECTALTNAME' });
986 my $opt = " ca -days 999999" ;
987 $opt .= " -batch -notext" ;
988 $opt .= " -in ${General::swroot}/certs/hostreq.pem" ;
989 $opt .= " -out ${General::swroot}/certs/hostcert.pem" ;
990 $opt .= " -extfile $v3extname " ;
991 $errormessage = & callssl
( $opt );
992 unlink ( "${General::swroot}/certs/hostreq.pem" ); #no more needed
996 # Create an empty CRL
997 if (! $errormessage ) {
998 & General
:: log ( "ipsec" , "Creating emptycrl..." );
999 my $opt = " ca -gencrl" ;
1000 $opt .= " -out ${General::swroot}/crls/cacrl.pem" ;
1001 $errormessage = & callssl
( $opt );
1004 # Successfully build CA / CERT!
1005 if (! $errormessage ) {
1006 & cleanssldatabase
();
1007 goto ROOTCERT_SUCCESS
;
1011 unlink ( "${General::swroot}/ca/cacert.pem" );
1012 unlink ( "${General::swroot}/certs/hostkey.pem" );
1013 unlink ( "${General::swroot}/certs/hostcert.pem" );
1014 unlink ( "${General::swroot}/crls/cacrl.pem" );
1015 & cleanssldatabase
();
1019 & Header
:: showhttpheaders
();
1020 & Header
:: openpage
( $Lang :: tr
{ 'vpn configuration main' }, 1 , '' );
1021 & Header
:: openbigbox
( '100%' , 'left' , '' , $errormessage );
1022 if ( $errormessage ) {
1023 & Header
:: openbox
( '100%' , 'left' , $Lang :: tr
{ 'error messages' });
1024 print "<class name='base'> $errormessage " ;
1025 print " </class>" ;
1026 & Header
:: closebox
();
1028 & Header
:: openbox
( '100%' , 'left' , " $Lang ::tr{'generate root/host certificates'}:" );
1030 <form method='post' enctype='multipart/form-data' action=' $ENV {'SCRIPT_NAME'}'>
1031 <table width='100%' border='0' cellspacing='1' cellpadding='0'>
1032 <tr><td width='40%' class='base'> $Lang ::tr{'organization name'}:</td>
1033 <td width='60%' class='base' nowrap='nowrap'><input type='text' name='ROOTCERT_ORGANIZATION' value=' $cgiparams {'ROOTCERT_ORGANIZATION'}' size='32' /></td></tr>
1034 <tr><td class='base'> $Lang ::tr{'ipfires hostname'}:</td>
1035 <td class='base' nowrap='nowrap'><input type='text' name='ROOTCERT_HOSTNAME' value=' $cgiparams {'ROOTCERT_HOSTNAME'}' size='32' /></td></tr>
1036 <tr><td class='base'> $Lang ::tr{'your e-mail'}: <img src='/blob.gif' alt='*' /></td>
1037 <td class='base' nowrap='nowrap'><input type='text' name='ROOTCERT_EMAIL' value=' $cgiparams {'ROOTCERT_EMAIL'}' size='32' /></td></tr>
1038 <tr><td class='base'> $Lang ::tr{'your department'}: <img src='/blob.gif' alt='*' /></td>
1039 <td class='base' nowrap='nowrap'><input type='text' name='ROOTCERT_OU' value=' $cgiparams {'ROOTCERT_OU'}' size='32' /></td></tr>
1040 <tr><td class='base'> $Lang ::tr{'city'}: <img src='/blob.gif' alt='*' /></td>
1041 <td class='base' nowrap='nowrap'><input type='text' name='ROOTCERT_CITY' value=' $cgiparams {'ROOTCERT_CITY'}' size='32' /></td></tr>
1042 <tr><td class='base'> $Lang ::tr{'state or province'}: <img src='/blob.gif' alt='*' /></td>
1043 <td class='base' nowrap='nowrap'><input type='text' name='ROOTCERT_STATE' value=' $cgiparams {'ROOTCERT_STATE'}' size='32' /></td></tr>
1044 <tr><td class='base'> $Lang ::tr{'country'}:</td>
1045 <td class='base'><select name='ROOTCERT_COUNTRY'>
1048 foreach my $country ( sort keys %{ Countries
:: countries
}) {
1049 print "<option value=' $Countries ::countries{ $country }'" ;
1050 if ( $Countries :: countries
{ $country } eq $cgiparams { 'ROOTCERT_COUNTRY' } ) {
1051 print " selected='selected'" ;
1053 print "> $country </option>" ;
1057 <tr><td class='base'> $Lang ::tr{'vpn subjectaltname'} (subjectAltName=email:*,URI:*,DNS:*,RID:*) <img src='/blob.gif' alt='*' /></td>
1058 <td class='base' nowrap='nowrap'><input type='text' name='SUBJECTALTNAME' value=' $cgiparams {'SUBJECTALTNAME'}' size='32' /></td></tr>
1060 <td><br /><input type='submit' name='ACTION' value=' $Lang ::tr{'generate root/host certificates'}' /><br /><br /></td></tr>
1061 <tr><td class='base' colspan='2' align='left'>
1062 <b><font color='${Header::colourred}'> $Lang ::tr{'capswarning'}</font></b>:
1063 $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'}
1065 <tr><td colspan='2'><hr /></td></tr>
1066 <tr><td class='base' nowrap='nowrap'> $Lang ::tr{'upload p12 file'}:</td>
1067 <td nowrap='nowrap'><input type='file' name='FH' size='32' /></td></tr>
1068 <tr><td class='base'> $Lang ::tr{'pkcs12 file password'}: <img src='/blob.gif' alt='*' /></td>
1069 <td class='base' nowrap='nowrap'><input type='password' name='P12_PASS' value=' $cgiparams {'P12_PASS'}' size='32' /></td></tr>
1071 <td><input type='submit' name='ACTION' value=' $Lang ::tr{'upload p12 file'}' /></td></tr>
1072 <tr><td class='base' colspan='2' align='left'>
1073 <img src='/blob.gif' alt='*' /> $Lang ::tr{'this field may be blank'}</td></tr>
1077 & Header
:: closebox
();
1078 & Header
:: closebigbox
();
1079 & Header
:: closepage
();
1084 system ( '/usr/local/bin/ipsecctrl' , 'S' );
1089 ### Export PKCS12 file to browser
1091 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'download pkcs12 file' }) {
1092 & General
:: readhasharray
( "${General::swroot}/vpn/config" , \
%confighash );
1093 print "Content-Type: application/force-download \n " ;
1094 print "Content-Disposition: attachment; filename=" . $confighash { $cgiparams { 'KEY' }}[ 1 ] . ".p12 \r\n " ;
1095 print "Content-Type: application/octet-stream \r\n\r\n " ;
1096 print `/bin/cat ${General::swroot}/certs/ $confighash { $cgiparams {'KEY'}}[1].p12` ;
1100 ### Display certificate
1102 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'show certificate' }) {
1103 & General
:: readhasharray
( "${General::swroot}/vpn/config" , \
%confighash );
1105 if ( - f
"${General::swroot}/certs/ $confighash { $cgiparams {'KEY'}}[1]cert.pem" ) {
1106 & Header
:: showhttpheaders
();
1107 & Header
:: openpage
( $Lang :: tr
{ 'vpn configuration main' }, 1 , '' );
1108 & Header
:: openbigbox
( '100%' , 'left' , '' , '' );
1109 & Header
:: openbox
( '100%' , 'left' , " $Lang ::tr{'cert'}:" );
1110 my $output = `/usr/bin/openssl x509 -text -in ${General::swroot}/certs/ $confighash { $cgiparams {'KEY'}}[1]cert.pem` ;
1111 $output = & Header
:: cleanhtml
( $output , "y" );
1112 print "<pre> $output </pre> \n " ;
1113 & Header
:: closebox
();
1114 print "<div align='center'><a href='/cgi-bin/vpnmain.cgi'> $Lang ::tr{'back'}</a></div>" ;
1115 & Header
:: closebigbox
();
1116 & Header
:: closepage
();
1121 ### Export Certificate to browser
1123 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'download certificate' }) {
1124 & General
:: readhasharray
( "${General::swroot}/vpn/config" , \
%confighash );
1126 if ( - f
"${General::swroot}/certs/ $confighash { $cgiparams {'KEY'}}[1]cert.pem" ) {
1127 print "Content-Type: application/force-download \n " ;
1128 print "Content-Disposition: attachment; filename=" . $confighash { $cgiparams { 'KEY' }}[ 1 ] . "cert.pem \n\n " ;
1129 print `/bin/cat ${General::swroot}/certs/ $confighash { $cgiparams {'KEY'}}[1]cert.pem` ;
1134 ### Enable/Disable connection
1136 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'toggle enable disable' }) {
1138 & General
:: readhash
( "${General::swroot}/vpn/settings" , \
%vpnsettings );
1139 & General
:: readhasharray
( "${General::swroot}/vpn/config" , \
%confighash );
1141 if ( $confighash { $cgiparams { 'KEY' }}) {
1142 if ( $confighash { $cgiparams { 'KEY' }}[ 0 ] eq 'off' ) {
1143 $confighash { $cgiparams { 'KEY' }}[ 0 ] = 'on' ;
1144 & General
:: writehasharray
( "${General::swroot}/vpn/config" , \
%confighash );
1146 system ( '/usr/local/bin/ipsecctrl' , 'S' , $cgiparams { 'KEY' }) if (& vpnenabled
);
1148 system ( '/usr/local/bin/ipsecctrl' , 'D' , $cgiparams { 'KEY' }) if (& vpnenabled
);
1149 $confighash { $cgiparams { 'KEY' }}[ 0 ] = 'off' ;
1150 & General
:: writehasharray
( "${General::swroot}/vpn/config" , \
%confighash );
1155 $errormessage = $Lang :: tr
{ 'invalid key' };
1159 ### Restart connection
1161 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'restart' }) {
1162 & General
:: readhash
( "${General::swroot}/vpn/settings" , \
%vpnsettings );
1163 & General
:: readhasharray
( "${General::swroot}/vpn/config" , \
%confighash );
1165 if ( $confighash { $cgiparams { 'KEY' }}) {
1167 system ( '/usr/local/bin/ipsecctrl' , 'S' , $cgiparams { 'KEY' });
1171 $errormessage = $Lang :: tr
{ 'invalid key' };
1175 ### Remove connection
1177 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'remove' }) {
1178 & General
:: readhash
( "${General::swroot}/vpn/settings" , \
%vpnsettings );
1179 & General
:: readhasharray
( "${General::swroot}/vpn/config" , \
%confighash );
1181 if ( $confighash { $cgiparams { 'KEY' }}) {
1182 system ( '/usr/local/bin/ipsecctrl' , 'D' , $cgiparams { 'KEY' }) if (& vpnenabled
);
1183 unlink ( "${General::swroot}/certs/ $confighash { $cgiparams {'KEY'}}[1]cert.pem" );
1184 unlink ( "${General::swroot}/certs/ $confighash { $cgiparams {'KEY'}}[1].p12" );
1185 delete $confighash { $cgiparams { 'KEY' }};
1186 & General
:: writehasharray
( "${General::swroot}/vpn/config" , \
%confighash );
1189 $errormessage = $Lang :: tr
{ 'invalid key' };
1193 ### Choose between adding a host-net or net-net connection
1195 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'add' } && $cgiparams { 'TYPE' } eq '' ) {
1196 & Header
:: showhttpheaders
();
1197 & Header
:: openpage
( $Lang :: tr
{ 'vpn configuration main' }, 1 , '' );
1198 & Header
:: openbigbox
( '100%' , 'left' , '' , '' );
1199 & Header
:: openbox
( '100%' , 'left' , $Lang :: tr
{ 'connection type' });
1201 <form method='post' action=' $ENV {'SCRIPT_NAME'}'>
1202 <b> $Lang ::tr{'connection type'}:</b><br />
1204 <tr><td><input type='radio' name='TYPE' value='host' checked='checked' /></td>
1205 <td class='base'> $Lang ::tr{'host to net vpn'}</td>
1207 <td><input type='radio' name='TYPE' value='net' /></td>
1208 <td class='base'> $Lang ::tr{'net to net vpn'}</td>
1210 <td align='center' colspan='2'><input type='submit' name='ACTION' value=' $Lang ::tr{'add'}' /></td>
1215 & Header
:: closebox
();
1216 & Header
:: closebigbox
();
1217 & Header
:: closepage
();
1220 ### Adding/Editing/Saving a connection
1222 } elsif (( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'add' }) ||
1223 ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'edit' }) ||
1224 ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'save' } && $cgiparams { 'ADVANCED' } eq '' )) {
1226 & General
:: readhash
( "${General::swroot}/vpn/settings" , \
%vpnsettings );
1227 & General
:: readhasharray
( "${General::swroot}/vpn/caconfig" , \
%cahash );
1228 & General
:: readhasharray
( "${General::swroot}/vpn/config" , \
%confighash );
1230 if ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'edit' }) {
1231 if (! $confighash { $cgiparams { 'KEY' }}[ 0 ]) {
1232 $errormessage = $Lang :: tr
{ 'invalid key' };
1235 $cgiparams { 'ENABLED' } = $confighash { $cgiparams { 'KEY' }}[ 0 ];
1236 $cgiparams { 'NAME' } = $confighash { $cgiparams { 'KEY' }}[ 1 ];
1237 $cgiparams { 'TYPE' } = $confighash { $cgiparams { 'KEY' }}[ 3 ];
1238 $cgiparams { 'AUTH' } = $confighash { $cgiparams { 'KEY' }}[ 4 ];
1239 $cgiparams { 'PSK' } = $confighash { $cgiparams { 'KEY' }}[ 5 ];
1240 #$cgiparams{'free'} = $confighash{$cgiparams{'KEY'}}[6];
1241 $cgiparams { 'LOCAL_ID' } = $confighash { $cgiparams { 'KEY' }}[ 7 ];
1242 $cgiparams { 'LOCAL_SUBNET' } = $confighash { $cgiparams { 'KEY' }}[ 8 ];
1243 $cgiparams { 'REMOTE_ID' } = $confighash { $cgiparams { 'KEY' }}[ 9 ];
1244 $cgiparams { 'REMOTE' } = $confighash { $cgiparams { 'KEY' }}[ 10 ];
1245 $cgiparams { 'REMOTE_SUBNET' } = $confighash { $cgiparams { 'KEY' }}[ 11 ];
1246 $cgiparams { 'REMARK' } = $confighash { $cgiparams { 'KEY' }}[ 25 ];
1247 $cgiparams { 'INTERFACE' } = $confighash { $cgiparams { 'KEY' }}[ 26 ];
1248 $cgiparams { 'DPD_ACTION' } = $confighash { $cgiparams { 'KEY' }}[ 27 ];
1249 $cgiparams { 'IKE_ENCRYPTION' } = $confighash { $cgiparams { 'KEY' }}[ 18 ];
1250 $cgiparams { 'IKE_INTEGRITY' } = $confighash { $cgiparams { 'KEY' }}[ 19 ];
1251 $cgiparams { 'IKE_GROUPTYPE' } = $confighash { $cgiparams { 'KEY' }}[ 20 ];
1252 $cgiparams { 'IKE_LIFETIME' } = $confighash { $cgiparams { 'KEY' }}[ 16 ];
1253 $cgiparams { 'ESP_ENCRYPTION' } = $confighash { $cgiparams { 'KEY' }}[ 21 ];
1254 $cgiparams { 'ESP_INTEGRITY' } = $confighash { $cgiparams { 'KEY' }}[ 22 ];
1255 $cgiparams { 'ESP_GROUPTYPE' } = $confighash { $cgiparams { 'KEY' }}[ 23 ];
1256 $cgiparams { 'ESP_KEYLIFE' } = $confighash { $cgiparams { 'KEY' }}[ 17 ];
1257 $cgiparams { 'AGGRMODE' } = $confighash { $cgiparams { 'KEY' }}[ 12 ];
1258 $cgiparams { 'COMPRESSION' } = $confighash { $cgiparams { 'KEY' }}[ 13 ];
1259 $cgiparams { 'ONLY_PROPOSED' } = $confighash { $cgiparams { 'KEY' }}[ 24 ];
1260 $cgiparams { 'PFS' } = $confighash { $cgiparams { 'KEY' }}[ 28 ];
1261 $cgiparams { 'VHOST' } = $confighash { $cgiparams { 'KEY' }}[ 14 ];
1263 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'save' }) {
1264 $cgiparams { 'REMARK' } = & Header
:: cleanhtml
( $cgiparams { 'REMARK' });
1265 if ( $cgiparams { 'TYPE' } !~ /^(host|net)$/ ) {
1266 $errormessage = $Lang :: tr
{ 'connection type is invalid' };
1270 if ( $cgiparams { 'NAME' } !~ /^[a-zA-Z0-9]+$/ ) {
1271 $errormessage = $Lang :: tr
{ 'name must only contain characters' };
1275 if ( $cgiparams { 'NAME' } =~ /^(host|01|block|private|clear|packetdefault)$/ ) {
1276 $errormessage = $Lang :: tr
{ 'name is invalid' };
1280 if ( length ( $cgiparams { 'NAME' }) > 60 ) {
1281 $errormessage = $Lang :: tr
{ 'name too long' };
1285 # Check if there is no other entry with this name
1286 if (! $cgiparams { 'KEY' }) { #only for add
1287 foreach my $key ( keys %confighash ) {
1288 if ( $confighash { $key }[ 1 ] eq $cgiparams { 'NAME' }) {
1289 $errormessage = $Lang :: tr
{ 'a connection with this name already exists' };
1295 if (( $cgiparams { 'TYPE' } eq 'net' ) && (! $cgiparams { 'REMOTE' })) {
1296 $errormessage = $Lang :: tr
{ 'invalid input for remote host/ip' };
1300 if ( $cgiparams { 'REMOTE' }) {
1301 if (! & General
:: validip
( $cgiparams { 'REMOTE' })) {
1302 if (! & General
:: validfqdn
( $cgiparams { 'REMOTE' })) {
1303 $errormessage = $Lang :: tr
{ 'invalid input for remote host/ip' };
1306 if (& valid_dns_host
( $cgiparams { 'REMOTE' })) {
1307 $warnmessage = " $Lang ::tr{'check vpn lr'} $cgiparams {'REMOTE'}. $Lang ::tr{'dns check failed'}" ;
1313 unless (& General
:: validipandmask
( $cgiparams { 'LOCAL_SUBNET' })) {
1314 $errormessage = $Lang :: tr
{ 'local subnet is invalid' };
1318 # Allow only one roadwarrior/psk without remote IP-address
1319 if ( $cgiparams { 'REMOTE' } eq '' && $cgiparams { 'AUTH' } eq 'psk' ) {
1320 foreach my $key ( keys %confighash ) {
1321 if ( ( $cgiparams { 'KEY' } ne $key ) &&
1322 ( $confighash { $key }[ 4 ] eq 'psk' ) &&
1323 ( $confighash { $key }[ 10 ] eq '' ) ) {
1324 $errormessage = $Lang :: tr
{ 'you can only define one roadwarrior connection when using pre-shared key authentication' };
1329 if (( $cgiparams { 'TYPE' } eq 'net' ) && (! & General
:: validipandmask
( $cgiparams { 'REMOTE_SUBNET' }))) {
1330 $errormessage = $Lang :: tr
{ 'remote subnet is invalid' };
1334 if ( $cgiparams { 'ENABLED' } !~ /^(on|off)$/ ) {
1335 $errormessage = $Lang :: tr
{ 'invalid input' };
1338 if ( $cgiparams { 'EDIT_ADVANCED' } !~ /^(on|off)$/ ) {
1339 $errormessage = $Lang :: tr
{ 'invalid input' };
1343 # Allow nothing or a string (DN,FDQN,) beginning with @
1344 # with no comma but slashes between RID eg @O=FR/C=Paris/OU=myhome/CN=franck
1345 if ( ( $cgiparams { 'LOCAL_ID' } !~ /^(|[\w.-]*@[\w. =*\/ -]+| \d\
. \d\
. \d\
. \d
)$/) ||
1346 ( $cgiparams { 'REMOTE_ID' } !~ /^(|[\w.-]*@[\w. =*\/ -]+| \d\
. \d\
. \d\
. \d
)$/) ||
1347 (( $cgiparams { 'REMOTE_ID' } eq $cgiparams { 'LOCAL_ID' }) && ( $cgiparams { 'LOCAL_ID' } ne '' ))
1349 $errormessage = $Lang :: tr
{ 'invalid local-remote id' } . '<br />' .
1350 'DER_ASN1_DN: @c =FR/ou=Paris/ou=Home/cn=*<br />' .
1351 'FQDN: @ipfire .org<br />' .
1352 'USER_FQDN: info @ipfire .org<br />' .
1353 'IPV4_ADDR: @123 .123.123.123' ;
1356 # If Auth is DN, verify existance of Remote ID.
1357 if ( $cgiparams { 'REMOTE_ID' } eq '' && (
1358 $cgiparams { 'AUTH' } eq 'auth-dn' || # while creation
1359 $confighash { $cgiparams { 'KEY' }}[ 2 ] eq ' %auth -dn' )){ # while editing
1360 $errormessage = $Lang :: tr
{ 'vpn missing remote id' };
1364 if ( $cgiparams { 'AUTH' } eq 'psk' ) {
1365 if (! length ( $cgiparams { 'PSK' }) ) {
1366 $errormessage = $Lang :: tr
{ 'pre-shared key is too short' };
1369 if ( $cgiparams { 'PSK' } =~ /'/ ) {
1370 $cgiparams { 'PSK' } =~ tr/'/ / ;
1371 $errormessage = $Lang :: tr
{ 'invalid characters found in pre-shared key' };
1374 } elsif ( $cgiparams { 'AUTH' } eq 'certreq' ) {
1375 if ( $cgiparams { 'KEY' }) {
1376 $errormessage = $Lang :: tr
{ 'cant change certificates' };
1379 if ( ref ( $cgiparams { 'FH' }) ne 'Fh' ) {
1380 $errormessage = $Lang :: tr
{ 'there was no file upload' };
1384 # Move uploaded certificate request to a temporary file
1385 ( my $fh , my $filename ) = tempfile
( );
1386 if ( copy
( $cgiparams { 'FH' }, $fh ) != 1 ) {
1391 # Sign the certificate request
1392 & General
:: log ( "ipsec" , "Signing your cert $cgiparams {'NAME'}..." );
1393 my $opt = " ca -days 999999" ;
1394 $opt .= " -batch -notext" ;
1395 $opt .= " -in $filename " ;
1396 $opt .= " -out ${General::swroot}/certs/ $cgiparams {'NAME'}cert.pem" ;
1398 if ( $errormessage = & callssl
( $opt ) ) {
1400 unlink ( "${General::swroot}/certs/ $cgiparams {'NAME'}cert.pem" );
1401 & cleanssldatabase
();
1405 & cleanssldatabase
();
1408 $cgiparams { 'CERT_NAME' } = getCNfromcert
( "${General::swroot}/certs/ $cgiparams {'NAME'}cert.pem" );
1409 if ( $cgiparams { 'CERT_NAME' } eq '' ) {
1410 $errormessage = $Lang :: tr
{ 'could not retrieve common name from certificate' };
1413 } elsif ( $cgiparams { 'AUTH' } eq 'pkcs12' ) {
1414 & General
:: log ( "ipsec" , "Importing from p12..." );
1416 if ( ref ( $cgiparams { 'FH' }) ne 'Fh' ) {
1417 $errormessage = $Lang :: tr
{ 'there was no file upload' };
1418 goto ROOTCERT_ERROR
;
1421 # Move uploaded certificate request to a temporary file
1422 ( my $fh , my $filename ) = tempfile
( );
1423 if ( copy
( $cgiparams { 'FH' }, $fh ) != 1 ) {
1425 goto ROOTCERT_ERROR
;
1428 # Extract the CA certificate from the file
1429 & General
:: log ( "ipsec" , "Extracting caroot from p12..." );
1430 if ( open ( STDIN
, "-|" )) {
1431 my $opt = " pkcs12 -cacerts -nokeys" ;
1432 $opt .= " -in $filename " ;
1433 $opt .= " -out /tmp/newcacert" ;
1434 $errormessage = & callssl
( $opt );
1436 print " $cgiparams {'P12_PASS'} \n " ;
1440 # Extract the Host certificate from the file
1441 if (! $errormessage ) {
1442 & General
:: log ( "ipsec" , "Extracting host cert from p12..." );
1443 if ( open ( STDIN
, "-|" )) {
1444 my $opt = " pkcs12 -clcerts -nokeys" ;
1445 $opt .= " -in $filename " ;
1446 $opt .= " -out /tmp/newhostcert" ;
1447 $errormessage = & callssl
( $opt );
1449 print " $cgiparams {'P12_PASS'} \n " ;
1454 if (! $errormessage ) {
1455 & General
:: log ( "ipsec" , "Moving cacert..." );
1456 #If CA have new subject, add it to our list of CA
1457 my $casubject = & Header
:: cleanhtml
( getsubjectfromcert
( '/tmp/newcacert' ));
1459 foreach my $x ( keys %cahash ) {
1460 $casubject = '' if ( $cahash { $x }[ 1 ] eq $casubject );
1461 unshift ( @names , $cahash { $x }[ 0 ]);
1463 if ( $casubject ) { # a new one!
1464 my $temp = `/usr/bin/openssl x509 -text -in /tmp/newcacert` ;
1465 if ( $temp !~ /CA:TRUE/i ) {
1466 $errormessage = $Lang :: tr
{ 'not a valid ca certificate' };
1468 #compute a name for it
1470 while ( grep ( /Imported-$idx/ , @names ) ) { $idx ++};
1471 $cgiparams { 'CA_NAME' }= "Imported- $idx " ;
1472 $cgiparams { 'CERT_NAME' }=& Header
:: cleanhtml
( getCNfromcert
( '/tmp/newhostcert' ));
1473 move
( "/tmp/newcacert" , "${General::swroot}/ca/ $cgiparams {'CA_NAME'}cert.pem" );
1474 $errormessage = " $Lang ::tr{'certificate file move failed'}: $!" if ($ ?
ne 0 );
1475 if (! $errormessage ) {
1476 my $key = & General
:: findhasharraykey
( \
%cahash );
1477 $cahash { $key }[ 0 ] = $cgiparams { 'CA_NAME' };
1478 $cahash { $key }[ 1 ] = $casubject ;
1479 & General
:: writehasharray
( "${General::swroot}/vpn/caconfig" , \
%cahash );
1480 system ( '/usr/local/bin/ipsecctrl' , 'R' );
1485 if (! $errormessage ) {
1486 & General
:: log ( "ipsec" , "Moving host cert..." );
1487 move
( "/tmp/newhostcert" , "${General::swroot}/certs/ $cgiparams {'NAME'}cert.pem" );
1488 $errormessage = " $Lang ::tr{'certificate file move failed'}: $!" if ($ ?
ne 0 );
1493 unlink ( '/tmp/newcacert' );
1494 unlink ( '/tmp/newhostcert' );
1495 if ( $errormessage ) {
1496 unlink ( "${General::swroot}/ca/ $cgiparams {'CA_NAME'}cert.pem" );
1497 unlink ( "${General::swroot}/certs/ $cgiparams {'NAME'}cert.pem" );
1500 & General
:: log ( "ipsec" , "p12 import completed!" );
1501 } elsif ( $cgiparams { 'AUTH' } eq 'certfile' ) {
1502 if ( $cgiparams { 'KEY' }) {
1503 $errormessage = $Lang :: tr
{ 'cant change certificates' };
1506 if ( ref ( $cgiparams { 'FH' }) ne 'Fh' ) {
1507 $errormessage = $Lang :: tr
{ 'there was no file upload' };
1510 # Move uploaded certificate to a temporary file
1511 ( my $fh , my $filename ) = tempfile
( );
1512 if ( copy
( $cgiparams { 'FH' }, $fh ) != 1 ) {
1517 # Verify the certificate has a valid CA and move it
1518 & General
:: log ( "ipsec" , "Validating imported cert against our known CA..." );
1519 my $validca = 1 ; #assume ok
1520 my $test = `/usr/bin/openssl verify -CAfile ${General::swroot}/ca/cacert.pem $filename ` ;
1521 if ( $test !~ /: OK/ ) {
1523 foreach my $key ( keys %cahash ) {
1524 $test = `/usr/bin/openssl verify -CAfile ${General::swroot}/ca/ $cahash { $key }[0]cert.pem $filename ` ;
1525 if ( $test =~ /: OK/ ) {
1532 $errormessage = $Lang :: tr
{ 'certificate does not have a valid ca associated with it' };
1536 move
( $filename , "${General::swroot}/certs/ $cgiparams {'NAME'}cert.pem" );
1538 $errormessage = " $Lang ::tr{'certificate file move failed'}: $!" ;
1544 $cgiparams { 'CERT_NAME' } = getCNfromcert
( "${General::swroot}/certs/ $cgiparams {'NAME'}cert.pem" );
1545 if ( $cgiparams { 'CERT_NAME' } eq '' ) {
1546 unlink ( "${General::swroot}/certs/ $cgiparams {'NAME'}cert.pem" );
1547 $errormessage = $Lang :: tr
{ 'could not retrieve common name from certificate' };
1550 } elsif ( $cgiparams { 'AUTH' } eq 'certgen' ) {
1551 if ( $cgiparams { 'KEY' }) {
1552 $errormessage = $Lang :: tr
{ 'cant change certificates' };
1555 # Validate input since the form was submitted
1556 if ( length ( $cgiparams { 'CERT_NAME' }) > 60 ) {
1557 $errormessage = $Lang :: tr
{ 'name too long' };
1560 if ( $cgiparams { 'CERT_NAME' } !~ /^[a-zA-Z0-9 ,\.\-_]+$/ ) {
1561 $errormessage = $Lang :: tr
{ 'invalid input for name' };
1564 if ( $cgiparams { 'CERT_EMAIL' } ne '' && (! & General
:: validemail
( $cgiparams { 'CERT_EMAIL' }))) {
1565 $errormessage = $Lang :: tr
{ 'invalid input for e-mail address' };
1568 if ( length ( $cgiparams { 'CERT_EMAIL' }) > 40 ) {
1569 $errormessage = $Lang :: tr
{ 'e-mail address too long' };
1572 if ( $cgiparams { 'CERT_OU' } ne '' && $cgiparams { 'CERT_OU' } !~ /^[a-zA-Z0-9 ,\.\-_]*$/ ) {
1573 $errormessage = $Lang :: tr
{ 'invalid input for department' };
1576 if ( length ( $cgiparams { 'CERT_ORGANIZATION' }) > 60 ) {
1577 $errormessage = $Lang :: tr
{ 'organization too long' };
1580 if ( $cgiparams { 'CERT_ORGANIZATION' } !~ /^[a-zA-Z0-9 ,\.\-_]+$/ ) {
1581 $errormessage = $Lang :: tr
{ 'invalid input for organization' };
1584 if ( $cgiparams { 'CERT_CITY' } ne '' && $cgiparams { 'CERT_CITY' } !~ /^[a-zA-Z0-9 ,\.\-_]*$/ ) {
1585 $errormessage = $Lang :: tr
{ 'invalid input for city' };
1588 if ( $cgiparams { 'CERT_STATE' } ne '' && $cgiparams { 'CERT_STATE' } !~ /^[a-zA-Z0-9 ,\.\-_]*$/ ) {
1589 $errormessage = $Lang :: tr
{ 'invalid input for state or province' };
1592 if ( $cgiparams { 'CERT_COUNTRY' } !~ /^[A-Z]*$/ ) {
1593 $errormessage = $Lang :: tr
{ 'invalid input for country' };
1596 #the exact syntax is a list comma separated of
1597 # email:any-validemail
1598 # URI: a uniform resource indicator
1599 # DNS: a DNS domain name
1600 # RID: a registered OBJECT IDENTIFIER
1602 # example: email:franck@foo.com,IP:10.0.0.10,DNS:franck.foo.com
1604 if ( $cgiparams { 'SUBJECTALTNAME' } ne '' && $cgiparams { 'SUBJECTALTNAME' } !~ /^(email|URI|DNS|RID|IP):[a-zA-Z0-9 :\/ , \
. \
- _@
]*$/) {
1605 $errormessage = $Lang :: tr
{ 'vpn altname syntax' };
1609 if ( length ( $cgiparams { 'CERT_PASS1' }) < 5 ) {
1610 $errormessage = $Lang :: tr
{ 'password too short' };
1613 if ( $cgiparams { 'CERT_PASS1' } ne $cgiparams { 'CERT_PASS2' }) {
1614 $errormessage = $Lang :: tr
{ 'passwords do not match' };
1618 # Replace empty strings with a .
1619 ( my $ou = $cgiparams { 'CERT_OU' }) =~ s/^\s*$/\./ ;
1620 ( my $city = $cgiparams { 'CERT_CITY' }) =~ s/^\s*$/\./ ;
1621 ( my $state = $cgiparams { 'CERT_STATE' }) =~ s/^\s*$/\./ ;
1623 # Create the Host certificate request
1624 & General
:: log ( "ipsec" , "Creating a cert..." );
1626 if ( open ( STDIN
, "-|" )) {
1627 my $opt = " req -nodes -rand /proc/interrupts:/proc/net/rt_cache" ;
1628 $opt .= " -newkey rsa:1024" ;
1629 $opt .= " -keyout ${General::swroot}/certs/ $cgiparams {'NAME'}key.pem" ;
1630 $opt .= " -out ${General::swroot}/certs/ $cgiparams {'NAME'}req.pem" ;
1632 if ( $errormessage = & callssl
( $opt ) ) {
1633 unlink ( "${General::swroot}/certs/ $cgiparams {'NAME'}key.pem" );
1634 unlink ( "${General::swroot}/certs/ $cgiparams {'NAME'}req.pem" );
1638 print " $cgiparams {'CERT_COUNTRY'} \n " ;
1641 print " $cgiparams {'CERT_ORGANIZATION'} \n " ;
1643 print " $cgiparams {'CERT_NAME'} \n " ;
1644 print " $cgiparams {'CERT_EMAIL'} \n " ;
1650 # Sign the host certificate request
1651 & General
:: log ( "ipsec" , "Signing the cert $cgiparams {'NAME'}..." );
1653 #No easy way for specifying the contain of subjectAltName without writing a config file...
1654 my ( $fh , $v3extname ) = tempfile
( '/tmp/XXXXXXXX' );
1656 basicConstraints=CA:FALSE
1657 nsComment="OpenSSL Generated Certificate"
1658 subjectKeyIdentifier=hash
1659 authorityKeyIdentifier=keyid,issuer:always
1662 print $fh "subjectAltName= $cgiparams {'SUBJECTALTNAME'}" if ( $cgiparams { 'SUBJECTALTNAME' });
1665 my $opt = " ca -days 999999 -batch -notext" ;
1666 $opt .= " -in ${General::swroot}/certs/ $cgiparams {'NAME'}req.pem" ;
1667 $opt .= " -out ${General::swroot}/certs/ $cgiparams {'NAME'}cert.pem" ;
1668 $opt .= " -extfile $v3extname " ;
1670 if ( $errormessage = & callssl
( $opt ) ) {
1671 unlink ( $v3extname );
1672 unlink ( "${General::swroot}/certs/ $cgiparams {'NAME'}key.pem" );
1673 unlink ( "${General::swroot}/certs/ $cgiparams {'NAME'}req.pem" );
1674 unlink ( "${General::swroot}/certs/ $cgiparams {'NAME'}cert.pem" );
1675 & cleanssldatabase
();
1678 unlink ( $v3extname );
1679 unlink ( "${General::swroot}/certs/ $cgiparams {'NAME'}req.pem" );
1680 & cleanssldatabase
();
1683 # Create the pkcs12 file
1684 & General
:: log ( "ipsec" , "Packing a pkcs12 file..." );
1685 $opt = " pkcs12 -export" ;
1686 $opt .= " -inkey ${General::swroot}/certs/ $cgiparams {'NAME'}key.pem" ;
1687 $opt .= " -in ${General::swroot}/certs/ $cgiparams {'NAME'}cert.pem" ;
1688 $opt .= " -name \" $cgiparams {'NAME'} \" " ;
1689 $opt .= " -passout pass: $cgiparams {'CERT_PASS1'}" ;
1690 $opt .= " -certfile ${General::swroot}/ca/cacert.pem" ;
1691 $opt .= " -caname \" $vpnsettings {'ROOTCERT_ORGANIZATION'} CA \" " ;
1692 $opt .= " -out ${General::swroot}/certs/ $cgiparams {'NAME'}.p12" ;
1694 if ( $errormessage = & callssl
( $opt ) ) {
1695 unlink ( "${General::swroot}/certs/ $cgiparams {'NAME'}key.pem" );
1696 unlink ( "${General::swroot}/certs/ $cgiparams {'NAME'}cert.pem" );
1697 unlink ( "${General::swroot}/certs/ $cgiparams {'NAME'}.p12" );
1700 unlink ( "${General::swroot}/certs/ $cgiparams {'NAME'}key.pem" );
1702 } elsif ( $cgiparams { 'AUTH' } eq 'cert' ) {
1703 ; # Nothing, just editing
1704 } elsif ( $cgiparams { 'AUTH' } eq 'auth-dn' ) {
1705 $cgiparams { 'CERT_NAME' } = ' %auth -dn' ; # a special value saying 'no cert file'
1707 $errormessage = $Lang :: tr
{ 'invalid input for authentication method' };
1711 # 1)Error message here is not accurate.
1712 # 2)Test is superfluous, openswan can reference same cert multiple times
1713 # 3)Present since initial version (1.3.2.11), it isn't a bug correction
1714 # Check if there is no other entry with this certificate name
1715 #if ((! $cgiparams{'KEY'}) && ($cgiparams{'AUTH'} ne 'psk') && ($cgiparams{'AUTH'} ne 'auth-dn')) {
1716 # foreach my $key (keys %confighash) {
1717 # if ($confighash{$key}[2] eq $cgiparams{'CERT_NAME'}) {
1718 # $errormessage = $Lang::tr{'a connection with this common name already exists'};
1719 # goto VPNCONF_ERROR;
1725 my $key = $cgiparams { 'KEY' };
1727 $key = & General
:: findhasharraykey
( \
%confighash );
1728 foreach my $i ( 0 .. 28 ) { $confighash { $key }[ $i ] = "" ;}
1730 $confighash { $key }[ 0 ] = $cgiparams { 'ENABLED' };
1731 $confighash { $key }[ 1 ] = $cgiparams { 'NAME' };
1732 if ((! $cgiparams { 'KEY' }) && $cgiparams { 'AUTH' } ne 'psk' ) {
1733 $confighash { $key }[ 2 ] = $cgiparams { 'CERT_NAME' };
1735 $confighash { $key }[ 3 ] = $cgiparams { 'TYPE' };
1736 if ( $cgiparams { 'AUTH' } eq 'psk' ) {
1737 $confighash { $key }[ 4 ] = 'psk' ;
1738 $confighash { $key }[ 5 ] = $cgiparams { 'PSK' };
1740 $confighash { $key }[ 4 ] = 'cert' ;
1742 if ( $cgiparams { 'TYPE' } eq 'net' ) {
1743 $confighash { $key }[ 11 ] = $cgiparams { 'REMOTE_SUBNET' };
1745 $confighash { $key }[ 7 ] = $cgiparams { 'LOCAL_ID' };
1746 $confighash { $key }[ 8 ] = $cgiparams { 'LOCAL_SUBNET' };
1747 $confighash { $key }[ 9 ] = $cgiparams { 'REMOTE_ID' };
1748 $confighash { $key }[ 10 ] = $cgiparams { 'REMOTE' };
1749 $confighash { $key }[ 25 ] = $cgiparams { 'REMARK' };
1750 $confighash { $key }[ 26 ] = $cgiparams { 'INTERFACE' };
1751 $confighash { $key }[ 27 ] = $cgiparams { 'DPD_ACTION' };
1753 #dont forget advanced value
1754 $confighash { $key }[ 18 ] = $cgiparams { 'IKE_ENCRYPTION' };
1755 $confighash { $key }[ 19 ] = $cgiparams { 'IKE_INTEGRITY' };
1756 $confighash { $key }[ 20 ] = $cgiparams { 'IKE_GROUPTYPE' };
1757 $confighash { $key }[ 16 ] = $cgiparams { 'IKE_LIFETIME' };
1758 $confighash { $key }[ 21 ] = $cgiparams { 'ESP_ENCRYPTION' };
1759 $confighash { $key }[ 22 ] = $cgiparams { 'ESP_INTEGRITY' };
1760 $confighash { $key }[ 23 ] = $cgiparams { 'ESP_GROUPTYPE' };
1761 $confighash { $key }[ 17 ] = $cgiparams { 'ESP_KEYLIFE' };
1762 $confighash { $key }[ 12 ] = $cgiparams { 'AGGRMODE' };
1763 $confighash { $key }[ 13 ] = $cgiparams { 'COMPRESSION' };
1764 $confighash { $key }[ 24 ] = $cgiparams { 'ONLY_PROPOSED' };
1765 $confighash { $key }[ 28 ] = $cgiparams { 'PFS' };
1766 $confighash { $key }[ 14 ] = $cgiparams { 'VHOST' };
1768 #free unused fields!
1769 $confighash { $key }[ 6 ] = 'off' ;
1770 $confighash { $key }[ 15 ] = 'off' ;
1772 & General
:: writehasharray
( "${General::swroot}/vpn/config" , \
%confighash );
1775 system ( '/usr/local/bin/ipsecctrl' , 'S' , $key );
1778 if ( $cgiparams { 'EDIT_ADVANCED' } eq 'on' ) {
1779 $cgiparams { 'KEY' } = $key ;
1780 $cgiparams { 'ACTION' } = $Lang :: tr
{ 'advanced' };
1783 } else { # add new connection
1784 $cgiparams { 'ENABLED' } = 'on' ;
1785 if ( ! - f
"${General::swroot}/private/cakey.pem" ) {
1786 $cgiparams { 'AUTH' } = 'psk' ;
1787 } elsif ( ! - f
"${General::swroot}/ca/cacert.pem" ) {
1788 $cgiparams { 'AUTH' } = 'certfile' ;
1790 $cgiparams { 'AUTH' } = 'certgen' ;
1792 $cgiparams { 'LOCAL_SUBNET' } = " $netsettings {'GREEN_NETADDRESS'}/ $netsettings {'GREEN_NETMASK'}" ;
1793 $cgiparams { 'CERT_EMAIL' } = $vpnsettings { 'ROOTCERT_EMAIL' };
1794 $cgiparams { 'CERT_OU' } = $vpnsettings { 'ROOTCERT_OU' };
1795 $cgiparams { 'CERT_ORGANIZATION' } = $vpnsettings { 'ROOTCERT_ORGANIZATION' };
1796 $cgiparams { 'CERT_CITY' } = $vpnsettings { 'ROOTCERT_CITY' };
1797 $cgiparams { 'CERT_STATE' } = $vpnsettings { 'ROOTCERT_STATE' };
1798 $cgiparams { 'CERT_COUNTRY' } = $vpnsettings { 'ROOTCERT_COUNTRY' };
1800 # choose appropriate dpd action
1801 if ( $cgiparams { 'TYPE' } eq 'host' ) {
1802 $cgiparams { 'DPD_ACTION' } = 'clear' ;
1804 $cgiparams { 'DPD_ACTION' } = 'restart' ;
1807 # Default is yes for 'pfs'
1808 $cgiparams { 'PFS' } = 'on' ;
1811 $cgiparams { 'LOCAL_ID' } = '' ;
1812 $cgiparams { 'REMOTE_ID' } = '' ;
1814 #use default advanced value
1815 $cgiparams { 'IKE_ENCRYPTION' } = 'aes128|3des' ; #[18];
1816 $cgiparams { 'IKE_INTEGRITY' } = 'sha|md5' ; #[19];
1817 $cgiparams { 'IKE_GROUPTYPE' } = '1536|1024' ; #[20];
1818 $cgiparams { 'IKE_LIFETIME' } = '1' ; #[16];
1819 $cgiparams { 'ESP_ENCRYPTION' } = 'aes128|3des' ; #[21];
1820 $cgiparams { 'ESP_INTEGRITY' } = 'sha1|md5' ; #[22];
1821 $cgiparams { 'ESP_GROUPTYPE' } = '' ; #[23];
1822 $cgiparams { 'ESP_KEYLIFE' } = '8' ; #[17];
1823 $cgiparams { 'AGGRMODE' } = 'off' ; #[12];
1824 $cgiparams { 'COMPRESSION' } = 'off' ; #[13];
1825 $cgiparams { 'ONLY_PROPOSED' } = 'off' ; #[24];
1826 $cgiparams { 'PFS' } = 'on' ; #[28];
1827 $cgiparams { 'VHOST' } = 'on' ; #[14];
1831 $checked { 'ENABLED' }{ 'off' } = '' ;
1832 $checked { 'ENABLED' }{ 'on' } = '' ;
1833 $checked { 'ENABLED' }{ $cgiparams { 'ENABLED' }} = "checked='checked'" ;
1835 $checked { 'EDIT_ADVANCED' }{ 'off' } = '' ;
1836 $checked { 'EDIT_ADVANCED' }{ 'on' } = '' ;
1837 $checked { 'EDIT_ADVANCED' }{ $cgiparams { 'EDIT_ADVANCED' }} = "checked='checked'" ;
1839 $checked { 'AUTH' }{ 'psk' } = '' ;
1840 $checked { 'AUTH' }{ 'certreq' } = '' ;
1841 $checked { 'AUTH' }{ 'certgen' } = '' ;
1842 $checked { 'AUTH' }{ 'certfile' } = '' ;
1843 $checked { 'AUTH' }{ 'pkcs12' } = '' ;
1844 $checked { 'AUTH' }{ 'auth-dn' } = '' ;
1845 $checked { 'AUTH' }{ $cgiparams { 'AUTH' }} = "checked='checked'" ;
1847 $selected { 'INTERFACE' }{ 'RED' } = '' ;
1848 $selected { 'INTERFACE' }{ 'ORANGE' } = '' ;
1849 $selected { 'INTERFACE' }{ 'GREEN' } = '' ;
1850 $selected { 'INTERFACE' }{ 'BLUE' } = '' ;
1851 $selected { 'INTERFACE' }{ $cgiparams { 'INTERFACE' }} = "selected='selected'" ;
1853 $selected { 'DPD_ACTION' }{ 'clear' } = '' ;
1854 $selected { 'DPD_ACTION' }{ 'hold' } = '' ;
1855 $selected { 'DPD_ACTION' }{ 'restart' } = '' ;
1856 $selected { 'DPD_ACTION' }{ $cgiparams { 'DPD_ACTION' }} = "selected='selected'" ;
1858 & Header
:: showhttpheaders
();
1859 & Header
:: openpage
( $Lang :: tr
{ 'vpn configuration main' }, 1 , '' );
1860 & Header
:: openbigbox
( '100%' , 'left' , '' , $errormessage );
1861 if ( $errormessage ) {
1862 & Header
:: openbox
( '100%' , 'left' , $Lang :: tr
{ 'error messages' });
1863 print "<class name='base'> $errormessage " ;
1864 print " </class>" ;
1865 & Header
:: closebox
();
1869 & Header
:: openbox
( '100%' , 'left' , " $Lang ::tr{'warning messages'}:" );
1870 print "<class name='base'> $warnmessage " ;
1871 print " </class>" ;
1872 & Header
:: closebox
();
1875 print "<form method='post' enctype='multipart/form-data' action=' $ENV {'SCRIPT_NAME'}'>" ;
1877 <input type='hidden' name='TYPE' value=' $cgiparams {'TYPE'}' />
1878 <input type='hidden' name='IKE_ENCRYPTION' value=' $cgiparams {'IKE_ENCRYPTION'}' />
1879 <input type='hidden' name='IKE_INTEGRITY' value=' $cgiparams {'IKE_INTEGRITY'}' />
1880 <input type='hidden' name='IKE_GROUPTYPE' value=' $cgiparams {'IKE_GROUPTYPE'}' />
1881 <input type='hidden' name='IKE_LIFETIME' value=' $cgiparams {'IKE_LIFETIME'}' />
1882 <input type='hidden' name='ESP_ENCRYPTION' value=' $cgiparams {'ESP_ENCRYPTION'}' />
1883 <input type='hidden' name='ESP_INTEGRITY' value=' $cgiparams {'ESP_INTEGRITY'}' />
1884 <input type='hidden' name='ESP_GROUPTYPE' value=' $cgiparams {'ESP_GROUPTYPE'}' />
1885 <input type='hidden' name='ESP_KEYLIFE' value=' $cgiparams {'ESP_KEYLIFE'}' />
1886 <input type='hidden' name='AGGRMODE' value=' $cgiparams {'AGGRMODE'}' />
1887 <input type='hidden' name='COMPRESSION' value=' $cgiparams {'COMPRESSION'}' />
1888 <input type='hidden' name='ONLY_PROPOSED' value=' $cgiparams {'ONLY_PROPOSED'}' />
1889 <input type='hidden' name='PFS' value=' $cgiparams {'PFS'}' />
1890 <input type='hidden' name='VHOST' value=' $cgiparams {'VHOST'}' />
1893 if ( $cgiparams { 'KEY' }) {
1894 print "<input type='hidden' name='KEY' value=' $cgiparams {'KEY'}' />" ;
1895 print "<input type='hidden' name='AUTH' value=' $cgiparams {'AUTH'}' />" ;
1898 & Header
:: openbox
( '100%' , 'left' , " $Lang ::tr{'connection'}:" );
1899 print "<table width='100%'>" ;
1900 print "<tr><td width='25%' class='boldbase'> $Lang ::tr{'name'}:</td>" ;
1901 if ( $cgiparams { 'KEY' }) {
1902 print "<td width='25%' class='base'><input type='hidden' name='NAME' value=' $cgiparams {'NAME'}' /><b> $cgiparams {'NAME'}</b></td>" ;
1904 print "<td width='25%'><input type='text' name='NAME' value=' $cgiparams {'NAME'}' size='30' /></td>" ;
1906 print "<td> $Lang ::tr{'enabled'}</td><td><input type='checkbox' name='ENABLED' $checked{'ENABLED'}{'on'} /></td></tr>" ;
1907 print '</tr><td><br /></td><tr>' ;
1911 if ( $cgiparams { 'TYPE' } eq 'host' ) {
1912 $disabled = "disabled='disabled'" ;
1913 $blob = "<img src='/blob.gif' alt='*' />" ;
1916 print "<tr><td> $Lang ::tr{'host ip'}:</td>" ;
1917 print "<td><select name='INTERFACE'>" ;
1918 print "<option value='RED' $selected {'INTERFACE'}{'RED'}>RED ( $vpnsettings {'VPN_IP'})</option>" ;
1919 print "<option value='GREEN' $selected {'INTERFACE'}{'GREEN'}>GREEN ( $netsettings {'GREEN_ADDRESS'})</option>" ;
1920 print "<option value='BLUE' $selected {'INTERFACE'}{'BLUE'}>BLUE ( $netsettings {'BLUE_ADDRESS'})</option>" if ( $netsettings { 'BLUE_DEV' } ne '' );
1921 print "<option value='ORANGE' $selected {'INTERFACE'}{'ORANGE'}>ORANGE ( $netsettings {'ORANGE_ADDRESS'})</option>" if ( $netsettings { 'ORANGE_DEV' } ne '' );
1922 print "</select></td>" ;
1924 <td class='boldbase'> $Lang ::tr{'remote host/ip'}: $blob </td>
1925 <td><input type='text' name='REMOTE' value=' $cgiparams {'REMOTE'}' size='30' /></td>
1927 <td class='boldbase' nowrap='nowrap'> $Lang ::tr{'local subnet'}</td>
1928 <td><input type='text' name='LOCAL_SUBNET' value=' $cgiparams {'LOCAL_SUBNET'}' size='30' /></td>
1929 <td class='boldbase' nowrap='nowrap'> $Lang ::tr{'remote subnet'}</td>
1930 <td><input $disabled type='text' name='REMOTE_SUBNET' value=' $cgiparams {'REMOTE_SUBNET'}' size='30' /></td>
1932 <td class='boldbase'> $Lang ::tr{'vpn local id'}: <img src='/blob.gif' alt='*' />
1933 <br />( $Lang ::tr{'eg'} <tt>@xy.example.com</tt>)</td>
1934 <td><input type='text' name='LOCAL_ID' value=' $cgiparams {'LOCAL_ID'}' /></td>
1935 <td class='boldbase'> $Lang ::tr{'vpn remote id'}: <img src='/blob.gif' alt='*' /></td>
1936 <td><input type='text' name='REMOTE_ID' value=' $cgiparams {'REMOTE_ID'}' /></td>
1938 </tr><td><br /></td><tr>
1939 <td> $Lang ::tr{'dpd action'}:</td>
1940 <td><select name='DPD_ACTION'>
1941 <option value='clear' $selected {'DPD_ACTION'}{'clear'}>clear</option>
1942 <option value='hold' $selected {'DPD_ACTION'}{'hold'}>hold</option>
1943 <option value='restart' $selected {'DPD_ACTION'}{'restart'}>restart</option>
1944 </select> <a href='http://www.openswan.com/docs/local/README.DPD'>?</a>
1947 <!--http://www.openswan.com/docs/local/README.DPD
1948 http://bugs.xelerance.com/view.php?id=156
1949 restart = clear + reinitiate connection
1951 <td class='boldbase'> $Lang ::tr{'remark title'} <img src='/blob.gif' alt='*' /></td>
1952 <td colspan='3'><input type='text' name='REMARK' value=' $cgiparams {'REMARK'}' size='55' maxlength='50' /></td>
1956 if (! $cgiparams { 'KEY' }) {
1957 print "<tr><td colspan='3'><input type='checkbox' name='EDIT_ADVANCED' $checked {'EDIT_ADVANCED'}{'on'} /> $Lang ::tr{'edit advanced settings when done'}</td></tr>" ;
1960 & Header
:: closebox
();
1962 if ( $cgiparams { 'KEY' } && $cgiparams { 'AUTH' } eq 'psk' ) {
1963 & Header
:: openbox
( '100%' , 'left' , $Lang :: tr
{ 'authentication' });
1965 <table width='100%' cellpadding='0' cellspacing='5' border='0'>
1966 <tr><td class='base' width='50%'> $Lang ::tr{'use a pre-shared key'}</td>
1967 <td class='base' width='50%'><input type='text' name='PSK' size='30' value=' $cgiparams {'PSK'}' /></td>
1972 & Header
:: closebox
();
1973 } elsif (! $cgiparams { 'KEY' }) {
1974 my $pskdisabled = ( $vpnsettings { 'VPN_IP' } eq ' %defaultroute ' ) ?
"disabled='disabled'" : '' ;
1975 $cgiparams { 'PSK' } = $Lang :: tr
{ 'vpn incompatible use of defaultroute' } if ( $pskdisabled );
1976 my $cakeydisabled = ( ! - f
"${General::swroot}/private/cakey.pem" ) ?
"disabled='disabled'" : '' ;
1977 $cgiparams { 'CERT_NAME' } = $Lang :: tr
{ 'vpn no full pki' } if ( $cakeydisabled );
1978 my $cacrtdisabled = ( ! - f
"${General::swroot}/ca/cacert.pem" ) ?
"disabled='disabled'" : '' ;
1980 & Header
:: openbox
( '100%' , 'left' , $Lang :: tr
{ 'authentication' });
1982 <table width='100%' cellpadding='0' cellspacing='5' border='0'>
1983 <tr><td width='5%'><input type='radio' name='AUTH' value='psk' $checked {'AUTH'}{'psk'} $pskdisabled /></td>
1984 <td class='base' width='55%'> $Lang ::tr{'use a pre-shared key'}</td>
1985 <td class='base' width='40%'><input type='text' name='PSK' size='30' value=' $cgiparams {'PSK'}' $pskdisabled /></td></tr>
1986 <tr><td colspan='3' bgcolor='#000000'></td></tr>
1987 <tr><td><input type='radio' name='AUTH' value='certreq' $checked {'AUTH'}{'certreq'} $cakeydisabled /></td>
1988 <td class='base'><hr /> $Lang ::tr{'upload a certificate request'}</td>
1989 <td class='base' rowspan='3' valign='middle'><input type='file' name='FH' size='30' $cacrtdisabled /></td></tr>
1990 <tr><td><input type='radio' name='AUTH' value='certfile' $checked {'AUTH'}{'certfile'} $cacrtdisabled /></td>
1991 <td class='base'> $Lang ::tr{'upload a certificate'}</td></tr>
1992 <tr><td><input type='radio' name='AUTH' value='pkcs12' $cacrtdisabled /></td>
1993 <td class='base'> $Lang ::tr{'upload p12 file'} $Lang ::tr{'pkcs12 file password'}:<input type='password' name='P12_PASS'/></td></tr>
1994 <tr><td><input type='radio' name='AUTH' value='auth-dn' $checked {'AUTH'}{'auth-dn'} $cacrtdisabled /></td>
1995 <td class='base'><hr /> $Lang ::tr{'vpn auth-dn'}</td></tr>
1996 <tr><td colspan='3' bgcolor='#000000'></td></tr>
1997 <tr><td><input type='radio' name='AUTH' value='certgen' $checked {'AUTH'}{'certgen'} $cakeydisabled /></td>
1998 <td class='base'><hr /> $Lang ::tr{'generate a certificate'}</td><td> </td></tr>
2000 <td class='base'> $Lang ::tr{'users fullname or system hostname'}:</td>
2001 <td class='base' nowrap='nowrap'><input type='text' name='CERT_NAME' value=' $cgiparams {'CERT_NAME'}' size='32' $cakeydisabled /></td></tr>
2003 <td class='base'> $Lang ::tr{'users email'}: <img src='/blob.gif' alt='*' /></td>
2004 <td class='base' nowrap='nowrap'><input type='text' name='CERT_EMAIL' value=' $cgiparams {'CERT_EMAIL'}' size='32' $cakeydisabled /></td></tr>
2006 <td class='base'> $Lang ::tr{'users department'}: <img src='/blob.gif' alt='*' /></td>
2007 <td class='base' nowrap='nowrap'><input type='text' name='CERT_OU' value=' $cgiparams {'CERT_OU'}' size='32' $cakeydisabled /></td></tr>
2009 <td class='base'> $Lang ::tr{'organization name'}: <img src='/blob.gif' alt='*' /></td>
2010 <td class='base' nowrap='nowrap'><input type='text' name='CERT_ORGANIZATION' value=' $cgiparams {'CERT_ORGANIZATION'}' size='32' $cakeydisabled /></td></tr>
2012 <td class='base'> $Lang ::tr{'city'}: <img src='/blob.gif' alt='*' /></td>
2013 <td class='base' nowrap='nowrap'><input type='text' name='CERT_CITY' value=' $cgiparams {'CERT_CITY'}' size='32' $cakeydisabled /></td></tr>
2015 <td class='base'> $Lang ::tr{'state or province'}: <img src='/blob.gif' alt='*' /></td>
2016 <td class='base' nowrap='nowrap'><input type='text' name='CERT_STATE' value=' $cgiparams {'CERT_STATE'}' size='32' $cakeydisabled /></td></tr>
2018 <td class='base'> $Lang ::tr{'country'}:</td>
2019 <td class='base'><select name='CERT_COUNTRY' $cakeydisabled >
2022 foreach my $country ( sort keys %{ Countries
:: countries
}) {
2023 print " \t\t\t <option value=' $Countries ::countries{ $country }'" ;
2024 if ( $Countries :: countries
{ $country } eq $cgiparams { 'CERT_COUNTRY' } ) {
2025 print " selected='selected'" ;
2027 print "> $country </option> \n " ;
2032 <tr><td> </td><td class='base'> $Lang ::tr{'vpn subjectaltname'} (subjectAltName=email:*,URI:*,DNS:*,RID:*)<img src='/blob.gif' alt='*' /></td>
2033 <td class='base' nowrap='nowrap'><input type='text' name='SUBJECTALTNAME' value=' $cgiparams {'SUBJECTALTNAME'}' size='32' $cakeydisabled /></td></tr>
2035 <td class='base'> $Lang ::tr{'pkcs12 file password'}:</td>
2036 <td class='base' nowrap='nowrap'><input type='password' name='CERT_PASS1' value=' $cgiparams {'CERT_PASS1'}' size='32' $cakeydisabled /></td></tr>
2037 <tr><td> </td><td class='base'> $Lang ::tr{'pkcs12 file password'}:( $Lang ::tr{'confirmation'})</td>
2038 <td class='base' nowrap='nowrap'><input type='password' name='CERT_PASS2' value=' $cgiparams {'CERT_PASS2'}' size='32' $cakeydisabled /></td></tr>
2042 & Header
:: closebox
();
2045 print "<div align='center'><input type='submit' name='ACTION' value=' $Lang ::tr{'save'}' />" ;
2046 if ( $cgiparams { 'KEY' }) {
2047 print "<input type='submit' name='ACTION' value=' $Lang ::tr{'advanced'}' />" ;
2049 print "<input type='submit' name='ACTION' value=' $Lang ::tr{'cancel'}' /></div></form>" ;
2050 & Header
:: closebigbox
();
2051 & Header
:: closepage
();
2058 ### Advanced settings
2060 if (( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'advanced' }) ||
2061 ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'save' } && $cgiparams { 'ADVANCED' } eq 'yes' )) {
2062 & General
:: readhash
( "${General::swroot}/vpn/settings" , \
%vpnsettings );
2063 & General
:: readhasharray
( "${General::swroot}/vpn/config" , \
%confighash );
2064 if (! $confighash { $cgiparams { 'KEY' }}) {
2065 $errormessage = $Lang :: tr
{ 'invalid key' };
2069 if ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'save' }) {
2070 # I didn't read any incompatibilities here....
2071 #if ($cgiparams{'VHOST'} eq 'on' && $cgiparams{'COMPRESSION'} eq 'on') {
2072 # $errormessage = $Lang::tr{'cannot enable both nat traversal and compression'};
2073 # goto ADVANCED_ERROR;
2075 my @temp = split ( '\|' , $cgiparams { 'IKE_ENCRYPTION' });
2077 $errormessage = $Lang :: tr
{ 'invalid input' };
2078 goto ADVANCED_ERROR
;
2080 foreach my $val ( @temp ) {
2081 if ( $val !~ /^(aes256|aes128|3des|twofish256|twofish128|serpent256|serpent128|blowfish256|blowfish128|cast128)$/ ) {
2082 $errormessage = $Lang :: tr
{ 'invalid input' };
2083 goto ADVANCED_ERROR
;
2086 @temp = split ( '\|' , $cgiparams { 'IKE_INTEGRITY' });
2088 $errormessage = $Lang :: tr
{ 'invalid input' };
2089 goto ADVANCED_ERROR
;
2091 foreach my $val ( @temp ) {
2092 if ( $val !~ /^(sha2_512|sha2_256|sha|md5)$/ ) {
2093 $errormessage = $Lang :: tr
{ 'invalid input' };
2094 goto ADVANCED_ERROR
;
2097 @temp = split ( '\|' , $cgiparams { 'IKE_GROUPTYPE' });
2099 $errormessage = $Lang :: tr
{ 'invalid input' };
2100 goto ADVANCED_ERROR
;
2102 foreach my $val ( @temp ) {
2103 if ( $val !~ /^(768|1024|1536|2048|3072|4096|6144|8192)$/ ) {
2104 $errormessage = $Lang :: tr
{ 'invalid input' };
2105 goto ADVANCED_ERROR
;
2108 if ( $cgiparams { 'IKE_LIFETIME' } !~ /^\d+$/ ) {
2109 $errormessage = $Lang :: tr
{ 'invalid input for ike lifetime' };
2110 goto ADVANCED_ERROR
;
2112 if ( $cgiparams { 'IKE_LIFETIME' } < 1 || $cgiparams { 'IKE_LIFETIME' } > 8 ) {
2113 $errormessage = $Lang :: tr
{ 'ike lifetime should be between 1 and 8 hours' };
2114 goto ADVANCED_ERROR
;
2116 @temp = split ( '\|' , $cgiparams { 'ESP_ENCRYPTION' });
2118 $errormessage = $Lang :: tr
{ 'invalid input' };
2119 goto ADVANCED_ERROR
;
2121 foreach my $val ( @temp ) {
2122 if ( $val !~ /^(aes256|aes128|3des|twofish256|twofish128|serpent256|serpent128|blowfish256|blowfish128)$/ ) {
2123 $errormessage = $Lang :: tr
{ 'invalid input' };
2124 goto ADVANCED_ERROR
;
2127 @temp = split ( '\|' , $cgiparams { 'ESP_INTEGRITY' });
2129 $errormessage = $Lang :: tr
{ 'invalid input' };
2130 goto ADVANCED_ERROR
;
2132 foreach my $val ( @temp ) {
2133 if ( $val !~ /^(sha2_512|sha2_256|sha1|md5)$/ ) {
2134 $errormessage = $Lang :: tr
{ 'invalid input' };
2135 goto ADVANCED_ERROR
;
2138 if ( $cgiparams { 'ESP_GROUPTYPE' } ne '' &&
2139 $cgiparams { 'ESP_GROUPTYPE' } !~ /^modp(768|1024|1536|2048|3072|4096)$/ ) {
2140 $errormessage = $Lang :: tr
{ 'invalid input' };
2141 goto ADVANCED_ERROR
;
2144 if ( $cgiparams { 'ESP_KEYLIFE' } !~ /^\d+$/ ) {
2145 $errormessage = $Lang :: tr
{ 'invalid input for esp keylife' };
2146 goto ADVANCED_ERROR
;
2148 if ( $cgiparams { 'ESP_KEYLIFE' } < 1 || $cgiparams { 'ESP_KEYLIFE' } > 24 ) {
2149 $errormessage = $Lang :: tr
{ 'esp keylife should be between 1 and 24 hours' };
2150 goto ADVANCED_ERROR
;
2154 ( $cgiparams { 'AGGRMODE' } !~ /^(|on|off)$/ ) ||
2155 ( $cgiparams { 'COMPRESSION' } !~ /^(|on|off)$/ ) ||
2156 ( $cgiparams { 'ONLY_PROPOSED' } !~ /^(|on|off)$/ ) ||
2157 ( $cgiparams { 'PFS' } !~ /^(|on|off)$/ ) ||
2158 ( $cgiparams { 'VHOST' } !~ /^(|on|off)$/ )
2160 $errormessage = $Lang :: tr
{ 'invalid input' };
2161 goto ADVANCED_ERROR
;
2164 $confighash { $cgiparams { 'KEY' }}[ 18 ] = $cgiparams { 'IKE_ENCRYPTION' };
2165 $confighash { $cgiparams { 'KEY' }}[ 19 ] = $cgiparams { 'IKE_INTEGRITY' };
2166 $confighash { $cgiparams { 'KEY' }}[ 20 ] = $cgiparams { 'IKE_GROUPTYPE' };
2167 $confighash { $cgiparams { 'KEY' }}[ 16 ] = $cgiparams { 'IKE_LIFETIME' };
2168 $confighash { $cgiparams { 'KEY' }}[ 21 ] = $cgiparams { 'ESP_ENCRYPTION' };
2169 $confighash { $cgiparams { 'KEY' }}[ 22 ] = $cgiparams { 'ESP_INTEGRITY' };
2170 $confighash { $cgiparams { 'KEY' }}[ 23 ] = $cgiparams { 'ESP_GROUPTYPE' };
2171 $confighash { $cgiparams { 'KEY' }}[ 17 ] = $cgiparams { 'ESP_KEYLIFE' };
2172 $confighash { $cgiparams { 'KEY' }}[ 12 ] = $cgiparams { 'AGGRMODE' };
2173 $confighash { $cgiparams { 'KEY' }}[ 13 ] = $cgiparams { 'COMPRESSION' };
2174 $confighash { $cgiparams { 'KEY' }}[ 24 ] = $cgiparams { 'ONLY_PROPOSED' };
2175 $confighash { $cgiparams { 'KEY' }}[ 28 ] = $cgiparams { 'PFS' };
2176 $confighash { $cgiparams { 'KEY' }}[ 14 ] = $cgiparams { 'VHOST' };
2177 & General
:: writehasharray
( "${General::swroot}/vpn/config" , \
%confighash );
2180 system ( '/usr/local/bin/ipsecctrl' , 'S' , $cgiparams { 'KEY' });
2185 $cgiparams { 'IKE_ENCRYPTION' } = $confighash { $cgiparams { 'KEY' }}[ 18 ];
2186 $cgiparams { 'IKE_INTEGRITY' } = $confighash { $cgiparams { 'KEY' }}[ 19 ];
2187 $cgiparams { 'IKE_GROUPTYPE' } = $confighash { $cgiparams { 'KEY' }}[ 20 ];
2188 $cgiparams { 'IKE_LIFETIME' } = $confighash { $cgiparams { 'KEY' }}[ 16 ];
2189 $cgiparams { 'ESP_ENCRYPTION' } = $confighash { $cgiparams { 'KEY' }}[ 21 ];
2190 $cgiparams { 'ESP_INTEGRITY' } = $confighash { $cgiparams { 'KEY' }}[ 22 ];
2191 $cgiparams { 'ESP_GROUPTYPE' } = $confighash { $cgiparams { 'KEY' }}[ 23 ];
2192 $cgiparams { 'ESP_KEYLIFE' } = $confighash { $cgiparams { 'KEY' }}[ 17 ];
2193 $cgiparams { 'AGGRMODE' } = $confighash { $cgiparams { 'KEY' }}[ 12 ];
2194 $cgiparams { 'COMPRESSION' } = $confighash { $cgiparams { 'KEY' }}[ 13 ];
2195 $cgiparams { 'ONLY_PROPOSED' } = $confighash { $cgiparams { 'KEY' }}[ 24 ];
2196 $cgiparams { 'PFS' } = $confighash { $cgiparams { 'KEY' }}[ 28 ];
2197 $cgiparams { 'VHOST' } = $confighash { $cgiparams { 'KEY' }}[ 14 ];
2199 if ( $confighash { $cgiparams { 'KEY' }}[ 3 ] eq 'net' || $confighash { $cgiparams { 'KEY' }}[ 10 ]) {
2200 $cgiparams { 'VHOST' } = 'off' ;
2205 $checked { 'IKE_ENCRYPTION' }{ 'aes256' } = '' ;
2206 $checked { 'IKE_ENCRYPTION' }{ 'aes128' } = '' ;
2207 $checked { 'IKE_ENCRYPTION' }{ '3des' } = '' ;
2208 $checked { 'IKE_ENCRYPTION' }{ 'twofish256' } = '' ;
2209 $checked { 'IKE_ENCRYPTION' }{ 'twofish128' } = '' ;
2210 $checked { 'IKE_ENCRYPTION' }{ 'serpent256' } = '' ;
2211 $checked { 'IKE_ENCRYPTION' }{ 'serpent128' } = '' ;
2212 $checked { 'IKE_ENCRYPTION' }{ 'blowfish256' } = '' ;
2213 $checked { 'IKE_ENCRYPTION' }{ 'blowfish128' } = '' ;
2214 $checked { 'IKE_ENCRYPTION' }{ 'cast128' } = '' ;
2215 my @temp = split ( '\|' , $cgiparams { 'IKE_ENCRYPTION' });
2216 foreach my $key ( @temp ) { $checked { 'IKE_ENCRYPTION' }{ $key } = "selected='selected'" ; }
2217 $checked { 'IKE_INTEGRITY' }{ 'sha2_512' } = '' ;
2218 $checked { 'IKE_INTEGRITY' }{ 'sha2_256' } = '' ;
2219 $checked { 'IKE_INTEGRITY' }{ 'sha' } = '' ;
2220 $checked { 'IKE_INTEGRITY' }{ 'md5' } = '' ;
2221 @temp = split ( '\|' , $cgiparams { 'IKE_INTEGRITY' });
2222 foreach my $key ( @temp ) { $checked { 'IKE_INTEGRITY' }{ $key } = "selected='selected'" ; }
2223 $checked { 'IKE_GROUPTYPE' }{ '768' } = '' ;
2224 $checked { 'IKE_GROUPTYPE' }{ '1024' } = '' ;
2225 $checked { 'IKE_GROUPTYPE' }{ '1536' } = '' ;
2226 $checked { 'IKE_GROUPTYPE' }{ '2048' } = '' ;
2227 $checked { 'IKE_GROUPTYPE' }{ '3072' } = '' ;
2228 $checked { 'IKE_GROUPTYPE' }{ '4096' } = '' ;
2229 $checked { 'IKE_GROUPTYPE' }{ '6144' } = '' ;
2230 $checked { 'IKE_GROUPTYPE' }{ '8192' } = '' ;
2231 @temp = split ( '\|' , $cgiparams { 'IKE_GROUPTYPE' });
2232 foreach my $key ( @temp ) { $checked { 'IKE_GROUPTYPE' }{ $key } = "selected='selected'" ; }
2233 $checked { 'ESP_ENCRYPTION' }{ 'aes256' } = '' ;
2234 $checked { 'ESP_ENCRYPTION' }{ 'aes128' } = '' ;
2235 $checked { 'ESP_ENCRYPTION' }{ '3des' } = '' ;
2236 $checked { 'ESP_ENCRYPTION' }{ 'twofish256' } = '' ;
2237 $checked { 'ESP_ENCRYPTION' }{ 'twofish128' } = '' ;
2238 $checked { 'ESP_ENCRYPTION' }{ 'serpent256' } = '' ;
2239 $checked { 'ESP_ENCRYPTION' }{ 'serpent128' } = '' ;
2240 $checked { 'ESP_ENCRYPTION' }{ 'blowfish256' } = '' ;
2241 $checked { 'ESP_ENCRYPTION' }{ 'blowfish128' } = '' ;
2242 @temp = split ( '\|' , $cgiparams { 'ESP_ENCRYPTION' });
2243 foreach my $key ( @temp ) { $checked { 'ESP_ENCRYPTION' }{ $key } = "selected='selected'" ; }
2244 $checked { 'ESP_INTEGRITY' }{ 'sha2_512' } = '' ;
2245 $checked { 'ESP_INTEGRITY' }{ 'sha2_256' } = '' ;
2246 $checked { 'ESP_INTEGRITY' }{ 'sha1' } = '' ;
2247 $checked { 'ESP_INTEGRITY' }{ 'md5' } = '' ;
2248 @temp = split ( '\|' , $cgiparams { 'ESP_INTEGRITY' });
2249 foreach my $key ( @temp ) { $checked { 'ESP_INTEGRITY' }{ $key } = "selected='selected'" ; }
2250 $checked { 'ESP_GROUPTYPE' }{ 'modp768' } = '' ;
2251 $checked { 'ESP_GROUPTYPE' }{ 'modp1024' } = '' ;
2252 $checked { 'ESP_GROUPTYPE' }{ 'modp1536' } = '' ;
2253 $checked { 'ESP_GROUPTYPE' }{ 'modp2048' } = '' ;
2254 $checked { 'ESP_GROUPTYPE' }{ 'modp3072' } = '' ;
2255 $checked { 'ESP_GROUPTYPE' }{ 'modp4096' } = '' ;
2256 $checked { 'ESP_GROUPTYPE' }{ $cgiparams { 'ESP_GROUPTYPE' }} = "selected='selected'" ;
2258 $checked { 'AGGRMODE' } = $cgiparams { 'AGGRMODE' } eq 'on' ?
"checked='checked'" : '' ;
2259 $checked { 'COMPRESSION' } = $cgiparams { 'COMPRESSION' } eq 'on' ?
"checked='checked'" : '' ;
2260 $checked { 'ONLY_PROPOSED' } = $cgiparams { 'ONLY_PROPOSED' } eq 'on' ?
"checked='checked'" : '' ;
2261 $checked { 'PFS' } = $cgiparams { 'PFS' } eq 'on' ?
"checked='checked'" : '' ;
2262 $checked { 'VHOST' } = $cgiparams { 'VHOST' } eq 'on' ?
"checked='checked'" : '' ;
2264 & Header
:: showhttpheaders
();
2265 & Header
:: openpage
( $Lang :: tr
{ 'vpn configuration main' }, 1 , '' );
2266 & Header
:: openbigbox
( '100%' , 'left' , '' , $errormessage );
2268 if ( $errormessage ) {
2269 & Header
:: openbox
( '100%' , 'left' , $Lang :: tr
{ 'error messages' });
2270 print "<class name='base'> $errormessage " ;
2271 print " </class>" ;
2272 & Header
:: closebox
();
2276 & Header
:: openbox
( '100%' , 'left' , $Lang :: tr
{ 'warning messages' });
2277 print "<class name='base'> $warnmessage " ;
2278 print " </class>" ;
2279 & Header
:: closebox
();
2282 & Header
:: openbox
( '100%' , 'left' , " $Lang ::tr{'advanced'}:" );
2284 <form method='post' enctype='multipart/form-data' action=' $ENV {'SCRIPT_NAME'}'>
2285 <input type='hidden' name='ADVANCED' value='yes' />
2286 <input type='hidden' name='KEY' value=' $cgiparams {'KEY'}' />
2288 <table width='100%'>
2289 <tr><td class='boldbase' align='right' valign='top'> $Lang ::tr{'ike encryption'}</td><td class='boldbase' valign='top'>
2290 <select name='IKE_ENCRYPTION' multiple='multiple' size='4'>
2291 <option value='aes256' $checked {'IKE_ENCRYPTION'}{'aes256'}>AES (256 bit)</option>
2292 <option value='aes128' $checked {'IKE_ENCRYPTION'}{'aes128'}>AES (128 bit)</option>
2293 <option value='3des' $checked {'IKE_ENCRYPTION'}{'3des'}>3DES</option>
2294 <option value='twofish256' $checked {'IKE_ENCRYPTION'}{'twofish256'}>Twofish (256 bit)</option>
2295 <option value='twofish128' $checked {'IKE_ENCRYPTION'}{'twofish128'}>Twofish (128 bit)</option>
2296 <option value='serpent256' $checked {'IKE_ENCRYPTION'}{'serpent256'}>Serpent (256 bit)</option>
2297 <option value='serpent128' $checked {'IKE_ENCRYPTION'}{'serpent128'}>Serpent (128 bit)</option>
2298 <option value='blowfish256' $checked {'IKE_ENCRYPTION'}{'blowfish256'}>Blowfish (256 bit)</option>
2299 <option value='blowfish128' $checked {'IKE_ENCRYPTION'}{'blowfish128'}>Blowfish (128 bit)</option>
2300 <option value='cast128' $checked {'IKE_ENCRYPTION'}{'cast128'}>Cast (128 bit)</option>
2303 <td class='boldbase' align='right' valign='top'> $Lang ::tr{'ike integrity'}</td><td class='boldbase' valign='top'>
2304 <select name='IKE_INTEGRITY' multiple='multiple' size='4'>
2305 <option value='sha2_512' $checked {'IKE_INTEGRITY'}{'sha2_512'}>SHA2 (512)</option>
2306 <option value='sha2_256' $checked {'IKE_INTEGRITY'}{'sha2_256'}>SHA2 (256)</option>
2307 <option value='sha' $checked {'IKE_INTEGRITY'}{'sha'}>SHA</option>
2308 <option value='md5' $checked {'IKE_INTEGRITY'}{'md5'}>MD5</option>
2311 <td class='boldbase' align='right' valign='top'> $Lang ::tr{'ike grouptype'}</td><td class='boldbase' valign='top'>
2312 <select name='IKE_GROUPTYPE' multiple='multiple' size='4'>
2313 <option value='8192' $checked {'IKE_GROUPTYPE'}{'8192'}>MODP-8192</option>
2314 <option value='6144' $checked {'IKE_GROUPTYPE'}{'6144'}>MODP-6144</option>
2315 <option value='4096' $checked {'IKE_GROUPTYPE'}{'4096'}>MODP-4096</option>
2316 <option value='3072' $checked {'IKE_GROUPTYPE'}{'3072'}>MODP-3072</option>
2317 <option value='2048' $checked {'IKE_GROUPTYPE'}{'2048'}>MODP-2048</option>
2318 <option value='1536' $checked {'IKE_GROUPTYPE'}{'1536'}>MODP-1536</option>
2319 <option value='1024' $checked {'IKE_GROUPTYPE'}{'1024'}>MODP-1024</option>
2320 <option value='768' $checked {'IKE_GROUPTYPE'}{'768'}>MODP-768</option>
2323 <td class='boldbase' align='right' valign='top'> $Lang ::tr{'ike lifetime'}</td><td class='boldbase' valign='top'>
2324 <input type='text' name='IKE_LIFETIME' value=' $cgiparams {'IKE_LIFETIME'}' size='5' /> $Lang ::tr{'hours'}</td>
2327 <td colspan='1'><hr /></td>
2329 <td class='boldbase' align='right' valign='top'> $Lang ::tr{'esp encryption'}</td><td class='boldbase' valign='top'>
2330 <select name='ESP_ENCRYPTION' multiple='multiple' size='4'>
2331 <option value='aes256' $checked {'ESP_ENCRYPTION'}{'aes256'}>AES (256 bit)</option>
2332 <option value='aes128' $checked {'ESP_ENCRYPTION'}{'aes128'}>AES (128 bit)</option>
2333 <option value='3des' $checked {'ESP_ENCRYPTION'}{'3des'}>3DES</option>
2334 <option value='twofish256' $checked {'ESP_ENCRYPTION'}{'twofish256'}>Twofish (256 bit)</option>
2335 <option value='twofish128' $checked {'ESP_ENCRYPTION'}{'twofish128'}>Twofish (128 bit)</option>
2336 <option value='serpent256' $checked {'ESP_ENCRYPTION'}{'serpent256'}>Serpent (256 bit)</option>
2337 <option value='serpent128' $checked {'ESP_ENCRYPTION'}{'serpent128'}>Serpent (128 bit)</option>
2338 <option value='blowfish256' $checked {'ESP_ENCRYPTION'}{'blowfish256'}>Blowfish (256 bit)</option>
2339 <option value='blowfish128' $checked {'ESP_ENCRYPTION'}{'blowfish128'}>Blowfish (128 bit)</option></select></td>
2341 <td class='boldbase' align='right' valign='top'> $Lang ::tr{'esp integrity'}</td><td class='boldbase' valign='top'>
2342 <select name='ESP_INTEGRITY' multiple='multiple' size='4'>
2343 <option value='sha2_512' $checked {'ESP_INTEGRITY'}{'sha2_512'}>SHA2 (512)</option>
2344 <option value='sha2_256' $checked {'ESP_INTEGRITY'}{'sha2_256'}>SHA2 (256)</option>
2345 <option value='sha1' $checked {'ESP_INTEGRITY'}{'sha1'}>SHA1</option>
2346 <option value='md5' $checked {'ESP_INTEGRITY'}{'md5'}>MD5</option></select></td>
2348 <td class='boldbase' align='right' valign='top'> $Lang ::tr{'esp grouptype'}</td><td class='boldbase' valign='top'>
2349 <select name='ESP_GROUPTYPE'>
2350 <option value=''> $Lang ::tr{'phase1 group'}</option>
2351 <option value='modp4096' $checked {'ESP_GROUPTYPE'}{'modp4096'}>MODP-4096</option>
2352 <option value='modp3072' $checked {'ESP_GROUPTYPE'}{'modp3072'}>MODP-3072</option>
2353 <option value='modp2048' $checked {'ESP_GROUPTYPE'}{'modp2048'}>MODP-2048</option>
2354 <option value='modp1536' $checked {'ESP_GROUPTYPE'}{'modp1536'}>MODP-1536</option>
2355 <option value='modp1024' $checked {'ESP_GROUPTYPE'}{'modp1024'}>MODP-1024</option>
2356 <option value='modp768' $checked {'ESP_GROUPTYPE'}{'modp768'}>MODP-768</option></select></td>
2358 <td class='boldbase' align='right' valign='top'> $Lang ::tr{'esp keylife'}</td><td class='boldbase' valign='top'>
2359 <input type='text' name='ESP_KEYLIFE' value=' $cgiparams {'ESP_KEYLIFE'}' size='5' /> $Lang ::tr{'hours'}</td>
2361 <td colspan='1'><hr /></td>
2363 <td colspan='5'><input type='checkbox' name='ONLY_PROPOSED' $checked {'ONLY_PROPOSED'} />
2364 IKE+ESP: $Lang ::tr{'use only proposed settings'}</td>
2366 <td colspan='5'><input type='checkbox' name='AGGRMODE' $checked {'AGGRMODE'} />
2367 $Lang ::tr{'vpn aggrmode'}</td>
2369 <td colspan='5'><input type='checkbox' name='PFS' $checked {'PFS'} />
2370 $Lang ::tr{'pfs yes no'}</td>
2371 <td align='right'><input type='submit' name='ACTION' value=' $Lang ::tr{'save'}' /></td>
2373 <td colspan='5'><input type='checkbox' name='COMPRESSION' $checked {'COMPRESSION'} />
2374 $Lang ::tr{'vpn payload compression'}</td>
2375 <td align='right'><input type='submit' name='ACTION' value=' $Lang ::tr{'cancel'}' /></td>
2379 if ( $confighash { $cgiparams { 'KEY' }}[ 3 ] eq 'net' ) {
2380 print "<tr><td><input type='hidden' name='VHOST' value='off' /></td></tr>" ;
2381 } elsif ( $confighash { $cgiparams { 'KEY' }}[ 10 ]) {
2382 print "<tr><td colspan='5'><input type='checkbox' name='VHOST' $checked {'VHOST'} disabled='disabled' />" ;
2383 print " $Lang ::tr{'vpn vhost'}</td></tr>" ;
2385 print "<tr><td colspan='5'><input type='checkbox' name='VHOST' $checked {'VHOST'} />" ;
2386 print " $Lang ::tr{'vpn vhost'}</td></tr>" ;
2389 print "</table></form>" ;
2390 & Header
:: closebox
();
2391 & Header
:: closebigbox
();
2392 & Header
:: closepage
();
2399 ### Default status page
2404 & General
:: readhash
( "${General::swroot}/vpn/settings" , \
%cgiparams );
2405 & General
:: readhasharray
( "${General::swroot}/vpn/caconfig" , \
%cahash );
2406 & General
:: readhasharray
( "${General::swroot}/vpn/config" , \
%confighash );
2407 $cgiparams { 'CA_NAME' } = '' ;
2409 my @status = `/usr/sbin/ipsec auto --status` ;
2411 # suggest a default name for this side
2412 if ( $cgiparams { 'VPN_IP' } eq '' && - e
"${General::swroot}/red/active" ) {
2413 if ( open ( IPADDR
, "${General::swroot}/red/local-ipaddress" )) {
2414 my $ipaddr = < IPADDR
>;
2417 $cgiparams { 'VPN_IP' } = ( gethostbyaddr ( pack ( "C4" , split ( /\./ , $ipaddr )), 2 ))[ 0 ];
2418 if ( $cgiparams { 'VPN_IP' } eq '' ) {
2419 $cgiparams { 'VPN_IP' } = $ipaddr ;
2423 # no IP found, use %defaultroute
2424 $cgiparams { 'VPN_IP' } = ' %defaultroute ' if ( $cgiparams { 'VPN_IP' } eq '' );
2426 $cgiparams { 'VPN_DELAYED_START' } = 0 if (! defined ( $cgiparams { 'VPN_DELAYED_START' }));
2427 $checked { 'VPN_WATCH' } = $cgiparams { 'VPN_WATCH' } eq 'on' ?
"checked='checked'" : '' ;
2428 map ( $checked { $_ } = $cgiparams { $_ } eq 'on' ?
"checked='checked'" : '' ,
2429 ( 'ENABLED' , 'DBG_CRYPT' , 'DBG_PARSING' , 'DBG_EMITTING' , 'DBG_CONTROL' ,
2430 'DBG_KLIPS' , 'DBG_DNS' , 'DBG_NAT_T' ));
2433 & Header
:: showhttpheaders
();
2434 & Header
:: openpage
( $Lang :: tr
{ 'vpn configuration main' }, 1 , '' );
2435 & Header
:: openbigbox
( '100%' , 'left' , '' , $errormessage );
2437 if ( $errormessage ) {
2438 & Header
:: openbox
( '100%' , 'left' , $Lang :: tr
{ 'error messages' });
2439 print "<class name='base'> $errormessage \n " ;
2440 print " </class> \n " ;
2441 & Header
:: closebox
();
2444 & Header
:: openbox
( '100%' , 'left' , $Lang :: tr
{ 'global settings' });
2446 <form method='post' action=' $ENV {'SCRIPT_NAME'}'>
2447 <table width='100%'>
2449 <td width='20%' class='base' nowrap='nowrap'> $Lang ::tr{'vpn red name'}:</td>
2450 <td width='20%'><input type='text' name='VPN_IP' value=' $cgiparams {'VPN_IP'}' /></td>
2451 <td width='20%' class='base'> $Lang ::tr{'enabled'}<input type='checkbox' name='ENABLED' $checked {'ENABLED'} /></td>
2457 <td class='base' nowrap='nowrap'> $Lang ::tr{'override mtu'}: <img src='/blob.gif' alt='*' /></td>
2458 <td ><input type='text' name='VPN_OVERRIDE_MTU' value=' $cgiparams {'VPN_OVERRIDE_MTU'}' /></td>
2464 <td class='base' nowrap='nowrap'> $Lang ::tr{'vpn delayed start'}: <img src='/blob.gif' alt='*' /><img src='/blob.gif' alt='*' /></td>
2465 <td ><input type='text' name='VPN_DELAYED_START' value=' $cgiparams {'VPN_DELAYED_START'}' /></td>
2468 <p> $Lang ::tr{'vpn watch'}:<input type='checkbox' name='VPN_WATCH' $checked {'VPN_WATCH'} /></p>
2469 <p>PLUTO DEBUG =
2470 crypt:<input type='checkbox' name='DBG_CRYPT' $checked {'DBG_CRYPT'} />,
2471 parsing:<input type='checkbox' name='DBG_PARSING' $checked {'DBG_PARSING'} />,
2472 emitting:<input type='checkbox' name='DBG_EMITTING' $checked {'DBG_EMITTING'} />,
2473 control:<input type='checkbox' name='DBG_CONTROL' $checked {'DBG_CONTROL'} />,
2474 klips:<input type='checkbox' name='DBG_KLIPS' $checked {'DBG_KLIPS'} />,
2475 dns:<input type='checkbox' name='DBG_DNS' $checked {'DBG_DNS'} />,
2476 nat_t:<input type='checkbox' name='DBG_NAT_T' $checked {'DBG_NAT_T'} /></p>
2479 <table width='100%'>
2481 <td class='base' valign='top'><img src='/blob.gif' alt='*' /></td>
2482 <td width='70%' class='base' valign='top'> $Lang ::tr{'this field may be blank'}</td>
2485 <td class='base' valign='top' nowrap='nowrap'><img src='/blob.gif' alt='*' /><img src='/blob.gif' alt='*' /> </td>
2486 <td class='base'> <font class='base'> $Lang ::tr{'vpn delayed start help'}</font></td>
2487 <td width='30%' align='center' class='base'><input type='submit' name='ACTION' value=' $Lang ::tr{'save'}' /></td>
2493 & Header
:: closebox
();
2495 & Header
:: openbox
( '100%' , 'left' , $Lang :: tr
{ 'connection status and controlc' });
2497 <table width='100%' border='0' cellspacing='1' cellpadding='0'>
2499 <td width='10%' class='boldbase' align='center'><b> $Lang ::tr{'name'}</b></td>
2500 <td width='22%' class='boldbase' align='center'><b> $Lang ::tr{'type'}</b></td>
2501 <td width='23%' class='boldbase' align='center'><b> $Lang ::tr{'common name'}</b></td>
2502 <td width='30%' class='boldbase' align='center'><b> $Lang ::tr{'remark'}</b></td>
2503 <td width='10%' class='boldbase' align='center'><b> $Lang ::tr{'status'}</b></td>
2504 <td class='boldbase' align='center' colspan='6'><b> $Lang ::tr{'action'}</b></td>
2510 foreach my $key ( keys %confighash ) {
2511 if ( $confighash { $key }[ 0 ] eq 'on' ) { $gif = 'on.gif' ; } else { $gif = 'off.gif' ; }
2514 print "<tr bgcolor=' $color {'color20'}'> \n " ;
2516 print "<tr bgcolor=' $color {'color22'}'> \n " ;
2518 print "<td align='center' nowrap='nowrap'> $confighash { $key }[1]</td>" ;
2519 print "<td align='center' nowrap='nowrap'>" . $Lang :: tr
{ " $confighash { $key }[3]" } . " (" . $Lang :: tr
{ " $confighash { $key }[4]" } . ")</td>" ;
2520 if ( $confighash { $key }[ 2 ] eq ' %auth -dn' ) {
2521 print "<td align='left' nowrap='nowrap'> $confighash { $key }[9]</td>" ;
2522 } elsif ( $confighash { $key }[ 4 ] eq 'cert' ) {
2523 print "<td align='left' nowrap='nowrap'> $confighash { $key }[2]</td>" ;
2525 print "<td align='left'> </td>" ;
2527 print "<td align='center'> $confighash { $key }[25]</td>" ;
2529 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>" ;
2530 foreach my $line ( @status ) {
2531 if ( $line =~ /\"$confighash{$key}[1]\".*IPsec SA established/ ) {
2532 $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>" ;
2535 # move to blueif really down
2536 if ( $confighash { $key }[ 0 ] eq 'off' && $active =~ /${Header::colourred}/ ) {
2537 $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>" ;
2540 <td align='center'> $active </td>
2542 <form method='post' action=' $ENV {'SCRIPT_NAME'}'>
2543 <input type='image' name=' $Lang ::tr{'restart'}' src='/images/reload.gif' alt=' $Lang ::tr{'restart'}' title=' $Lang ::tr{'restart'}' />
2544 <input type='hidden' name='ACTION' value=' $Lang ::tr{'restart'}' />
2545 <input type='hidden' name='KEY' value=' $key ' />
2550 if (( $confighash { $key }[ 4 ] eq 'cert' ) && ( $confighash { $key }[ 2 ] ne ' %auth -dn' )) {
2553 <form method='post' action=' $ENV {'SCRIPT_NAME'}'>
2554 <input type='image' name=' $Lang ::tr{'show certificate'}' src='/images/info.gif' alt=' $Lang ::tr{'show certificate'}' title=' $Lang ::tr{'show certificate'}' />
2555 <input type='hidden' name='ACTION' value=' $Lang ::tr{'show certificate'}' />
2556 <input type='hidden' name='KEY' value=' $key ' />
2561 print "<td width='2%'> </td>" ;
2563 if ( $confighash { $key }[ 4 ] eq 'cert' && - f
"${General::swroot}/certs/ $confighash { $key }[1].p12" ) {
2566 <form method='post' action=' $ENV {'SCRIPT_NAME'}'>
2567 <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'}' />
2568 <input type='hidden' name='ACTION' value=' $Lang ::tr{'download pkcs12 file'}' />
2569 <input type='hidden' name='KEY' value=' $key ' />
2573 ; } elsif (( $confighash { $key }[ 4 ] eq 'cert' ) && ( $confighash { $key }[ 2 ] ne ' %auth -dn' )) {
2576 <form method='post' action=' $ENV {'SCRIPT_NAME'}'>
2577 <input type='image' name=' $Lang ::tr{'download certificate'}' src='/images/floppy.gif' alt=' $Lang ::tr{'download certificate'}' title=' $Lang ::tr{'download certificate'}' />
2578 <input type='hidden' name='ACTION' value=' $Lang ::tr{'download certificate'}' />
2579 <input type='hidden' name='KEY' value=' $key ' />
2584 print "<td width='2%'> </td>" ;
2588 <form method='post' action=' $ENV {'SCRIPT_NAME'}'>
2589 <input type='image' name=' $Lang ::tr{'toggle enable disable'}' src='/images/ $gif ' alt=' $Lang ::tr{'toggle enable disable'}' title=' $Lang ::tr{'toggle enable disable'}' />
2590 <input type='hidden' name='ACTION' value=' $Lang ::tr{'toggle enable disable'}' />
2591 <input type='hidden' name='KEY' value=' $key ' />
2596 <form method='post' action=' $ENV {'SCRIPT_NAME'}'>
2597 <input type='hidden' name='ACTION' value=' $Lang ::tr{'edit'}' />
2598 <input type='image' name=' $Lang ::tr{'edit'}' src='/images/edit.gif' alt=' $Lang ::tr{'edit'}' title=' $Lang ::tr{'edit'}' />
2599 <input type='hidden' name='KEY' value=' $key ' />
2602 <td align='center' >
2603 <form method='post' action=' $ENV {'SCRIPT_NAME'}'>
2604 <input type='hidden' name='ACTION' value=' $Lang ::tr{'remove'}' />
2605 <input type='image' name=' $Lang ::tr{'remove'}' src='/images/delete.gif' alt=' $Lang ::tr{'remove'}' title=' $Lang ::tr{'remove'}' />
2606 <input type='hidden' name='KEY' value=' $key ' />
2616 # If the config file contains entries, print Key to action icons
2621 <td class='boldbase'> <b> $Lang ::tr{'legend'}:</b></td>
2622 <td> <img src='/images/on.gif' alt=' $Lang ::tr{'click to disable'}' /></td>
2623 <td class='base'> $Lang ::tr{'click to disable'}</td>
2624 <td> <img src='/images/info.gif' alt=' $Lang ::tr{'show certificate'}' /></td>
2625 <td class='base'> $Lang ::tr{'show certificate'}</td>
2626 <td> <img src='/images/edit.gif' alt=' $Lang ::tr{'edit'}' /></td>
2627 <td class='base'> $Lang ::tr{'edit'}</td>
2628 <td> <img src='/images/delete.gif' alt=' $Lang ::tr{'remove'}' /></td>
2629 <td class='base'> $Lang ::tr{'remove'}</td>
2633 <td> <img src='/images/off.gif' alt='?OFF' /></td>
2634 <td class='base'> $Lang ::tr{'click to enable'}</td>
2635 <td> <img src='/images/floppy.gif' alt='?FLOPPY' /></td>
2636 <td class='base'> $Lang ::tr{'download certificate'}</td>
2637 <td> <img src='/images/reload.gif' alt='?RELOAD'/></td>
2638 <td class='base'> $Lang ::tr{'restart'}</td>
2646 <table width='100%'>
2647 <tr><td align='center' colspan='9'>
2648 <form method='post' action=' $ENV {'SCRIPT_NAME'}'>
2649 <input type='submit' name='ACTION' value=' $Lang ::tr{'add'}' />
2655 & Header
:: closebox
();
2657 & Header
:: openbox
( '100%' , 'left' , " $Lang ::tr{'certificate authorities'}:" );
2659 <table width='100%' border='0' cellspacing='1' cellpadding='0'>
2661 <td width='25%' class='boldbase' align='center'><b> $Lang ::tr{'name'}</b></td>
2662 <td width='65%' class='boldbase' align='center'><b> $Lang ::tr{'subject'}</b></td>
2663 <td width='10%' class='boldbase' colspan='3' align='center'><b> $Lang ::tr{'action'}</b></td>
2667 if (- f
"${General::swroot}/ca/cacert.pem" ) {
2668 my $casubject = & Header
:: cleanhtml
( getsubjectfromcert
( "${General::swroot}/ca/cacert.pem" ));
2671 <tr bgcolor=' $color {'color22'}'>
2672 <td class='base'> $Lang ::tr{'root certificate'}</td>
2673 <td class='base'> $casubject </td>
2674 <td width='3%' align='center'>
2675 <form method='post' action=' $ENV {'SCRIPT_NAME'}'>
2676 <input type='hidden' name='ACTION' value=' $Lang ::tr{'show root certificate'}' />
2677 <input type='image' name=' $Lang ::tr{'edit'}' src='/images/info.gif' alt=' $Lang ::tr{'show root certificate'}' title=' $Lang ::tr{'show root certificate'}' />
2680 <td width='3%' align='center'>
2681 <form method='post' action=' $ENV {'SCRIPT_NAME'}'>
2682 <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'}' />
2683 <input type='hidden' name='ACTION' value=' $Lang ::tr{'download root certificate'}' />
2686 <td width='4%'> </td></tr>
2690 # display rootcert generation buttons
2692 <tr bgcolor=' $color {'color22'}'>
2693 <td class='base'> $Lang ::tr{'root certificate'}:</td>
2694 <td class='base'> $Lang ::tr{'not present'}</td>
2695 <td colspan='3'> </td></tr>
2700 if (- f
"${General::swroot}/certs/hostcert.pem" ) {
2701 my $hostsubject = & Header
:: cleanhtml
( getsubjectfromcert
( "${General::swroot}/certs/hostcert.pem" ));
2704 <tr bgcolor=' $color {'color20'}'>
2705 <td class='base'> $Lang ::tr{'host certificate'}</td>
2706 <td class='base'> $hostsubject </td>
2707 <td width='3%' align='center'>
2708 <form method='post' action=' $ENV {'SCRIPT_NAME'}'>
2709 <input type='hidden' name='ACTION' value=' $Lang ::tr{'show host certificate'}' />
2710 <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'}' />
2713 <td width='3%' align='center'>
2714 <form method='post' action=' $ENV {'SCRIPT_NAME'}'>
2715 <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'}' />
2716 <input type='hidden' name='ACTION' value=' $Lang ::tr{'download host certificate'}' />
2719 <td width='4%'> </td></tr>
2725 <tr bgcolor=' $color {'color20'}'>
2726 <td width='25%' class='base'> $Lang ::tr{'host certificate'}:</td>
2727 <td class='base'> $Lang ::tr{'not present'}</td>
2728 <td colspan='3'> </td></tr>
2734 if ( keys %cahash > 0 ) {
2735 foreach my $key ( keys %cahash ) {
2736 if ( $rowcolor ++ % 2 ) {
2737 print "<tr bgcolor=' $color {'color20'}'> \n " ;
2739 print "<tr bgcolor=' $color {'color22'}'> \n " ;
2741 print "<td class='base'> $cahash { $key }[0]</td> \n " ;
2742 print "<td class='base'> $cahash { $key }[1]</td> \n " ;
2745 <form method='post' name='cafrm${key}a' action=' $ENV {'SCRIPT_NAME'}'>
2746 <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'}' />
2747 <input type='hidden' name='ACTION' value=' $Lang ::tr{'show ca certificate'}' />
2748 <input type='hidden' name='KEY' value=' $key ' />
2752 <form method='post' name='cafrm${key}b' action=' $ENV {'SCRIPT_NAME'}'>
2753 <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'}' />
2754 <input type='hidden' name='ACTION' value=' $Lang ::tr{'download ca certificate'}' />
2755 <input type='hidden' name='KEY' value=' $key ' />
2759 <form method='post' name='cafrm${key}c' action=' $ENV {'SCRIPT_NAME'}'>
2760 <input type='hidden' name='ACTION' value=' $Lang ::tr{'remove ca certificate'}' />
2761 <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'}' />
2762 <input type='hidden' name='KEY' value=' $key ' />
2772 # If the file contains entries, print Key to action icons
2773 if ( - f
"${General::swroot}/ca/cacert.pem" ) {
2776 <td class='boldbase'> <b> $Lang ::tr{'legend'}:</b></td>
2777 <td> <img src='/images/info.gif' alt=' $Lang ::tr{'show certificate'}' /></td>
2778 <td class='base'> $Lang ::tr{'show certificate'}</td>
2779 <td> <img src='/images/floppy.gif' alt=' $Lang ::tr{'download certificate'}' /></td>
2780 <td class='base'> $Lang ::tr{'download certificate'}</td>
2785 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>" ;
2788 <form method='post' enctype='multipart/form-data' action=' $ENV {'SCRIPT_NAME'}'>
2789 <table width='100%' border='0' cellspacing='1' cellpadding='0'>
2792 <td class='base' nowrap='nowrap'> $Lang ::tr{'ca name'}:</td>
2793 <td nowrap='nowrap'><input type='text' name='CA_NAME' value=' $cgiparams {'CA_NAME'}' size='15' /> </td>
2794 <td nowrap='nowrap'><input type='file' name='FH' size='30' /></td>
2795 <td nowrap='nowrap'><input type='submit' name='ACTION' value=' $Lang ::tr{'upload ca certificate'}' /></td>
2798 <td colspan='3'> $Lang ::tr{'resetting the vpn configuration will remove the root ca, the host certificate and all certificate based connections'}:</td>
2799 <td><input type='submit' name='ACTION' value=' $Lang ::tr{'remove x509'}' /></td>
2805 & Header
:: closebox
();
2806 & Header
:: closebigbox
();
2807 & Header
:: closepage
();