]>
git.ipfire.org Git - ipfire-2.x.git/blob - html/cgi-bin/vpnmain.cgi
2 ###############################################################################
4 # IPFire.org - A linux based firewall #
5 # Copyright (C) 2007-2013 IPFire Team info@ipfire.org #
7 # This program is free software: you can redistribute it and/or modify #
8 # it under the terms of the GNU General Public License as published by #
9 # the Free Software Foundation, either version 3 of the License, or #
10 # (at your option) any later version. #
12 # This program is distributed in the hope that it will be useful, #
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of #
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
15 # GNU General Public License for more details. #
17 # You should have received a copy of the GNU General Public License #
18 # along with this program. If not, see <http://www.gnu.org/licenses/>. #
20 ###############################################################################
24 use File
:: Temp qw
/ tempfile tempdir / ;
27 # enable only the following on debugging purpose
29 #use CGI::Carp 'fatalsToBrowser';
31 require '/var/ipfire/general-functions.pl' ;
32 require "${General::swroot}/lang.pl" ;
33 require "${General::swroot}/header.pl" ;
34 require "${General::swroot}/countries.pl" ;
36 #workaround to suppress a warning when a variable is used only once
37 my @dummy = ( ${ Header
:: colourgreen
}, ${ Header
:: colourblue
} );
41 ### Initialize variables
43 my $sleepDelay = 4 ; # after a call to ipsecctrl S or R, wait this delay (seconds) before reading status (let the ipsec do its job)
52 my $errormessage = '' ;
55 my %mainsettings = ();
56 & General
:: readhash
( "${General::swroot}/main/settings" , \
%mainsettings );
57 & General
:: readhash
( "/srv/web/ipfire/html/themes/" . $mainsettings { 'THEME' }. "/include/colors.txt" , \
%color );
59 & General
:: readhash
( "${General::swroot}/ethernet/settings" , \
%netsettings );
61 my %INACTIVITY_TIMEOUTS = (
62 300 => $Lang :: tr
{ 'five minutes' },
63 600 => $Lang :: tr
{ 'ten minutes' },
64 900 => $Lang :: tr
{ 'fifteen minutes' },
65 1800 => $Lang :: tr
{ 'thirty minutes' },
66 3600 => $Lang :: tr
{ 'one hour' },
67 43200 => $Lang :: tr
{ 'twelve hours' },
68 86400 => $Lang :: tr
{ '24 hours' },
69 0 => "- $Lang ::tr{'unlimited'} -" ,
74 $cgiparams { 'ENABLED' } = 'off' ;
75 $cgiparams { 'EDIT_ADVANCED' } = 'off' ;
76 $cgiparams { 'ACTION' } = '' ;
77 $cgiparams { 'CA_NAME' } = '' ;
78 $cgiparams { 'KEY' } = '' ;
79 $cgiparams { 'TYPE' } = '' ;
80 $cgiparams { 'ADVANCED' } = '' ;
81 $cgiparams { 'NAME' } = '' ;
82 $cgiparams { 'LOCAL_SUBNET' } = '' ;
83 $cgiparams { 'REMOTE_SUBNET' } = '' ;
84 $cgiparams { 'REMOTE' } = '' ;
85 $cgiparams { 'LOCAL_ID' } = '' ;
86 $cgiparams { 'REMOTE_ID' } = '' ;
87 $cgiparams { 'REMARK' } = '' ;
88 $cgiparams { 'PSK' } = '' ;
89 $cgiparams { 'CERT_NAME' } = '' ;
90 $cgiparams { 'CERT_EMAIL' } = '' ;
91 $cgiparams { 'CERT_OU' } = '' ;
92 $cgiparams { 'CERT_ORGANIZATION' } = '' ;
93 $cgiparams { 'CERT_CITY' } = '' ;
94 $cgiparams { 'CERT_STATE' } = '' ;
95 $cgiparams { 'CERT_COUNTRY' } = '' ;
96 $cgiparams { 'SUBJECTALTNAME' } = '' ;
97 $cgiparams { 'CERT_PASS1' } = '' ;
98 $cgiparams { 'CERT_PASS2' } = '' ;
99 $cgiparams { 'ROOTCERT_HOSTNAME' } = '' ;
100 $cgiparams { 'ROOTCERT_COUNTRY' } = '' ;
101 $cgiparams { 'P12_PASS' } = '' ;
102 $cgiparams { 'ROOTCERT_ORGANIZATION' } = '' ;
103 $cgiparams { 'ROOTCERT_HOSTNAME' } = '' ;
104 $cgiparams { 'ROOTCERT_EMAIL' } = '' ;
105 $cgiparams { 'ROOTCERT_OU' } = '' ;
106 $cgiparams { 'ROOTCERT_CITY' } = '' ;
107 $cgiparams { 'ROOTCERT_STATE' } = '' ;
108 $cgiparams { 'RW_NET' } = '' ;
109 $cgiparams { 'DPD_DELAY' } = '30' ;
110 $cgiparams { 'DPD_TIMEOUT' } = '120' ;
111 $cgiparams { 'FORCE_MOBIKE' } = 'off' ;
112 $cgiparams { 'START_ACTION' } = 'route' ;
113 $cgiparams { 'INACTIVITY_TIMEOUT' } = 1800 ;
114 $cgiparams { 'MODE' } = "tunnel" ;
115 $cgiparams { 'INTERFACE_MODE' } = "" ;
116 $cgiparams { 'INTERFACE_ADDRESS' } = "" ;
117 $cgiparams { 'INTERFACE_MTU' } = 1500 ;
118 & Header
:: getcgihash
( \
%cgiparams , { 'wantfile' => 1 , 'filevar' => 'FH' });
124 my $hostname = $_ [ 0 ];
125 unless ( $hostname ) { return "No hostname" };
126 my $res = new Net
:: DNS
:: Resolver
;
127 my $query = $res -> search ( " $hostname " );
129 foreach my $rr ( $query -> answer ) {
130 ## Potential bug - we are only looking at A records:
131 return 0 if $rr -> type eq "A" ;
134 return $res -> errorstring ;
138 ### Just return true is one interface is vpn enabled
141 return ( $vpnsettings { 'ENABLED' } eq 'on' );
144 ### old version: maintain serial number to one, without explication.
145 ### this: let the counter go, so that each cert is numbered.
147 sub cleanssldatabase
{
148 if ( open ( FILE
, ">${General::swroot}/certs/serial" )) {
152 if ( open ( FILE
, ">${General::swroot}/certs/index.txt" )) {
156 if ( open ( FILE
, ">${General::swroot}/certs/index.txt.attr" )) {
160 unlink ( "${General::swroot}/certs/index.txt.old" );
161 unlink ( "${General::swroot}/certs/index.txt.attr.old" );
162 unlink ( "${General::swroot}/certs/serial.old" );
163 unlink ( "${General::swroot}/certs/01.pem" );
165 sub newcleanssldatabase
{
166 if (! - s
"${General::swroot}/certs/serial" ) {
167 open ( FILE
, ">${General::swroot}/certs/serial" );
171 if (! - s
">${General::swroot}/certs/index.txt" ) {
172 system ( "touch ${General::swroot}/certs/index.txt" );
174 if (! - s
">${General::swroot}/certs/index.txt.attr" ) {
175 system ( "touch ${General::swroot}/certs/index.txt.attr" );
177 unlink ( "${General::swroot}/certs/index.txt.old" );
178 unlink ( "${General::swroot}/certs/index.txt.attr.old" );
179 unlink ( "${General::swroot}/certs/serial.old" );
180 # unlink ("${General::swroot}/certs/01.pem"); numbering evolves. Wrong place to delete
184 ### Call openssl and return errormessage if any
188 my $retssl = `/usr/bin/openssl $opt 2>&1` ; #redirect stderr
190 foreach my $line ( split ( /\n/ , $retssl )) {
191 & General
:: log ( "ipsec" , " $line " ) if ( 0 ); # 1 for verbose logging
192 $ret .= '<br>' . $line if ( $line =~ /error|unknown/ );
195 $ret = & Header
:: cleanhtml
( $ret );
197 return $ret ?
" $Lang ::tr{'openssl produced an error'}: $ret " : '' ;
200 ### Obtain a CN from given cert
202 sub getCNfromcert
($) {
203 #&General::log("ipsec", "Extracting name from $_[0]...");
204 my $temp = `/usr/bin/openssl x509 -text -in $_ [0]` ;
205 $temp =~ /Subject:.*CN = (.*)[\n]/ ;
207 $temp =~ s
+/ Email
+, E
+;
208 $temp =~ s/ ST = / S = / ;
214 ### Obtain Subject from given cert
216 sub getsubjectfromcert
($) {
217 #&General::log("ipsec", "Extracting subject from $_[0]...");
218 my $temp = `/usr/bin/openssl x509 -text -in $_ [0]` ;
219 $temp =~ /Subject: (.*)[\n]/ ;
221 $temp =~ s
+/ Email
+, E
+;
222 $temp =~ s/ ST = / S = / ;
226 ### Combine local subnet and connection name to make a unique name for each connection section
227 ### (this sub is not used now)
229 sub makeconnname
($) {
233 $subnet =~ /^(.*?)\/ (.* ?
)$/; # $1=IP $2=mask
234 my $ip = unpack ( 'N' , & Socket
:: inet_aton
( $1 ));
235 if ( length ( $2 ) > 2 ) {
236 my $mm = unpack ( 'N' , & Socket
:: inet_aton
( $2 ));
237 while ( ( $mm & 1 )== 0 ) {
244 return sprintf ( " %s - %X " , $conn , $ip );
247 ### Write a config file.
249 ###Type=Host : GUI can choose the interface used (RED,GREEN,BLUE) and
250 ### the side is always defined as 'left'.
253 sub writeipsecfiles
{
254 my %lconfighash = ();
255 my %lvpnsettings = ();
256 & General
:: readhasharray
( "${General::swroot}/vpn/config" , \
%lconfighash );
257 & General
:: readhash
( "${General::swroot}/vpn/settings" , \
%lvpnsettings );
259 open ( CONF
, ">${General::swroot}/vpn/ipsec.conf" ) or die "Unable to open ${General::swroot}/vpn/ipsec.conf: $!" ;
260 open ( SECRETS
, ">${General::swroot}/vpn/ipsec.secrets" ) or die "Unable to open ${General::swroot}/vpn/ipsec.secrets: $!" ;
263 print CONF
"version 2 \n\n " ;
264 print CONF
"conn %default \n " ;
265 print CONF
" \t keyingtries= %forever \n " ;
268 # Add user includes to config file
269 if (- e
"/etc/ipsec.user.conf" ) {
270 print CONF
"include /etc/ipsec.user.conf \n " ;
274 print SECRETS
"include /etc/ipsec.user.secrets \n " ;
276 if (- f
"${General::swroot}/certs/hostkey.pem" ) {
277 print SECRETS
": RSA ${General::swroot}/certs/hostkey.pem \n "
279 my $last_secrets = '' ; # old the less specifics connections
281 foreach my $key ( keys %lconfighash ) {
282 next if ( $lconfighash { $key }[ 0 ] ne 'on' );
284 #remote peer is not set? => use '%any'
285 $lconfighash { $key }[ 10 ] = ' %any ' if ( $lconfighash { $key }[ 10 ] eq '' );
288 if ( $lconfighash { $key }[ 26 ] eq 'BLUE' ) {
289 $localside = $netsettings { 'BLUE_ADDRESS' };
290 } elsif ( $lconfighash { $key }[ 26 ] eq 'GREEN' ) {
291 $localside = $netsettings { 'GREEN_ADDRESS' };
292 } elsif ( $lconfighash { $key }[ 26 ] eq 'ORANGE' ) {
293 $localside = $netsettings { 'ORANGE_ADDRESS' };
295 $localside = $lvpnsettings { 'VPN_IP' };
298 print CONF
"conn $lconfighash { $key }[1] \n " ;
299 print CONF
" \t left= $localside \n " ;
300 print CONF
" \t leftsubnet=" . & make_subnets
( $lconfighash { $key }[ 8 ]) . " \n " ;
301 print CONF
" \t leftfirewall=yes \n " ;
302 print CONF
" \t lefthostaccess=yes \n " ;
303 print CONF
" \t right= $lconfighash { $key }[10] \n " ;
305 if ( $lconfighash { $key }[ 3 ] eq 'net' ) {
306 print CONF
" \t rightsubnet=" . & make_subnets
( $lconfighash { $key }[ 11 ]) . " \n " ;
309 # Local Cert and Remote Cert (unless auth is DN dn-auth)
310 if ( $lconfighash { $key }[ 4 ] eq 'cert' ) {
311 print CONF
" \t leftcert=${General::swroot}/certs/hostcert.pem \n " ;
312 print CONF
" \t rightcert=${General::swroot}/certs/ $lconfighash { $key }[1]cert.pem \n " if ( $lconfighash { $key }[ 2 ] ne ' %auth -dn' );
315 # Local and Remote IDs
316 print CONF
" \t leftid= \" $lconfighash { $key }[7] \"\n " if ( $lconfighash { $key }[ 7 ]);
317 print CONF
" \t rightid= \" $lconfighash { $key }[9] \"\n " if ( $lconfighash { $key }[ 9 ]);
320 if ( $lconfighash { $key }[ 35 ] eq "transport" ) {
321 print CONF
" \t type=transport \n " ;
323 print CONF
" \t type=tunnel \n " ;
327 my $pfs = $lconfighash { $key }[ 28 ] eq 'on' ?
'on' : 'off' ;
330 if ( $lconfighash { $key }[ 18 ] && $lconfighash { $key }[ 19 ] && $lconfighash { $key }[ 20 ]) {
331 my @encs = split ( '\|' , $lconfighash { $key }[ 18 ]);
332 my @ints = split ( '\|' , $lconfighash { $key }[ 19 ]);
333 my @groups = split ( '\|' , $lconfighash { $key }[ 20 ]);
335 my @algos = & make_algos
( "ike" , \
@encs , \
@ints , \
@groups , 1 );
336 print CONF
" \t ike=" . join ( "," , @algos );
338 if ( $lconfighash { $key }[ 24 ] eq 'on' ) { #only proposed algorythms?
345 if ( $lconfighash { $key }[ 21 ] && $lconfighash { $key }[ 22 ]) {
346 my @encs = split ( '\|' , $lconfighash { $key }[ 21 ]);
347 my @ints = split ( '\|' , $lconfighash { $key }[ 22 ]);
348 my @groups = split ( '\|' , $lconfighash { $key }[ 23 ]);
350 # Use IKE grouptype if no ESP group type has been selected
351 # (for backwards compatibility)
352 if ( $lconfighash { $key }[ 23 ] eq "" ) {
353 @groups = split ( '\|' , $lconfighash { $key }[ 20 ]);
356 my @algos = & make_algos
( "esp" , \
@encs , \
@ints , \
@groups , ( $pfs eq "on" ));
357 print CONF
" \t esp=" . join ( "," , @algos );
359 if ( $lconfighash { $key }[ 24 ] eq 'on' ) { #only proposed algorythms?
367 if (! $lconfighash { $key }[ 29 ]) {
368 $lconfighash { $key }[ 29 ] = "ikev1" ;
371 print CONF
" \t keyexchange= $lconfighash { $key }[29] \n " ;
374 print CONF
" \t ikelifetime= $lconfighash { $key }[16]h \n " if ( $lconfighash { $key }[ 16 ]);
375 print CONF
" \t keylife= $lconfighash { $key }[17]h \n " if ( $lconfighash { $key }[ 17 ]);
378 print CONF
" \t compress=yes \n " if ( $lconfighash { $key }[ 13 ] eq 'on' );
381 if (( $lconfighash { $key }[ 29 ] eq "ikev2" ) && ( $lconfighash { $key }[ 32 ] eq 'on' )) {
382 print CONF
" \t mobike=yes \n " ;
385 # Dead Peer Detection
386 my $dpdaction = $lconfighash { $key }[ 27 ];
387 print CONF
" \t dpdaction= $dpdaction \n " ;
389 # If the dead peer detection is disabled and IKEv2 is used,
390 # dpddelay must be set to zero, too.
391 if ( $dpdaction eq "none" ) {
392 if ( $lconfighash { $key }[ 29 ] eq "ikev2" ) {
393 print CONF
" \t dpddelay=0 \n " ;
396 my $dpddelay = $lconfighash { $key }[ 31 ];
400 print CONF
" \t dpddelay= $dpddelay \n " ;
401 my $dpdtimeout = $lconfighash { $key }[ 30 ];
405 print CONF
" \t dpdtimeout= $dpdtimeout \n " ;
408 # Build Authentication details: LEFTid RIGHTid : PSK psk
410 if ( $lconfighash { $key }[ 4 ] eq 'psk' ) {
411 $psk_line = ( $lconfighash { $key }[ 7 ] ?
$lconfighash { $key }[ 7 ] : $localside ) . " " ;
412 $psk_line .= $lconfighash { $key }[ 9 ] ?
$lconfighash { $key }[ 9 ] : $lconfighash { $key }[ 10 ]; #remoteid or remote address?
413 $psk_line .= " : PSK ' $lconfighash { $key }[5]' \n " ;
414 # if the line contains %any, it is less specific than two IP or ID, so move it at end of file.
415 if ( $psk_line =~ /%any/ ) {
416 $last_secrets .= $psk_line ;
418 print SECRETS
$psk_line ;
420 print CONF
" \t authby=secret \n " ;
422 print CONF
" \t authby=rsasig \n " ;
423 print CONF
" \t leftrsasigkey= %cert \n " ;
424 print CONF
" \t rightrsasigkey= %cert \n " ;
427 my $start_action = $lconfighash { $key }[ 33 ];
428 if (! $start_action ) {
429 $start_action = "start" ;
432 my $inactivity_timeout = $lconfighash { $key }[ 34 ];
433 if ( $inactivity_timeout eq "" ) {
434 $inactivity_timeout = 900 ;
437 # Automatically start only if a net-to-net connection
438 if ( $lconfighash { $key }[ 3 ] eq 'host' ) {
439 print CONF
" \t auto=add \n " ;
440 print CONF
" \t rightsourceip= $lvpnsettings {'RW_NET'} \n " ;
442 print CONF
" \t auto= $start_action \n " ;
444 # If in on-demand mode, we terminate the tunnel
445 # after 15 min of no traffic
446 if ( $start_action eq 'route' && $inactivity_timeout > 0 ) {
447 print CONF
" \t inactivity= $inactivity_timeout \n " ;
452 print CONF
" \t fragmentation=yes \n " ;
457 # Add post user includes to config file
458 # After the GUI-connections allows to patch connections.
459 if (- e
"/etc/ipsec.user-post.conf" ) {
460 print CONF
"include /etc/ipsec.user-post.conf \n " ;
464 print SECRETS
$last_secrets if ( $last_secrets );
469 # Hook to regenerate the configuration files.
470 if ( $ENV { "REMOTE_ADDR" } eq "" ) {
476 ### Save main settings
478 if ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'save' } && $cgiparams { 'TYPE' } eq '' && $cgiparams { 'KEY' } eq '' ) {
479 & General
:: readhash
( "${General::swroot}/vpn/settings" , \
%vpnsettings );
481 unless (& General
:: validfqdn
( $cgiparams { 'VPN_IP' }) || & General
:: validip
( $cgiparams { 'VPN_IP' })
482 || $cgiparams { 'VPN_IP' } eq ' %defaultroute ' ) {
483 $errormessage = $Lang :: tr
{ 'invalid input for hostname' };
487 unless ( $cgiparams { 'VPN_DELAYED_START' } =~ /^[0-9]{1,3}$/ ) { #allow 0-999 seconds !
488 $errormessage = $Lang :: tr
{ 'invalid time period' };
492 if ( $cgiparams { 'RW_NET' } ne '' and !& General
:: validipandmask
( $cgiparams { 'RW_NET' }) ) {
493 $errormessage = $Lang :: tr
{ 'urlfilter invalid ip or mask error' };
497 $vpnsettings { 'ENABLED' } = $cgiparams { 'ENABLED' };
498 $vpnsettings { 'VPN_IP' } = $cgiparams { 'VPN_IP' };
499 $vpnsettings { 'VPN_DELAYED_START' } = $cgiparams { 'VPN_DELAYED_START' };
500 $vpnsettings { 'RW_NET' } = $cgiparams { 'RW_NET' };
501 & General
:: writehash
( "${General::swroot}/vpn/settings" , \
%vpnsettings );
504 system ( '/usr/local/bin/ipsecctrl' , 'S' );
506 system ( '/usr/local/bin/ipsecctrl' , 'D' );
513 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'remove x509' } && $cgiparams { 'AREUSURE' } eq 'yes' ) {
514 & General
:: readhasharray
( "${General::swroot}/vpn/config" , \
%confighash );
516 foreach my $key ( keys %confighash ) {
517 if ( $confighash { $key }[ 4 ] eq 'cert' ) {
518 delete $confighash { $key };
521 while ( my $file = glob ( "${General::swroot}/{ca,certs,crls,private}/*" )) {
525 if ( open ( FILE
, ">${General::swroot}/vpn/caconfig" )) {
529 & General
:: writehasharray
( "${General::swroot}/vpn/config" , \
%confighash );
531 system ( '/usr/local/bin/ipsecctrl' , 'R' );
537 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'remove x509' }) {
538 & Header
:: showhttpheaders
();
539 & Header
:: openpage
( $Lang :: tr
{ 'ipsec' }, 1 , '' );
540 & Header
:: openbigbox
( '100%' , 'left' , '' , '' );
541 & Header
:: openbox
( '100%' , 'left' , $Lang :: tr
{ 'are you sure' });
543 <form method='post' action=' $ENV {'SCRIPT_NAME'}'>
547 <input type='hidden' name='AREUSURE' value='yes' />
548 <b><font color='${Header::colourred}'> $Lang ::tr{'capswarning'}</font></b>: $Lang ::tr{'resetting the vpn configuration will remove the root ca, the host certificate and all certificate based connections'}
552 <input type='submit' name='ACTION' value=' $Lang ::tr{'remove x509'}' />
553 <input type='submit' name='ACTION' value=' $Lang ::tr{'cancel'}' /></td>
560 & Header
:: closebigbox
();
561 & Header
:: closepage
();
565 ### Upload CA Certificate
567 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'upload ca certificate' }) {
568 & General
:: readhasharray
( "${General::swroot}/vpn/caconfig" , \
%cahash );
570 if ( $cgiparams { 'CA_NAME' } !~ /^[a-zA-Z0-9]+$/ ) {
571 $errormessage = $Lang :: tr
{ 'name must only contain characters' };
575 if ( length ( $cgiparams { 'CA_NAME' }) > 60 ) {
576 $errormessage = $Lang :: tr
{ 'name too long' };
580 if ( $cgiparams { 'CA_NAME' } eq 'ca' ) {
581 $errormessage = $Lang :: tr
{ 'name is invalid' };
582 goto UPLOAD_CA_ERROR
;
585 # Check if there is no other entry with this name
586 foreach my $key ( keys %cahash ) {
587 if ( $cahash { $key }[ 0 ] eq $cgiparams { 'CA_NAME' }) {
588 $errormessage = $Lang :: tr
{ 'a ca certificate with this name already exists' };
593 if ( ref ( $cgiparams { 'FH' }) ne 'Fh' ) {
594 $errormessage = $Lang :: tr
{ 'there was no file upload' };
597 # Move uploaded ca to a temporary file
598 ( my $fh , my $filename ) = tempfile
( );
599 if ( copy
( $cgiparams { 'FH' }, $fh ) != 1 ) {
603 my $temp = `/usr/bin/openssl x509 -text -in $filename ` ;
604 if ( $temp !~ /CA:TRUE/i ) {
605 $errormessage = $Lang :: tr
{ 'not a valid ca certificate' };
609 move
( $filename , "${General::swroot}/ca/ $cgiparams {'CA_NAME'}cert.pem" );
611 $errormessage = " $Lang ::tr{'certificate file move failed'}: $!" ;
617 my $key = & General
:: findhasharraykey
( \
%cahash );
618 $cahash { $key }[ 0 ] = $cgiparams { 'CA_NAME' };
619 $cahash { $key }[ 1 ] = & Header
:: cleanhtml
( getsubjectfromcert
( "${General::swroot}/ca/ $cgiparams {'CA_NAME'}cert.pem" ));
620 & General
:: writehasharray
( "${General::swroot}/vpn/caconfig" , \
%cahash );
622 system ( '/usr/local/bin/ipsecctrl' , 'R' );
628 ### Display ca certificate
630 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'show ca certificate' }) {
631 & General
:: readhasharray
( "${General::swroot}/vpn/caconfig" , \
%cahash );
633 if ( - f
"${General::swroot}/ca/ $cahash { $cgiparams {'KEY'}}[0]cert.pem" ) {
634 & Header
:: showhttpheaders
();
635 & Header
:: openpage
( $Lang :: tr
{ 'ipsec' }, 1 , '' );
636 & Header
:: openbigbox
( '100%' , 'left' , '' , '' );
637 & Header
:: openbox
( '100%' , 'left' , " $Lang ::tr{'ca certificate'}:" );
638 my $output = `/usr/bin/openssl x509 -text -in ${General::swroot}/ca/ $cahash { $cgiparams {'KEY'}}[0]cert.pem` ;
639 $output = & Header
:: cleanhtml
( $output , "y" );
640 print "<pre> $output </pre> \n " ;
642 print "<div align='center'><a href='/cgi-bin/vpnmain.cgi'> $Lang ::tr{'back'}</a></div>" ;
643 & Header
:: closebigbox
();
644 & Header
:: closepage
();
647 $errormessage = $Lang :: tr
{ 'invalid key' };
651 ### Export ca certificate to browser
653 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'download ca certificate' }) {
654 & General
:: readhasharray
( "${General::swroot}/vpn/caconfig" , \
%cahash );
656 if ( - f
"${General::swroot}/ca/ $cahash { $cgiparams {'KEY'}}[0]cert.pem" ) {
657 print "Content-Type: application/force-download \n " ;
658 print "Content-Type: application/octet-stream \r\n " ;
659 print "Content-Disposition: attachment; filename= $cahash { $cgiparams {'KEY'}}[0]cert.pem \r\n\r\n " ;
660 print `/usr/bin/openssl x509 -in ${General::swroot}/ca/ $cahash { $cgiparams {'KEY'}}[0]cert.pem` ;
663 $errormessage = $Lang :: tr
{ 'invalid key' };
667 ### Remove ca certificate (step 2)
669 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'remove ca certificate' } && $cgiparams { 'AREUSURE' } eq 'yes' ) {
670 & General
:: readhasharray
( "${General::swroot}/vpn/config" , \
%confighash );
671 & General
:: readhasharray
( "${General::swroot}/vpn/caconfig" , \
%cahash );
673 if ( - f
"${General::swroot}/ca/ $cahash { $cgiparams {'KEY'}}[0]cert.pem" ) {
674 foreach my $key ( keys %confighash ) {
675 my $test = `/usr/bin/openssl verify -CAfile ${General::swroot}/ca/ $cahash { $cgiparams {'KEY'}}[0]cert.pem ${General::swroot}/certs/ $confighash { $key }[1]cert.pem` ;
676 if ( $test =~ /: OK/ ) {
678 system ( '/usr/local/bin/ipsecctrl' , 'D' , $key ) if (& vpnenabled
);
679 unlink ( "${General::swroot}/certs/ $confighash { $key }[1]cert.pem" );
680 unlink ( "${General::swroot}/certs/ $confighash { $key }[1].p12" );
681 delete $confighash { $key };
682 & General
:: writehasharray
( "${General::swroot}/vpn/config" , \
%confighash );
686 unlink ( "${General::swroot}/ca/ $cahash { $cgiparams {'KEY'}}[0]cert.pem" );
687 delete $cahash { $cgiparams { 'KEY' }};
688 & General
:: writehasharray
( "${General::swroot}/vpn/caconfig" , \
%cahash );
689 system ( '/usr/local/bin/ipsecctrl' , 'R' );
692 $errormessage = $Lang :: tr
{ 'invalid key' };
695 ### Remove ca certificate (step 1)
697 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'remove ca certificate' }) {
698 & General
:: readhasharray
( "${General::swroot}/vpn/config" , \
%confighash );
699 & General
:: readhasharray
( "${General::swroot}/vpn/caconfig" , \
%cahash );
701 my $assignedcerts = 0 ;
702 if ( - f
"${General::swroot}/ca/ $cahash { $cgiparams {'KEY'}}[0]cert.pem" ) {
703 foreach my $key ( keys %confighash ) {
704 my $test = `/usr/bin/openssl verify -CAfile ${General::swroot}/ca/ $cahash { $cgiparams {'KEY'}}[0]cert.pem ${General::swroot}/certs/ $confighash { $key }[1]cert.pem` ;
705 if ( $test =~ /: OK/ ) {
709 if ( $assignedcerts ) {
710 & Header
:: showhttpheaders
();
711 & Header
:: openpage
( $Lang :: tr
{ 'ipsec' }, 1 , '' );
712 & Header
:: openbigbox
( '100%' , 'left' , '' , '' );
713 & Header
:: openbox
( '100%' , 'left' , $Lang :: tr
{ 'are you sure' });
715 <form method='post' action=' $ENV {'SCRIPT_NAME'}'>
719 <input type='hidden' name='KEY' value=' $cgiparams {'KEY'}' />
720 <input type='hidden' name='AREUSURE' value='yes' /></td>
723 <b><font color='${Header::colourred}'> $Lang ::tr{'capswarning'}</font></b> $Lang ::tr{'connections are associated with this ca. deleting the ca will delete these connections as well.'}</td>
726 <input type='submit' name='ACTION' value=' $Lang ::tr{'remove ca certificate'}' />
727 <input type='submit' name='ACTION' value=' $Lang ::tr{'cancel'}' /></td>
734 & Header
:: closebigbox
();
735 & Header
:: closepage
();
738 unlink ( "${General::swroot}/ca/ $cahash { $cgiparams {'KEY'}}[0]cert.pem" );
739 delete $cahash { $cgiparams { 'KEY' }};
740 & General
:: writehasharray
( "${General::swroot}/vpn/caconfig" , \
%cahash );
741 system ( '/usr/local/bin/ipsecctrl' , 'R' );
745 $errormessage = $Lang :: tr
{ 'invalid key' };
749 ### Display root certificate
751 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'show root certificate' } ||
752 $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'show host certificate' }) {
754 & Header
:: showhttpheaders
();
755 & Header
:: openpage
( $Lang :: tr
{ 'ipsec' }, 1 , '' );
756 & Header
:: openbigbox
( '100%' , 'left' , '' , '' );
757 if ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'show root certificate' }) {
758 & Header
:: openbox
( '100%' , 'left' , " $Lang ::tr{'root certificate'}:" );
759 $output = `/usr/bin/openssl x509 -text -in ${General::swroot}/ca/cacert.pem` ;
761 & Header
:: openbox
( '100%' , 'left' , " $Lang ::tr{'host certificate'}:" );
762 $output = `/usr/bin/openssl x509 -text -in ${General::swroot}/certs/hostcert.pem` ;
764 $output = & Header
:: cleanhtml
( $output , "y" );
765 print "<pre> $output </pre> \n " ;
767 print "<div align='center'><a href='/cgi-bin/vpnmain.cgi'> $Lang ::tr{'back'}</a></div>" ;
768 & Header
:: closebigbox
();
769 & Header
:: closepage
();
773 ### Export root certificate to browser
775 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'download root certificate' }) {
776 if ( - f
"${General::swroot}/ca/cacert.pem" ) {
777 print "Content-Type: application/force-download \n " ;
778 print "Content-Disposition: attachment; filename=cacert.pem \r\n\r\n " ;
779 print `/usr/bin/openssl x509 -in ${General::swroot}/ca/cacert.pem` ;
783 ### Export host certificate to browser
785 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'download host certificate' }) {
786 if ( - f
"${General::swroot}/certs/hostcert.pem" ) {
787 print "Content-Type: application/force-download \n " ;
788 print "Content-Disposition: attachment; filename=hostcert.pem \r\n\r\n " ;
789 print `/usr/bin/openssl x509 -in ${General::swroot}/certs/hostcert.pem` ;
793 ### Form for generating/importing the caroot+host certificate
795 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'generate root/host certificates' } ||
796 $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'upload p12 file' }) {
798 if (- f
"${General::swroot}/ca/cacert.pem" ) {
799 $errormessage = $Lang :: tr
{ 'valid root certificate already exists' };
803 & General
:: readhash
( "${General::swroot}/vpn/settings" , \
%vpnsettings );
804 # fill in initial values
805 if ( $cgiparams { 'ROOTCERT_HOSTNAME' } eq '' ) {
806 if (- e
"${General::swroot}/red/active" && open ( IPADDR
, "${General::swroot}/red/local-ipaddress" )) {
807 my $ipaddr = < IPADDR
>;
810 $cgiparams { 'ROOTCERT_HOSTNAME' } = ( gethostbyaddr ( pack ( "C4" , split ( /\./ , $ipaddr )), 2 ))[ 0 ];
811 if ( $cgiparams { 'ROOTCERT_HOSTNAME' } eq '' ) {
812 $cgiparams { 'ROOTCERT_HOSTNAME' } = $ipaddr ;
815 $cgiparams { 'ROOTCERT_COUNTRY' } = $vpnsettings { 'ROOTCERT_COUNTRY' } if (! $cgiparams { 'ROOTCERT_COUNTRY' });
816 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'upload p12 file' }) {
817 & General
:: log ( "ipsec" , "Importing from p12..." );
819 if ( ref ( $cgiparams { 'FH' }) ne 'Fh' ) {
820 $errormessage = $Lang :: tr
{ 'there was no file upload' };
824 # Move uploaded certificate request to a temporary file
825 ( my $fh , my $filename ) = tempfile
( );
826 if ( copy
( $cgiparams { 'FH' }, $fh ) != 1 ) {
831 # Extract the CA certificate from the file
832 & General
:: log ( "ipsec" , "Extracting caroot from p12..." );
833 if ( open ( STDIN
, "-|" )) {
834 my $opt = " pkcs12 -cacerts -nokeys" ;
835 $opt .= " -in $filename " ;
836 $opt .= " -out /tmp/newcacert" ;
837 $errormessage = & callssl
( $opt );
839 print " $cgiparams {'P12_PASS'} \n " ;
843 # Extract the Host certificate from the file
844 if (! $errormessage ) {
845 & General
:: log ( "ipsec" , "Extracting host cert from p12..." );
846 if ( open ( STDIN
, "-|" )) {
847 my $opt = " pkcs12 -clcerts -nokeys" ;
848 $opt .= " -in $filename " ;
849 $opt .= " -out /tmp/newhostcert" ;
850 $errormessage = & callssl
( $opt );
852 print " $cgiparams {'P12_PASS'} \n " ;
857 # Extract the Host key from the file
858 if (! $errormessage ) {
859 & General
:: log ( "ipsec" , "Extracting private key from p12..." );
860 if ( open ( STDIN
, "-|" )) {
861 my $opt = " pkcs12 -nocerts -nodes" ;
862 $opt .= " -in $filename " ;
863 $opt .= " -out /tmp/newhostkey" ;
864 $errormessage = & callssl
( $opt );
866 print " $cgiparams {'P12_PASS'} \n " ;
871 if (! $errormessage ) {
872 & General
:: log ( "ipsec" , "Moving cacert..." );
873 move
( "/tmp/newcacert" , "${General::swroot}/ca/cacert.pem" );
874 $errormessage = " $Lang ::tr{'certificate file move failed'}: $!" if ($ ?
ne 0 );
877 if (! $errormessage ) {
878 & General
:: log ( "ipsec" , "Moving host cert..." );
879 move
( "/tmp/newhostcert" , "${General::swroot}/certs/hostcert.pem" );
880 $errormessage = " $Lang ::tr{'certificate file move failed'}: $!" if ($ ?
ne 0 );
883 if (! $errormessage ) {
884 & General
:: log ( "ipsec" , "Moving private key..." );
885 move
( "/tmp/newhostkey" , "${General::swroot}/certs/hostkey.pem" );
886 $errormessage = " $Lang ::tr{'certificate file move failed'}: $!" if ($ ?
ne 0 );
891 unlink ( '/tmp/newcacert' );
892 unlink ( '/tmp/newhostcert' );
893 unlink ( '/tmp/newhostkey' );
895 unlink ( "${General::swroot}/ca/cacert.pem" );
896 unlink ( "${General::swroot}/certs/hostcert.pem" );
897 unlink ( "${General::swroot}/certs/hostkey.pem" );
901 # Create empty CRL cannot be done because we don't have
902 # the private key for this CAROOT
903 # IPFire can only import certificates
905 & General
:: log ( "ipsec" , "p12 import completed!" );
907 goto ROOTCERT_SUCCESS
;
909 } elsif ( $cgiparams { 'ROOTCERT_COUNTRY' } ne '' ) {
911 # Validate input since the form was submitted
912 if ( $cgiparams { 'ROOTCERT_ORGANIZATION' } eq '' ){
913 $errormessage = $Lang :: tr
{ 'organization cant be empty' };
916 if ( length ( $cgiparams { 'ROOTCERT_ORGANIZATION' }) > 60 ) {
917 $errormessage = $Lang :: tr
{ 'organization too long' };
920 if ( $cgiparams { 'ROOTCERT_ORGANIZATION' } !~ /^[a-zA-Z0-9 ,\.\-_]*$/ ) {
921 $errormessage = $Lang :: tr
{ 'invalid input for organization' };
924 if ( $cgiparams { 'ROOTCERT_HOSTNAME' } eq '' ){
925 $errormessage = $Lang :: tr
{ 'hostname cant be empty' };
928 unless (& General
:: validfqdn
( $cgiparams { 'ROOTCERT_HOSTNAME' }) || & General
:: validip
( $cgiparams { 'ROOTCERT_HOSTNAME' })) {
929 $errormessage = $Lang :: tr
{ 'invalid input for hostname' };
932 if ( $cgiparams { 'ROOTCERT_EMAIL' } ne '' && (! & General
:: validemail
( $cgiparams { 'ROOTCERT_EMAIL' }))) {
933 $errormessage = $Lang :: tr
{ 'invalid input for e-mail address' };
936 if ( length ( $cgiparams { 'ROOTCERT_EMAIL' }) > 40 ) {
937 $errormessage = $Lang :: tr
{ 'e-mail address too long' };
940 if ( $cgiparams { 'ROOTCERT_OU' } ne '' && $cgiparams { 'ROOTCERT_OU' } !~ /^[a-zA-Z0-9 ,\.\-_]*$/ ) {
941 $errormessage = $Lang :: tr
{ 'invalid input for department' };
944 if ( $cgiparams { 'ROOTCERT_CITY' } ne '' && $cgiparams { 'ROOTCERT_CITY' } !~ /^[a-zA-Z0-9 ,\.\-_]*$/ ) {
945 $errormessage = $Lang :: tr
{ 'invalid input for city' };
948 if ( $cgiparams { 'ROOTCERT_STATE' } ne '' && $cgiparams { 'ROOTCERT_STATE' } !~ /^[a-zA-Z0-9 ,\.\-_]*$/ ) {
949 $errormessage = $Lang :: tr
{ 'invalid input for state or province' };
952 if ( $cgiparams { 'ROOTCERT_COUNTRY' } !~ /^[A-Z]*$/ ) {
953 $errormessage = $Lang :: tr
{ 'invalid input for country' };
956 #the exact syntax is a list comma separated of
957 # email:any-validemail
958 # URI: a uniform resource indicator
959 # DNS: a DNS domain name
960 # RID: a registered OBJECT IDENTIFIER
962 # example: email:franck@foo.com,IP:10.0.0.10,DNS:franck.foo.com
964 if ( $cgiparams { 'SUBJECTALTNAME' } ne '' && $cgiparams { 'SUBJECTALTNAME' } !~ /^(email|URI|DNS|RID|IP):[a-zA-Z0-9 :\/ , \
. \
- _@
]*$/) {
965 $errormessage = $Lang :: tr
{ 'vpn altname syntax' };
969 # Copy the cgisettings to vpnsettings and save the configfile
970 $vpnsettings { 'ROOTCERT_ORGANIZATION' } = $cgiparams { 'ROOTCERT_ORGANIZATION' };
971 $vpnsettings { 'ROOTCERT_HOSTNAME' } = $cgiparams { 'ROOTCERT_HOSTNAME' };
972 $vpnsettings { 'ROOTCERT_EMAIL' } = $cgiparams { 'ROOTCERT_EMAIL' };
973 $vpnsettings { 'ROOTCERT_OU' } = $cgiparams { 'ROOTCERT_OU' };
974 $vpnsettings { 'ROOTCERT_CITY' } = $cgiparams { 'ROOTCERT_CITY' };
975 $vpnsettings { 'ROOTCERT_STATE' } = $cgiparams { 'ROOTCERT_STATE' };
976 $vpnsettings { 'ROOTCERT_COUNTRY' } = $cgiparams { 'ROOTCERT_COUNTRY' };
977 & General
:: writehash
( "${General::swroot}/vpn/settings" , \
%vpnsettings );
979 # Replace empty strings with a .
980 ( my $ou = $cgiparams { 'ROOTCERT_OU' }) =~ s/^\s*$/\./ ;
981 ( my $city = $cgiparams { 'ROOTCERT_CITY' }) =~ s/^\s*$/\./ ;
982 ( my $state = $cgiparams { 'ROOTCERT_STATE' }) =~ s/^\s*$/\./ ;
984 # Create the CA certificate
985 if (! $errormessage ) {
986 & General
:: log ( "ipsec" , "Creating cacert..." );
987 if ( open ( STDIN
, "-|" )) {
988 my $opt = " req -x509 -sha256 -nodes" ;
989 $opt .= " -days 999999" ;
990 $opt .= " -newkey rsa:4096" ;
991 $opt .= " -keyout ${General::swroot}/private/cakey.pem" ;
992 $opt .= " -out ${General::swroot}/ca/cacert.pem" ;
994 $errormessage = & callssl
( $opt );
996 print " $cgiparams {'ROOTCERT_COUNTRY'} \n " ;
999 print " $cgiparams {'ROOTCERT_ORGANIZATION'} \n " ;
1001 print " $cgiparams {'ROOTCERT_ORGANIZATION'} CA \n " ;
1002 print " $cgiparams {'ROOTCERT_EMAIL'} \n " ;
1007 # Create the Host certificate request
1008 if (! $errormessage ) {
1009 & General
:: log ( "ipsec" , "Creating host cert..." );
1010 if ( open ( STDIN
, "-|" )) {
1011 my $opt = " req -sha256 -nodes" ;
1012 $opt .= " -newkey rsa:2048" ;
1013 $opt .= " -keyout ${General::swroot}/certs/hostkey.pem" ;
1014 $opt .= " -out ${General::swroot}/certs/hostreq.pem" ;
1015 $errormessage = & callssl
( $opt );
1017 print " $cgiparams {'ROOTCERT_COUNTRY'} \n " ;
1020 print " $cgiparams {'ROOTCERT_ORGANIZATION'} \n " ;
1022 print " $cgiparams {'ROOTCERT_HOSTNAME'} \n " ;
1023 print " $cgiparams {'ROOTCERT_EMAIL'} \n " ;
1030 # Sign the host certificate request
1031 if (! $errormessage ) {
1032 & General
:: log ( "ipsec" , "Self signing host cert..." );
1034 #No easy way for specifying the contain of subjectAltName without writing a config file...
1035 my ( $fh , $v3extname ) = tempfile
( '/tmp/XXXXXXXX' );
1037 basicConstraints=CA:FALSE
1038 nsComment="OpenSSL Generated Certificate"
1039 subjectKeyIdentifier=hash
1040 authorityKeyIdentifier=keyid,issuer:always
1041 extendedKeyUsage = serverAuth
1044 print $fh "subjectAltName= $cgiparams {'SUBJECTALTNAME'}" if ( $cgiparams { 'SUBJECTALTNAME' });
1047 my $opt = " ca -md sha256 -days 999999" ;
1048 $opt .= " -batch -notext" ;
1049 $opt .= " -in ${General::swroot}/certs/hostreq.pem" ;
1050 $opt .= " -out ${General::swroot}/certs/hostcert.pem" ;
1051 $opt .= " -extfile $v3extname " ;
1052 $errormessage = & callssl
( $opt );
1053 unlink ( "${General::swroot}/certs/hostreq.pem" ); #no more needed
1054 unlink ( $v3extname );
1057 # Create an empty CRL
1058 if (! $errormessage ) {
1059 & General
:: log ( "ipsec" , "Creating emptycrl..." );
1060 my $opt = " ca -gencrl" ;
1061 $opt .= " -out ${General::swroot}/crls/cacrl.pem" ;
1062 $errormessage = & callssl
( $opt );
1065 # Successfully build CA / CERT!
1066 if (! $errormessage ) {
1067 & cleanssldatabase
();
1068 goto ROOTCERT_SUCCESS
;
1072 unlink ( "${General::swroot}/ca/cacert.pem" );
1073 unlink ( "${General::swroot}/certs/hostkey.pem" );
1074 unlink ( "${General::swroot}/certs/hostcert.pem" );
1075 unlink ( "${General::swroot}/crls/cacrl.pem" );
1076 & cleanssldatabase
();
1080 & Header
:: showhttpheaders
();
1081 & Header
:: openpage
( $Lang :: tr
{ 'ipsec' }, 1 , '' );
1082 & Header
:: openbigbox
( '100%' , 'left' , '' , $errormessage );
1083 if ( $errormessage ) {
1084 & Header
:: openbox
( '100%' , 'left' , $Lang :: tr
{ 'error messages' });
1085 print "<class name='base'> $errormessage " ;
1086 print " </class>" ;
1087 & Header
:: closebox
();
1089 & Header
:: openbox
( '100%' , 'left' , " $Lang ::tr{'generate root/host certificates'}:" );
1091 <form method='post' enctype='multipart/form-data' action=' $ENV {'SCRIPT_NAME'}'>
1092 <table width='100%' border='0' cellspacing='1' cellpadding='0'>
1093 <tr><td width='40%' class='base'> $Lang ::tr{'organization name'}: <img src='/blob.gif' alt='*' /></td>
1094 <td width='60%' class='base' nowrap='nowrap'><input type='text' name='ROOTCERT_ORGANIZATION' value=' $cgiparams {'ROOTCERT_ORGANIZATION'}' size='32' /></td></tr>
1095 <tr><td class='base'> $Lang ::tr{'ipfires hostname'}: <img src='/blob.gif' alt='*' /></td>
1096 <td class='base' nowrap='nowrap'><input type='text' name='ROOTCERT_HOSTNAME' value=' $cgiparams {'ROOTCERT_HOSTNAME'}' size='32' /></td></tr>
1097 <tr><td class='base'> $Lang ::tr{'your e-mail'}:</td>
1098 <td class='base' nowrap='nowrap'><input type='text' name='ROOTCERT_EMAIL' value=' $cgiparams {'ROOTCERT_EMAIL'}' size='32' /></td></tr>
1099 <tr><td class='base'> $Lang ::tr{'your department'}:</td>
1100 <td class='base' nowrap='nowrap'><input type='text' name='ROOTCERT_OU' value=' $cgiparams {'ROOTCERT_OU'}' size='32' /></td></tr>
1101 <tr><td class='base'> $Lang ::tr{'city'}:</td>
1102 <td class='base' nowrap='nowrap'><input type='text' name='ROOTCERT_CITY' value=' $cgiparams {'ROOTCERT_CITY'}' size='32' /></td></tr>
1103 <tr><td class='base'> $Lang ::tr{'state or province'}:</td>
1104 <td class='base' nowrap='nowrap'><input type='text' name='ROOTCERT_STATE' value=' $cgiparams {'ROOTCERT_STATE'}' size='32' /></td></tr>
1105 <tr><td class='base'> $Lang ::tr{'country'}:</td>
1106 <td class='base'><select name='ROOTCERT_COUNTRY'>
1109 foreach my $country ( sort keys %{ Countries
:: countries
}) {
1110 print "<option value=' $Countries ::countries{ $country }'" ;
1111 if ( $Countries :: countries
{ $country } eq $cgiparams { 'ROOTCERT_COUNTRY' } ) {
1112 print " selected='selected'" ;
1114 print "> $country </option>" ;
1118 <tr><td class='base'> $Lang ::tr{'vpn subjectaltname'} (subjectAltName=email:*,URI:*,DNS:*,RID:*)</td>
1119 <td class='base' nowrap='nowrap'><input type='text' name='SUBJECTALTNAME' value=' $cgiparams {'SUBJECTALTNAME'}' size='32' /></td></tr>
1121 <td><br /><input type='submit' name='ACTION' value=' $Lang ::tr{'generate root/host certificates'}' /><br /><br /></td></tr>
1122 <tr><td class='base' colspan='2' align='left'>
1123 <b><font color='${Header::colourred}'> $Lang ::tr{'capswarning'}</font></b>:
1124 $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'}
1126 <tr><td colspan='2'><hr></td></tr>
1127 <tr><td class='base' nowrap='nowrap'> $Lang ::tr{'upload p12 file'}:</td>
1128 <td nowrap='nowrap'><input type='file' name='FH' size='32' /></td></tr>
1129 <tr><td class='base'> $Lang ::tr{'pkcs12 file password'}:</td>
1130 <td class='base' nowrap='nowrap'><input type='password' name='P12_PASS' value=' $cgiparams {'P12_PASS'}' size='32' /></td></tr>
1132 <td><input type='submit' name='ACTION' value=' $Lang ::tr{'upload p12 file'}' /></td></tr>
1133 <tr><td class='base' colspan='2' align='left'>
1134 <img src='/blob.gif' alt='*' /> $Lang ::tr{'required field'}</td></tr>
1138 & Header
:: closebox
();
1139 & Header
:: closebigbox
();
1140 & Header
:: closepage
();
1145 system ( '/usr/local/bin/ipsecctrl' , 'S' );
1150 ### Export PKCS12 file to browser
1152 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'download pkcs12 file' }) {
1153 & General
:: readhasharray
( "${General::swroot}/vpn/config" , \
%confighash );
1154 print "Content-Type: application/force-download \n " ;
1155 print "Content-Disposition: attachment; filename=" . $confighash { $cgiparams { 'KEY' }}[ 1 ] . ".p12 \r\n " ;
1156 print "Content-Type: application/octet-stream \r\n\r\n " ;
1157 print `/bin/cat ${General::swroot}/certs/ $confighash { $cgiparams {'KEY'}}[1].p12` ;
1161 ### Display certificate
1163 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'show certificate' }) {
1164 & General
:: readhasharray
( "${General::swroot}/vpn/config" , \
%confighash );
1166 if ( - f
"${General::swroot}/certs/ $confighash { $cgiparams {'KEY'}}[1]cert.pem" ) {
1167 & Header
:: showhttpheaders
();
1168 & Header
:: openpage
( $Lang :: tr
{ 'ipsec' }, 1 , '' );
1169 & Header
:: openbigbox
( '100%' , 'left' , '' , '' );
1170 & Header
:: openbox
( '100%' , 'left' , " $Lang ::tr{'cert'}:" );
1171 my $output = `/usr/bin/openssl x509 -text -in ${General::swroot}/certs/ $confighash { $cgiparams {'KEY'}}[1]cert.pem` ;
1172 $output = & Header
:: cleanhtml
( $output , "y" );
1173 print "<pre> $output </pre> \n " ;
1174 & Header
:: closebox
();
1175 print "<div align='center'><a href='/cgi-bin/vpnmain.cgi'> $Lang ::tr{'back'}</a></div>" ;
1176 & Header
:: closebigbox
();
1177 & Header
:: closepage
();
1182 ### Export Certificate to browser
1184 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'download certificate' }) {
1185 & General
:: readhasharray
( "${General::swroot}/vpn/config" , \
%confighash );
1187 if ( - f
"${General::swroot}/certs/ $confighash { $cgiparams {'KEY'}}[1]cert.pem" ) {
1188 print "Content-Type: application/force-download \n " ;
1189 print "Content-Disposition: attachment; filename=" . $confighash { $cgiparams { 'KEY' }}[ 1 ] . "cert.pem \n\n " ;
1190 print `/bin/cat ${General::swroot}/certs/ $confighash { $cgiparams {'KEY'}}[1]cert.pem` ;
1195 ### Enable/Disable connection
1197 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'toggle enable disable' }) {
1199 & General
:: readhash
( "${General::swroot}/vpn/settings" , \
%vpnsettings );
1200 & General
:: readhasharray
( "${General::swroot}/vpn/config" , \
%confighash );
1202 if ( $confighash { $cgiparams { 'KEY' }}) {
1203 if ( $confighash { $cgiparams { 'KEY' }}[ 0 ] eq 'off' ) {
1204 $confighash { $cgiparams { 'KEY' }}[ 0 ] = 'on' ;
1205 & General
:: writehasharray
( "${General::swroot}/vpn/config" , \
%confighash );
1207 system ( '/usr/local/bin/ipsecctrl' , 'S' , $cgiparams { 'KEY' }) if (& vpnenabled
);
1209 system ( '/usr/local/bin/ipsecctrl' , 'D' , $cgiparams { 'KEY' }) if (& vpnenabled
);
1210 $confighash { $cgiparams { 'KEY' }}[ 0 ] = 'off' ;
1211 & General
:: writehasharray
( "${General::swroot}/vpn/config" , \
%confighash );
1216 $errormessage = $Lang :: tr
{ 'invalid key' };
1220 ### Restart connection
1222 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'restart' }) {
1223 & General
:: readhash
( "${General::swroot}/vpn/settings" , \
%vpnsettings );
1224 & General
:: readhasharray
( "${General::swroot}/vpn/config" , \
%confighash );
1226 if ( $confighash { $cgiparams { 'KEY' }}) {
1228 system ( '/usr/local/bin/ipsecctrl' , 'S' , $cgiparams { 'KEY' });
1232 $errormessage = $Lang :: tr
{ 'invalid key' };
1236 ### Remove connection
1238 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'remove' }) {
1239 & General
:: readhash
( "${General::swroot}/vpn/settings" , \
%vpnsettings );
1240 & General
:: readhasharray
( "${General::swroot}/vpn/config" , \
%confighash );
1242 if ( $confighash { $cgiparams { 'KEY' }}) {
1243 system ( '/usr/local/bin/ipsecctrl' , 'D' , $cgiparams { 'KEY' }) if (& vpnenabled
);
1244 unlink ( "${General::swroot}/certs/ $confighash { $cgiparams {'KEY'}}[1]cert.pem" );
1245 unlink ( "${General::swroot}/certs/ $confighash { $cgiparams {'KEY'}}[1].p12" );
1246 delete $confighash { $cgiparams { 'KEY' }};
1247 & General
:: writehasharray
( "${General::swroot}/vpn/config" , \
%confighash );
1250 $errormessage = $Lang :: tr
{ 'invalid key' };
1252 & General
:: firewall_reload
();
1254 ### Choose between adding a host-net or net-net connection
1256 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'add' } && $cgiparams { 'TYPE' } eq '' ) {
1257 & Header
:: showhttpheaders
();
1258 & Header
:: openpage
( $Lang :: tr
{ 'ipsec' }, 1 , '' );
1259 & Header
:: openbigbox
( '100%' , 'left' , '' , '' );
1260 & Header
:: openbox
( '100%' , 'left' , $Lang :: tr
{ 'connection type' });
1262 <form method='post' action=' $ENV {'SCRIPT_NAME'}'>
1263 <b> $Lang ::tr{'connection type'}:</b><br />
1265 <tr><td><input type='radio' name='TYPE' value='host' checked='checked' /></td>
1266 <td class='base'> $Lang ::tr{'host to net vpn'}</td>
1268 <td><input type='radio' name='TYPE' value='net' /></td>
1269 <td class='base'> $Lang ::tr{'net to net vpn'}</td>
1271 <td align='center' colspan='2'><input type='submit' name='ACTION' value=' $Lang ::tr{'add'}' /></td>
1276 & Header
:: closebox
();
1277 & Header
:: closebigbox
();
1278 & Header
:: closepage
();
1281 ### Adding/Editing/Saving a connection
1283 } elsif (( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'add' }) ||
1284 ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'edit' }) ||
1285 ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'save' } && $cgiparams { 'ADVANCED' } eq '' )) {
1287 & General
:: readhash
( "${General::swroot}/vpn/settings" , \
%vpnsettings );
1288 & General
:: readhasharray
( "${General::swroot}/vpn/caconfig" , \
%cahash );
1289 & General
:: readhasharray
( "${General::swroot}/vpn/config" , \
%confighash );
1291 if ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'edit' }) {
1292 if (! $confighash { $cgiparams { 'KEY' }}[ 0 ]) {
1293 $errormessage = $Lang :: tr
{ 'invalid key' };
1296 $cgiparams { 'ENABLED' } = $confighash { $cgiparams { 'KEY' }}[ 0 ];
1297 $cgiparams { 'NAME' } = $confighash { $cgiparams { 'KEY' }}[ 1 ];
1298 $cgiparams { 'TYPE' } = $confighash { $cgiparams { 'KEY' }}[ 3 ];
1299 $cgiparams { 'AUTH' } = $confighash { $cgiparams { 'KEY' }}[ 4 ];
1300 $cgiparams { 'PSK' } = $confighash { $cgiparams { 'KEY' }}[ 5 ];
1301 #$cgiparams{'free'} = $confighash{$cgiparams{'KEY'}}[6];
1302 $cgiparams { 'LOCAL_ID' } = $confighash { $cgiparams { 'KEY' }}[ 7 ];
1303 my @local_subnets = split ( "," , $confighash { $cgiparams { 'KEY' }}[ 8 ]);
1304 $cgiparams { 'LOCAL_SUBNET' } = join ( /\|/ , @local_subnets );
1305 $cgiparams { 'REMOTE_ID' } = $confighash { $cgiparams { 'KEY' }}[ 9 ];
1306 $cgiparams { 'REMOTE' } = $confighash { $cgiparams { 'KEY' }}[ 10 ];
1307 my @remote_subnets = split ( "," , $confighash { $cgiparams { 'KEY' }}[ 11 ]);
1308 $cgiparams { 'REMOTE_SUBNET' } = join ( /\|/ , @remote_subnets );
1309 $cgiparams { 'REMARK' } = $confighash { $cgiparams { 'KEY' }}[ 25 ];
1310 $cgiparams { 'DPD_ACTION' } = $confighash { $cgiparams { 'KEY' }}[ 27 ];
1311 $cgiparams { 'IKE_VERSION' } = $confighash { $cgiparams { 'KEY' }}[ 29 ];
1312 $cgiparams { 'IKE_ENCRYPTION' } = $confighash { $cgiparams { 'KEY' }}[ 18 ];
1313 $cgiparams { 'IKE_INTEGRITY' } = $confighash { $cgiparams { 'KEY' }}[ 19 ];
1314 $cgiparams { 'IKE_GROUPTYPE' } = $confighash { $cgiparams { 'KEY' }}[ 20 ];
1315 $cgiparams { 'IKE_LIFETIME' } = $confighash { $cgiparams { 'KEY' }}[ 16 ];
1316 $cgiparams { 'ESP_ENCRYPTION' } = $confighash { $cgiparams { 'KEY' }}[ 21 ];
1317 $cgiparams { 'ESP_INTEGRITY' } = $confighash { $cgiparams { 'KEY' }}[ 22 ];
1318 $cgiparams { 'ESP_GROUPTYPE' } = $confighash { $cgiparams { 'KEY' }}[ 23 ];
1319 if ( $cgiparams { 'ESP_GROUPTYPE' } eq "" ) {
1320 $cgiparams { 'ESP_GROUPTYPE' } = $cgiparams { 'IKE_GROUPTYPE' };
1322 $cgiparams { 'ESP_KEYLIFE' } = $confighash { $cgiparams { 'KEY' }}[ 17 ];
1323 $cgiparams { 'COMPRESSION' } = $confighash { $cgiparams { 'KEY' }}[ 13 ];
1324 $cgiparams { 'ONLY_PROPOSED' } = $confighash { $cgiparams { 'KEY' }}[ 24 ];
1325 $cgiparams { 'PFS' } = $confighash { $cgiparams { 'KEY' }}[ 28 ];
1326 $cgiparams { 'DPD_TIMEOUT' } = $confighash { $cgiparams { 'KEY' }}[ 30 ];
1327 $cgiparams { 'DPD_DELAY' } = $confighash { $cgiparams { 'KEY' }}[ 31 ];
1328 $cgiparams { 'FORCE_MOBIKE' } = $confighash { $cgiparams { 'KEY' }}[ 32 ];
1329 $cgiparams { 'INACTIVITY_TIMEOUT' } = $confighash { $cgiparams { 'KEY' }}[ 34 ];
1330 $cgiparams { 'MODE' } = $confighash { $cgiparams { 'KEY' }}[ 35 ];
1331 $cgiparams { 'INTERFACE_MODE' } = $confighash { $cgiparams { 'KEY' }}[ 36 ];
1332 $cgiparams { 'INTERFACE_ADDRESS' } = $confighash { $cgiparams { 'KEY' }}[ 37 ];
1333 $cgiparams { 'INTERFACE_MTU' } = $confighash { $cgiparams { 'KEY' }}[ 38 ];
1335 if (! $cgiparams { 'DPD_DELAY' }) {
1336 $cgiparams { 'DPD_DELAY' } = 30 ;
1339 if (! $cgiparams { 'DPD_TIMEOUT' }) {
1340 $cgiparams { 'DPD_TIMEOUT' } = 120 ;
1343 if ( $cgiparams { 'INACTIVITY_TIMEOUT' } eq "" ) {
1344 $cgiparams { 'INACTIVITY_TIMEOUT' } = 900 ;
1347 if ( $cgiparams { 'MODE' } eq "" ) {
1348 $cgiparams { 'MODE' } = "tunnel" ;
1351 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'save' }) {
1352 $cgiparams { 'REMARK' } = & Header
:: cleanhtml
( $cgiparams { 'REMARK' });
1353 if ( $cgiparams { 'TYPE' } !~ /^(host|net)$/ ) {
1354 $errormessage = $Lang :: tr
{ 'connection type is invalid' };
1358 if ( $cgiparams { 'NAME' } !~ /^[a-zA-Z0-9]+$/ ) {
1359 $errormessage = $Lang :: tr
{ 'name must only contain characters' };
1363 if ( $cgiparams { 'NAME' } =~ /^(host|01|block|private|clear|packetdefault)$/ ) {
1364 $errormessage = $Lang :: tr
{ 'name is invalid' };
1368 if ( length ( $cgiparams { 'NAME' }) > 60 ) {
1369 $errormessage = $Lang :: tr
{ 'name too long' };
1373 # Check if there is no other entry with this name
1374 if (! $cgiparams { 'KEY' }) { #only for add
1375 foreach my $key ( keys %confighash ) {
1376 if ( $confighash { $key }[ 1 ] eq $cgiparams { 'NAME' }) {
1377 $errormessage = $Lang :: tr
{ 'a connection with this name already exists' };
1383 if (( $cgiparams { 'TYPE' } eq 'net' ) && (! $cgiparams { 'REMOTE' })) {
1384 $errormessage = $Lang :: tr
{ 'invalid input for remote host/ip' };
1388 if ( $cgiparams { 'REMOTE' }) {
1389 if (( $cgiparams { 'REMOTE' } ne ' %any ' ) && (! & General
:: validip
( $cgiparams { 'REMOTE' }))) {
1390 if (! & General
:: validfqdn
( $cgiparams { 'REMOTE' })) {
1391 $errormessage = $Lang :: tr
{ 'invalid input for remote host/ip' };
1394 if (& valid_dns_host
( $cgiparams { 'REMOTE' })) {
1395 $warnmessage = " $Lang ::tr{'check vpn lr'} $cgiparams {'REMOTE'}. $Lang ::tr{'dns check failed'}" ;
1401 my @local_subnets = split ( "," , $cgiparams { 'LOCAL_SUBNET' });
1402 foreach my $subnet ( @local_subnets ) {
1403 unless (& Network
:: check_subnet
( $subnet )) {
1404 $errormessage = $Lang :: tr
{ 'local subnet is invalid' };
1409 # Allow only one roadwarrior/psk without remote IP-address
1410 if ( $cgiparams { 'REMOTE' } eq '' && $cgiparams { 'AUTH' } eq 'psk' ) {
1411 foreach my $key ( keys %confighash ) {
1412 if ( ( $cgiparams { 'KEY' } ne $key ) &&
1413 ( $confighash { $key }[ 4 ] eq 'psk' ) &&
1414 ( $confighash { $key }[ 10 ] eq '' ) ) {
1415 $errormessage = $Lang :: tr
{ 'you can only define one roadwarrior connection when using pre-shared key authentication' };
1421 if ( $cgiparams { 'TYPE' } eq 'net' ) {
1422 my @remote_subnets = split ( "," , $cgiparams { 'REMOTE_SUBNET' });
1423 foreach my $subnet ( @remote_subnets ) {
1424 unless (& Network
:: check_subnet
( $subnet )) {
1425 $errormessage = $Lang :: tr
{ 'remote subnet is invalid' };
1431 if ( $cgiparams { 'ENABLED' } !~ /^(on|off)$/ ) {
1432 $errormessage = $Lang :: tr
{ 'invalid input' };
1435 if ( $cgiparams { 'EDIT_ADVANCED' } !~ /^(on|off)$/ ) {
1436 $errormessage = $Lang :: tr
{ 'invalid input' };
1440 # Allow nothing or a string (DN,FDQN,) beginning with @
1441 # with no comma but slashes between RID eg @O=FR/C=Paris/OU=myhome/CN=franck
1442 if ( ( $cgiparams { 'LOCAL_ID' } !~ /^(|[\w.-]*@[\w. =*\/ -]+| \d
+ \
. \d
+ \
. \d
+ \
. \d
+)$/) ||
1443 ( $cgiparams { 'REMOTE_ID' } !~ /^(|[\w.-]*@[\w. =*\/ -]+| \d
+ \
. \d
+ \
. \d
+ \
. \d
+)$/) ||
1444 (( $cgiparams { 'REMOTE_ID' } eq $cgiparams { 'LOCAL_ID' }) && ( $cgiparams { 'LOCAL_ID' } ne '' ))
1446 $errormessage = $Lang :: tr
{ 'invalid local-remote id' } . '<br />' .
1447 'DER_ASN1_DN: @c =FR/ou=Paris/ou=Home/cn=*<br />' .
1448 'FQDN: @ipfire .org<br />' .
1449 'USER_FQDN: info @ipfire .org<br />' .
1450 'IPV4_ADDR: 123.123.123.123' ;
1453 # If Auth is DN, verify existance of Remote ID.
1454 if ( $cgiparams { 'REMOTE_ID' } eq '' && (
1455 $cgiparams { 'AUTH' } eq 'auth-dn' || # while creation
1456 $confighash { $cgiparams { 'KEY' }}[ 2 ] eq ' %auth -dn' )){ # while editing
1457 $errormessage = $Lang :: tr
{ 'vpn missing remote id' };
1461 if ( $cgiparams { 'TYPE' } eq 'net' ){
1462 $warnmessage =& General
:: checksubnets
( '' , $cgiparams { 'REMOTE_SUBNET' }, 'ipsec' );
1463 if ( $warnmessage ne '' ){
1464 $warnmessage = $Lang :: tr
{ 'remote subnet' }. " ( $cgiparams {'REMOTE_SUBNET'}) <br>" . $warnmessage ;
1468 if ( $cgiparams { 'AUTH' } eq 'psk' ) {
1469 if (! length ( $cgiparams { 'PSK' }) ) {
1470 $errormessage = $Lang :: tr
{ 'pre-shared key is too short' };
1473 if ( $cgiparams { 'PSK' } =~ /'/ ) {
1474 $cgiparams { 'PSK' } =~ tr/'/ / ;
1475 $errormessage = $Lang :: tr
{ 'invalid characters found in pre-shared key' };
1478 } elsif ( $cgiparams { 'AUTH' } eq 'certreq' ) {
1479 if ( $cgiparams { 'KEY' }) {
1480 $errormessage = $Lang :: tr
{ 'cant change certificates' };
1483 if ( ref ( $cgiparams { 'FH' }) ne 'Fh' ) {
1484 $errormessage = $Lang :: tr
{ 'there was no file upload' };
1488 # Move uploaded certificate request to a temporary file
1489 ( my $fh , my $filename ) = tempfile
( );
1490 if ( copy
( $cgiparams { 'FH' }, $fh ) != 1 ) {
1495 # Sign the certificate request
1496 & General
:: log ( "ipsec" , "Signing your cert $cgiparams {'NAME'}..." );
1497 my $opt = " ca -md sha256 -days 999999" ;
1498 $opt .= " -batch -notext" ;
1499 $opt .= " -in $filename " ;
1500 $opt .= " -out ${General::swroot}/certs/ $cgiparams {'NAME'}cert.pem" ;
1502 if ( $errormessage = & callssl
( $opt ) ) {
1504 unlink ( "${General::swroot}/certs/ $cgiparams {'NAME'}cert.pem" );
1505 & cleanssldatabase
();
1509 & cleanssldatabase
();
1512 $cgiparams { 'CERT_NAME' } = getCNfromcert
( "${General::swroot}/certs/ $cgiparams {'NAME'}cert.pem" );
1513 if ( $cgiparams { 'CERT_NAME' } eq '' ) {
1514 $errormessage = $Lang :: tr
{ 'could not retrieve common name from certificate' };
1517 } elsif ( $cgiparams { 'AUTH' } eq 'pkcs12' ) {
1518 & General
:: log ( "ipsec" , "Importing from p12..." );
1520 if ( ref ( $cgiparams { 'FH' }) ne 'Fh' ) {
1521 $errormessage = $Lang :: tr
{ 'there was no file upload' };
1522 goto ROOTCERT_ERROR
;
1525 # Move uploaded certificate request to a temporary file
1526 ( my $fh , my $filename ) = tempfile
( );
1527 if ( copy
( $cgiparams { 'FH' }, $fh ) != 1 ) {
1529 goto ROOTCERT_ERROR
;
1532 # Extract the CA certificate from the file
1533 & General
:: log ( "ipsec" , "Extracting caroot from p12..." );
1534 if ( open ( STDIN
, "-|" )) {
1535 my $opt = " pkcs12 -cacerts -nokeys" ;
1536 $opt .= " -in $filename " ;
1537 $opt .= " -out /tmp/newcacert" ;
1538 $errormessage = & callssl
( $opt );
1540 print " $cgiparams {'P12_PASS'} \n " ;
1544 # Extract the Host certificate from the file
1545 if (! $errormessage ) {
1546 & General
:: log ( "ipsec" , "Extracting host cert from p12..." );
1547 if ( open ( STDIN
, "-|" )) {
1548 my $opt = " pkcs12 -clcerts -nokeys" ;
1549 $opt .= " -in $filename " ;
1550 $opt .= " -out /tmp/newhostcert" ;
1551 $errormessage = & callssl
( $opt );
1553 print " $cgiparams {'P12_PASS'} \n " ;
1558 if (! $errormessage ) {
1559 & General
:: log ( "ipsec" , "Moving cacert..." );
1560 #If CA have new subject, add it to our list of CA
1561 my $casubject = & Header
:: cleanhtml
( getsubjectfromcert
( '/tmp/newcacert' ));
1563 foreach my $x ( keys %cahash ) {
1564 $casubject = '' if ( $cahash { $x }[ 1 ] eq $casubject );
1565 unshift ( @names , $cahash { $x }[ 0 ]);
1567 if ( $casubject ) { # a new one!
1568 my $temp = `/usr/bin/openssl x509 -text -in /tmp/newcacert` ;
1569 if ( $temp !~ /CA:TRUE/i ) {
1570 $errormessage = $Lang :: tr
{ 'not a valid ca certificate' };
1572 #compute a name for it
1574 while ( grep ( /Imported-$idx/ , @names ) ) { $idx ++};
1575 $cgiparams { 'CA_NAME' }= "Imported- $idx " ;
1576 $cgiparams { 'CERT_NAME' }=& Header
:: cleanhtml
( getCNfromcert
( '/tmp/newhostcert' ));
1577 move
( "/tmp/newcacert" , "${General::swroot}/ca/ $cgiparams {'CA_NAME'}cert.pem" );
1578 $errormessage = " $Lang ::tr{'certificate file move failed'}: $!" if ($ ?
ne 0 );
1579 if (! $errormessage ) {
1580 my $key = & General
:: findhasharraykey
( \
%cahash );
1581 $cahash { $key }[ 0 ] = $cgiparams { 'CA_NAME' };
1582 $cahash { $key }[ 1 ] = $casubject ;
1583 & General
:: writehasharray
( "${General::swroot}/vpn/caconfig" , \
%cahash );
1584 system ( '/usr/local/bin/ipsecctrl' , 'R' );
1589 if (! $errormessage ) {
1590 & General
:: log ( "ipsec" , "Moving host cert..." );
1591 move
( "/tmp/newhostcert" , "${General::swroot}/certs/ $cgiparams {'NAME'}cert.pem" );
1592 $errormessage = " $Lang ::tr{'certificate file move failed'}: $!" if ($ ?
ne 0 );
1597 unlink ( '/tmp/newcacert' );
1598 unlink ( '/tmp/newhostcert' );
1599 if ( $errormessage ) {
1600 unlink ( "${General::swroot}/ca/ $cgiparams {'CA_NAME'}cert.pem" );
1601 unlink ( "${General::swroot}/certs/ $cgiparams {'NAME'}cert.pem" );
1604 & General
:: log ( "ipsec" , "p12 import completed!" );
1605 } elsif ( $cgiparams { 'AUTH' } eq 'certfile' ) {
1606 if ( $cgiparams { 'KEY' }) {
1607 $errormessage = $Lang :: tr
{ 'cant change certificates' };
1610 if ( ref ( $cgiparams { 'FH' }) ne 'Fh' ) {
1611 $errormessage = $Lang :: tr
{ 'there was no file upload' };
1614 # Move uploaded certificate to a temporary file
1615 ( my $fh , my $filename ) = tempfile
( );
1616 if ( copy
( $cgiparams { 'FH' }, $fh ) != 1 ) {
1621 # Verify the certificate has a valid CA and move it
1622 & General
:: log ( "ipsec" , "Validating imported cert against our known CA..." );
1623 my $validca = 1 ; #assume ok
1624 my $test = `/usr/bin/openssl verify -CAfile ${General::swroot}/ca/cacert.pem $filename ` ;
1625 if ( $test !~ /: OK/ ) {
1627 foreach my $key ( keys %cahash ) {
1628 $test = `/usr/bin/openssl verify -CAfile ${General::swroot}/ca/ $cahash { $key }[0]cert.pem $filename ` ;
1629 if ( $test =~ /: OK/ ) {
1636 $errormessage = $Lang :: tr
{ 'certificate does not have a valid ca associated with it' };
1640 move
( $filename , "${General::swroot}/certs/ $cgiparams {'NAME'}cert.pem" );
1642 $errormessage = " $Lang ::tr{'certificate file move failed'}: $!" ;
1648 $cgiparams { 'CERT_NAME' } = getCNfromcert
( "${General::swroot}/certs/ $cgiparams {'NAME'}cert.pem" );
1649 if ( $cgiparams { 'CERT_NAME' } eq '' ) {
1650 unlink ( "${General::swroot}/certs/ $cgiparams {'NAME'}cert.pem" );
1651 $errormessage = $Lang :: tr
{ 'could not retrieve common name from certificate' };
1654 } elsif ( $cgiparams { 'AUTH' } eq 'certgen' ) {
1655 if ( $cgiparams { 'KEY' }) {
1656 $errormessage = $Lang :: tr
{ 'cant change certificates' };
1659 # Validate input since the form was submitted
1660 if ( length ( $cgiparams { 'CERT_NAME' }) > 60 ) {
1661 $errormessage = $Lang :: tr
{ 'name too long' };
1664 if ( $cgiparams { 'CERT_NAME' } !~ /^[a-zA-Z0-9 ,\.\-_]+$/ ) {
1665 $errormessage = $Lang :: tr
{ 'invalid input for name' };
1668 if ( $cgiparams { 'CERT_EMAIL' } ne '' && (! & General
:: validemail
( $cgiparams { 'CERT_EMAIL' }))) {
1669 $errormessage = $Lang :: tr
{ 'invalid input for e-mail address' };
1672 if ( length ( $cgiparams { 'CERT_EMAIL' }) > 40 ) {
1673 $errormessage = $Lang :: tr
{ 'e-mail address too long' };
1676 if ( $cgiparams { 'CERT_OU' } ne '' && $cgiparams { 'CERT_OU' } !~ /^[a-zA-Z0-9 ,\.\-_]*$/ ) {
1677 $errormessage = $Lang :: tr
{ 'invalid input for department' };
1680 if ( length ( $cgiparams { 'CERT_ORGANIZATION' }) > 60 ) {
1681 $errormessage = $Lang :: tr
{ 'organization too long' };
1684 if ( $cgiparams { 'CERT_ORGANIZATION' } !~ /^[a-zA-Z0-9 ,\.\-_]+$/ ) {
1685 $errormessage = $Lang :: tr
{ 'invalid input for organization' };
1688 if ( $cgiparams { 'CERT_CITY' } ne '' && $cgiparams { 'CERT_CITY' } !~ /^[a-zA-Z0-9 ,\.\-_]*$/ ) {
1689 $errormessage = $Lang :: tr
{ 'invalid input for city' };
1692 if ( $cgiparams { 'CERT_STATE' } ne '' && $cgiparams { 'CERT_STATE' } !~ /^[a-zA-Z0-9 ,\.\-_]*$/ ) {
1693 $errormessage = $Lang :: tr
{ 'invalid input for state or province' };
1696 if ( $cgiparams { 'CERT_COUNTRY' } !~ /^[A-Z]*$/ ) {
1697 $errormessage = $Lang :: tr
{ 'invalid input for country' };
1700 #the exact syntax is a list comma separated of
1701 # email:any-validemail
1702 # URI: a uniform resource indicator
1703 # DNS: a DNS domain name
1704 # RID: a registered OBJECT IDENTIFIER
1706 # example: email:franck@foo.com,IP:10.0.0.10,DNS:franck.foo.com
1708 if ( $cgiparams { 'SUBJECTALTNAME' } ne '' && $cgiparams { 'SUBJECTALTNAME' } !~ /^(email|URI|DNS|RID|IP):[a-zA-Z0-9 :\/ , \
. \
- _@
]*$/) {
1709 $errormessage = $Lang :: tr
{ 'vpn altname syntax' };
1713 if ( length ( $cgiparams { 'CERT_PASS1' }) < 5 ) {
1714 $errormessage = $Lang :: tr
{ 'password too short' };
1717 if ( $cgiparams { 'CERT_PASS1' } ne $cgiparams { 'CERT_PASS2' }) {
1718 $errormessage = $Lang :: tr
{ 'passwords do not match' };
1722 # Replace empty strings with a .
1723 ( my $ou = $cgiparams { 'CERT_OU' }) =~ s/^\s*$/\./ ;
1724 ( my $city = $cgiparams { 'CERT_CITY' }) =~ s/^\s*$/\./ ;
1725 ( my $state = $cgiparams { 'CERT_STATE' }) =~ s/^\s*$/\./ ;
1727 # Create the Client certificate request
1728 & General
:: log ( "ipsec" , "Creating a cert..." );
1730 if ( open ( STDIN
, "-|" )) {
1731 my $opt = " req -nodes -rand /proc/interrupts:/proc/net/rt_cache" ;
1732 $opt .= " -newkey rsa:2048" ;
1733 $opt .= " -keyout ${General::swroot}/certs/ $cgiparams {'NAME'}key.pem" ;
1734 $opt .= " -out ${General::swroot}/certs/ $cgiparams {'NAME'}req.pem" ;
1736 if ( $errormessage = & callssl
( $opt ) ) {
1737 unlink ( "${General::swroot}/certs/ $cgiparams {'NAME'}key.pem" );
1738 unlink ( "${General::swroot}/certs/ $cgiparams {'NAME'}req.pem" );
1742 print " $cgiparams {'CERT_COUNTRY'} \n " ;
1745 print " $cgiparams {'CERT_ORGANIZATION'} \n " ;
1747 print " $cgiparams {'CERT_NAME'} \n " ;
1748 print " $cgiparams {'CERT_EMAIL'} \n " ;
1754 # Sign the client certificate request
1755 & General
:: log ( "ipsec" , "Signing the cert $cgiparams {'NAME'}..." );
1757 #No easy way for specifying the contain of subjectAltName without writing a config file...
1758 my ( $fh , $v3extname ) = tempfile
( '/tmp/XXXXXXXX' );
1760 basicConstraints=CA:FALSE
1761 nsComment="OpenSSL Generated Certificate"
1762 subjectKeyIdentifier=hash
1763 extendedKeyUsage=clientAuth
1764 authorityKeyIdentifier=keyid,issuer:always
1767 print $fh "subjectAltName= $cgiparams {'SUBJECTALTNAME'}" if ( $cgiparams { 'SUBJECTALTNAME' });
1770 my $opt = " ca -md sha256 -days 999999 -batch -notext" ;
1771 $opt .= " -in ${General::swroot}/certs/ $cgiparams {'NAME'}req.pem" ;
1772 $opt .= " -out ${General::swroot}/certs/ $cgiparams {'NAME'}cert.pem" ;
1773 $opt .= " -extfile $v3extname " ;
1775 if ( $errormessage = & callssl
( $opt ) ) {
1776 unlink ( $v3extname );
1777 unlink ( "${General::swroot}/certs/ $cgiparams {'NAME'}key.pem" );
1778 unlink ( "${General::swroot}/certs/ $cgiparams {'NAME'}req.pem" );
1779 unlink ( "${General::swroot}/certs/ $cgiparams {'NAME'}cert.pem" );
1780 & cleanssldatabase
();
1783 unlink ( $v3extname );
1784 unlink ( "${General::swroot}/certs/ $cgiparams {'NAME'}req.pem" );
1785 & cleanssldatabase
();
1788 # Create the pkcs12 file
1789 & General
:: log ( "ipsec" , "Packing a pkcs12 file..." );
1790 $opt = " pkcs12 -export" ;
1791 $opt .= " -inkey ${General::swroot}/certs/ $cgiparams {'NAME'}key.pem" ;
1792 $opt .= " -in ${General::swroot}/certs/ $cgiparams {'NAME'}cert.pem" ;
1793 $opt .= " -name \" $cgiparams {'NAME'} \" " ;
1794 $opt .= " -passout pass: $cgiparams {'CERT_PASS1'}" ;
1795 $opt .= " -certfile ${General::swroot}/ca/cacert.pem" ;
1796 $opt .= " -caname \" $vpnsettings {'ROOTCERT_ORGANIZATION'} CA \" " ;
1797 $opt .= " -out ${General::swroot}/certs/ $cgiparams {'NAME'}.p12" ;
1799 if ( $errormessage = & callssl
( $opt ) ) {
1800 unlink ( "${General::swroot}/certs/ $cgiparams {'NAME'}key.pem" );
1801 unlink ( "${General::swroot}/certs/ $cgiparams {'NAME'}cert.pem" );
1802 unlink ( "${General::swroot}/certs/ $cgiparams {'NAME'}.p12" );
1805 unlink ( "${General::swroot}/certs/ $cgiparams {'NAME'}key.pem" );
1807 } elsif ( $cgiparams { 'AUTH' } eq 'cert' ) {
1808 ; # Nothing, just editing
1809 } elsif ( $cgiparams { 'AUTH' } eq 'auth-dn' ) {
1810 $cgiparams { 'CERT_NAME' } = ' %auth -dn' ; # a special value saying 'no cert file'
1812 $errormessage = $Lang :: tr
{ 'invalid input for authentication method' };
1816 # 1)Error message here is not accurate.
1817 # 2)Test is superfluous, openswan can reference same cert multiple times
1818 # 3)Present since initial version (1.3.2.11), it isn't a bug correction
1819 # Check if there is no other entry with this certificate name
1820 #if ((! $cgiparams{'KEY'}) && ($cgiparams{'AUTH'} ne 'psk') && ($cgiparams{'AUTH'} ne 'auth-dn')) {
1821 # foreach my $key (keys %confighash) {
1822 # if ($confighash{$key}[2] eq $cgiparams{'CERT_NAME'}) {
1823 # $errormessage = $Lang::tr{'a connection with this common name already exists'};
1824 # goto VPNCONF_ERROR;
1830 my $key = $cgiparams { 'KEY' };
1832 $key = & General
:: findhasharraykey
( \
%confighash );
1833 foreach my $i ( 0 .. 38 ) { $confighash { $key }[ $i ] = "" ;}
1835 $confighash { $key }[ 0 ] = $cgiparams { 'ENABLED' };
1836 $confighash { $key }[ 1 ] = $cgiparams { 'NAME' };
1837 if ((! $cgiparams { 'KEY' }) && $cgiparams { 'AUTH' } ne 'psk' ) {
1838 $confighash { $key }[ 2 ] = $cgiparams { 'CERT_NAME' };
1840 $confighash { $key }[ 3 ] = $cgiparams { 'TYPE' };
1841 if ( $cgiparams { 'AUTH' } eq 'psk' ) {
1842 $confighash { $key }[ 4 ] = 'psk' ;
1843 $confighash { $key }[ 5 ] = $cgiparams { 'PSK' };
1845 $confighash { $key }[ 4 ] = 'cert' ;
1847 if ( $cgiparams { 'TYPE' } eq 'net' ) {
1848 my @remote_subnets = split ( "," , $cgiparams { 'REMOTE_SUBNET' });
1849 $confighash { $key }[ 11 ] = join ( '|' , @remote_subnets );
1851 $confighash { $key }[ 7 ] = $cgiparams { 'LOCAL_ID' };
1852 my @local_subnets = split ( "," , $cgiparams { 'LOCAL_SUBNET' });
1853 $confighash { $key }[ 8 ] = join ( '|' , @local_subnets );
1854 $confighash { $key }[ 9 ] = $cgiparams { 'REMOTE_ID' };
1855 $confighash { $key }[ 10 ] = $cgiparams { 'REMOTE' };
1856 $confighash { $key }[ 25 ] = $cgiparams { 'REMARK' };
1857 $confighash { $key }[ 26 ] = "" ; # Formerly INTERFACE
1858 $confighash { $key }[ 27 ] = $cgiparams { 'DPD_ACTION' };
1859 $confighash { $key }[ 29 ] = $cgiparams { 'IKE_VERSION' };
1861 # don't forget advanced value
1862 $confighash { $key }[ 18 ] = $cgiparams { 'IKE_ENCRYPTION' };
1863 $confighash { $key }[ 19 ] = $cgiparams { 'IKE_INTEGRITY' };
1864 $confighash { $key }[ 20 ] = $cgiparams { 'IKE_GROUPTYPE' };
1865 $confighash { $key }[ 16 ] = $cgiparams { 'IKE_LIFETIME' };
1866 $confighash { $key }[ 21 ] = $cgiparams { 'ESP_ENCRYPTION' };
1867 $confighash { $key }[ 22 ] = $cgiparams { 'ESP_INTEGRITY' };
1868 $confighash { $key }[ 23 ] = $cgiparams { 'ESP_GROUPTYPE' };
1869 $confighash { $key }[ 17 ] = $cgiparams { 'ESP_KEYLIFE' };
1870 $confighash { $key }[ 12 ] = 'off' ; # $cgiparams{'AGGRMODE'};
1871 $confighash { $key }[ 13 ] = $cgiparams { 'COMPRESSION' };
1872 $confighash { $key }[ 24 ] = $cgiparams { 'ONLY_PROPOSED' };
1873 $confighash { $key }[ 28 ] = $cgiparams { 'PFS' };
1874 $confighash { $key }[ 30 ] = $cgiparams { 'DPD_TIMEOUT' };
1875 $confighash { $key }[ 31 ] = $cgiparams { 'DPD_DELAY' };
1876 $confighash { $key }[ 32 ] = $cgiparams { 'FORCE_MOBIKE' };
1877 $confighash { $key }[ 34 ] = $cgiparams { 'INACTIVITY_TIMEOUT' };
1878 $confighash { $key }[ 35 ] = $cgiparams { 'MODE' };
1879 $confighash { $key }[ 36 ] = $cgiparams { 'INTERFACE_MODE' };
1880 $confighash { $key }[ 37 ] = $cgiparams { 'INTERFACE_ADDRESS' };
1881 $confighash { $key }[ 38 ] = $cgiparams { 'INTERFACE_MTU' };
1883 # free unused fields!
1884 $confighash { $key }[ 6 ] = 'off' ;
1885 $confighash { $key }[ 15 ] = 'off' ;
1887 & General
:: writehasharray
( "${General::swroot}/vpn/config" , \
%confighash );
1890 system ( '/usr/local/bin/ipsecctrl' , 'S' , $key );
1893 if ( $cgiparams { 'EDIT_ADVANCED' } eq 'on' ) {
1894 $cgiparams { 'KEY' } = $key ;
1895 $cgiparams { 'ACTION' } = $Lang :: tr
{ 'advanced' };
1898 } else { # add new connection
1899 $cgiparams { 'ENABLED' } = 'on' ;
1900 if ( ! - f
"${General::swroot}/private/cakey.pem" ) {
1901 $cgiparams { 'AUTH' } = 'psk' ;
1902 } elsif ( ! - f
"${General::swroot}/ca/cacert.pem" ) {
1903 $cgiparams { 'AUTH' } = 'certfile' ;
1905 $cgiparams { 'AUTH' } = 'certgen' ;
1907 $cgiparams { 'LOCAL_SUBNET' } = " $netsettings {'GREEN_NETADDRESS'}/ $netsettings {'GREEN_NETMASK'}" ;
1908 $cgiparams { 'CERT_EMAIL' } = $vpnsettings { 'ROOTCERT_EMAIL' };
1909 $cgiparams { 'CERT_OU' } = $vpnsettings { 'ROOTCERT_OU' };
1910 $cgiparams { 'CERT_ORGANIZATION' } = $vpnsettings { 'ROOTCERT_ORGANIZATION' };
1911 $cgiparams { 'CERT_CITY' } = $vpnsettings { 'ROOTCERT_CITY' };
1912 $cgiparams { 'CERT_STATE' } = $vpnsettings { 'ROOTCERT_STATE' };
1913 $cgiparams { 'CERT_COUNTRY' } = $vpnsettings { 'ROOTCERT_COUNTRY' };
1915 # choose appropriate dpd action
1916 if ( $cgiparams { 'TYPE' } eq 'host' ) {
1917 $cgiparams { 'DPD_ACTION' } = 'clear' ;
1919 $cgiparams { 'DPD_ACTION' } = 'restart' ;
1922 if (! $cgiparams { 'DPD_DELAY' }) {
1923 $cgiparams { 'DPD_DELAY' } = 30 ;
1926 if (! $cgiparams { 'DPD_TIMEOUT' }) {
1927 $cgiparams { 'DPD_TIMEOUT' } = 120 ;
1930 if (! $cgiparams { 'FORCE_MOBIKE' }) {
1931 $cgiparams { 'FORCE_MOBIKE' } = 'no' ;
1934 # Default IKE Version to v2
1935 if (! $cgiparams { 'IKE_VERSION' }) {
1936 $cgiparams { 'IKE_VERSION' } = 'ikev2' ;
1940 $cgiparams { 'LOCAL_ID' } = '' ;
1941 $cgiparams { 'REMOTE_ID' } = '' ;
1943 #use default advanced value
1944 $cgiparams { 'IKE_ENCRYPTION' } = 'chacha20poly1305|aes256gcm128|aes256gcm96|aes256gcm64|aes256|aes192gcm128|aes192gcm96|aes192gcm64|aes192|aes128gcm128|aes128gcm96|aes128gcm64|aes128' ; #[18];
1945 $cgiparams { 'IKE_INTEGRITY' } = 'sha2_512|sha2_256' ; #[19];
1946 $cgiparams { 'IKE_GROUPTYPE' } = 'curve25519|4096|3072|2048' ; #[20];
1947 $cgiparams { 'IKE_LIFETIME' } = '3' ; #[16];
1948 $cgiparams { 'ESP_ENCRYPTION' } = 'chacha20poly1305|aes256gcm128|aes256gcm96|aes256gcm64|aes256|aes192gcm128|aes192gcm96|aes192gcm64|aes192|aes128gcm128|aes128gcm96|aes128gcm64|aes128' ; #[21];
1949 $cgiparams { 'ESP_INTEGRITY' } = 'sha2_512|sha2_256' ; #[22];
1950 $cgiparams { 'ESP_GROUPTYPE' } = 'curve25519|4096|3072|2048' ; #[23];
1951 $cgiparams { 'ESP_KEYLIFE' } = '1' ; #[17];
1952 $cgiparams { 'COMPRESSION' } = 'off' ; #[13];
1953 $cgiparams { 'ONLY_PROPOSED' } = 'on' ; #[24];
1954 $cgiparams { 'PFS' } = 'on' ; #[28];
1955 $cgiparams { 'INACTIVITY_TIMEOUT' } = 900 ;
1956 $cgiparams { 'MODE' } = "tunnel" ;
1957 $cgiparams { 'INTERFACE_MODE' } = "" ;
1958 $cgiparams { 'INTERFACE_ADDRESS' } = "" ;
1959 $cgiparams { 'INTERFACE_MTU' } = 1500 ;
1963 $checked { 'ENABLED' }{ 'off' } = '' ;
1964 $checked { 'ENABLED' }{ 'on' } = '' ;
1965 $checked { 'ENABLED' }{ $cgiparams { 'ENABLED' }} = "checked='checked'" ;
1967 $checked { 'EDIT_ADVANCED' }{ 'off' } = '' ;
1968 $checked { 'EDIT_ADVANCED' }{ 'on' } = '' ;
1969 $checked { 'EDIT_ADVANCED' }{ $cgiparams { 'EDIT_ADVANCED' }} = "checked='checked'" ;
1971 $checked { 'AUTH' }{ 'psk' } = '' ;
1972 $checked { 'AUTH' }{ 'certreq' } = '' ;
1973 $checked { 'AUTH' }{ 'certgen' } = '' ;
1974 $checked { 'AUTH' }{ 'certfile' } = '' ;
1975 $checked { 'AUTH' }{ 'pkcs12' } = '' ;
1976 $checked { 'AUTH' }{ 'auth-dn' } = '' ;
1977 $checked { 'AUTH' }{ $cgiparams { 'AUTH' }} = "checked='checked'" ;
1979 & Header
:: showhttpheaders
();
1980 & Header
:: openpage
( $Lang :: tr
{ 'ipsec' }, 1 , '' );
1981 & Header
:: openbigbox
( '100%' , 'left' , '' , $errormessage );
1982 if ( $errormessage ) {
1983 & Header
:: openbox
( '100%' , 'left' , $Lang :: tr
{ 'error messages' });
1984 print "<class name='base'> $errormessage " ;
1985 print " </class>" ;
1986 & Header
:: closebox
();
1990 & Header
:: openbox
( '100%' , 'left' , " $Lang ::tr{'warning messages'}:" );
1991 print "<class name='base'> $warnmessage " ;
1992 print " </class>" ;
1993 & Header
:: closebox
();
1996 print "<form method='post' enctype='multipart/form-data' action=' $ENV {'SCRIPT_NAME'}'>" ;
1998 <input type='hidden' name='TYPE' value=' $cgiparams {'TYPE'}' />
1999 <input type='hidden' name='IKE_VERSION' value=' $cgiparams {'IKE_VERSION'}' />
2000 <input type='hidden' name='IKE_ENCRYPTION' value=' $cgiparams {'IKE_ENCRYPTION'}' />
2001 <input type='hidden' name='IKE_INTEGRITY' value=' $cgiparams {'IKE_INTEGRITY'}' />
2002 <input type='hidden' name='IKE_GROUPTYPE' value=' $cgiparams {'IKE_GROUPTYPE'}' />
2003 <input type='hidden' name='IKE_LIFETIME' value=' $cgiparams {'IKE_LIFETIME'}' />
2004 <input type='hidden' name='ESP_ENCRYPTION' value=' $cgiparams {'ESP_ENCRYPTION'}' />
2005 <input type='hidden' name='ESP_INTEGRITY' value=' $cgiparams {'ESP_INTEGRITY'}' />
2006 <input type='hidden' name='ESP_GROUPTYPE' value=' $cgiparams {'ESP_GROUPTYPE'}' />
2007 <input type='hidden' name='ESP_KEYLIFE' value=' $cgiparams {'ESP_KEYLIFE'}' />
2008 <input type='hidden' name='COMPRESSION' value=' $cgiparams {'COMPRESSION'}' />
2009 <input type='hidden' name='ONLY_PROPOSED' value=' $cgiparams {'ONLY_PROPOSED'}' />
2010 <input type='hidden' name='PFS' value=' $cgiparams {'PFS'}' />
2011 <input type='hidden' name='DPD_ACTION' value=' $cgiparams {'DPD_ACTION'}' />
2012 <input type='hidden' name='DPD_DELAY' value=' $cgiparams {'DPD_DELAY'}' />
2013 <input type='hidden' name='DPD_TIMEOUT' value=' $cgiparams {'DPD_TIMEOUT'}' />
2014 <input type='hidden' name='FORCE_MOBIKE' value=' $cgiparams {'FORCE_MOBIKE'}' />
2015 <input type='hidden' name='INACTIVITY_TIMEOUT' value=' $cgiparams {'INACTIVITY_TIMEOUT'}' />
2016 <input type='hidden' name='MODE' value=' $cgiparams {'MODE'}' />
2017 <input type='hidden' name='INTERFACE_MODE' value=' $cgiparams {'INTERFACE_MODE'}' />
2018 <input type='hidden' name='INTERFACE_ADDRESS' value=' $cgiparams {'INTERFACE_ADDRESS'}' />
2019 <input type='hidden' name='INTERFACE_MTU' value=' $cgiparams {'INTERFACE_MTU'}' />
2022 if ( $cgiparams { 'KEY' }) {
2023 print "<input type='hidden' name='KEY' value=' $cgiparams {'KEY'}' />" ;
2024 print "<input type='hidden' name='NAME' value=' $cgiparams {'NAME'}' />" ;
2025 print "<input type='hidden' name='AUTH' value=' $cgiparams {'AUTH'}' />" ;
2028 & Header
:: openbox
( '100%' , 'left' , " $Lang ::tr{'connection'}: $cgiparams {'NAME'}" );
2029 print "<table width='100%'>" ;
2030 if (! $cgiparams { 'KEY' }) {
2033 <td width='20%'> $Lang ::tr{'name'}: <img src='/blob.gif' alt='*' /></td>
2035 <input type='text' name='NAME' value=' $cgiparams {'NAME'}' size='25' />
2037 <td colspan="2"></td>
2044 if ( $cgiparams { 'TYPE' } eq 'host' ) {
2045 $disabled = "disabled='disabled'" ;
2046 } elsif ( $cgiparams { 'TYPE' } eq 'net' ) {
2047 $blob = "<img src='/blob.gif' alt='*' />" ;
2050 my @local_subnets = split ( /\|/ , $cgiparams { 'LOCAL_SUBNET' });
2051 my $local_subnets = join ( "," , @local_subnets );
2053 my @remote_subnets = split ( /\|/ , $cgiparams { 'REMOTE_SUBNET' });
2054 my $remote_subnets = join ( "," , @remote_subnets );
2058 <td width='20%'> $Lang ::tr{'enabled'}</td>
2060 <input type='checkbox' name='ENABLED' $checked {'ENABLED'}{'on'} />
2062 <td class='boldbase' nowrap='nowrap' width='20%'> $Lang ::tr{'local subnet'} <img src='/blob.gif' alt='*' /></td>
2064 <input type='text' name='LOCAL_SUBNET' value=' $local_subnets ' />
2068 <td class='boldbase' width='20%'> $Lang ::tr{'remote host/ip'}: $blob </td>
2070 <input type='text' name='REMOTE' value=' $cgiparams {'REMOTE'}' size="25" />
2072 <td class='boldbase' nowrap='nowrap' width='20%'> $Lang ::tr{'remote subnet'} $blob </td>
2074 <input $disabled type='text' name='REMOTE_SUBNET' value=' $remote_subnets ' />
2078 <td class='boldbase' width='20%'> $Lang ::tr{'vpn local id'}:</td>
2080 <input type='text' name='LOCAL_ID' value=' $cgiparams {'LOCAL_ID'}' size="25" />
2082 <td class='boldbase' width='20%'> $Lang ::tr{'vpn remote id'}:</td>
2084 <input type='text' name='REMOTE_ID' value=' $cgiparams {'REMOTE_ID'}' size="25" />
2087 <tr><td colspan="4"><br /></td></tr>
2089 <td class='boldbase' width='20%'> $Lang ::tr{'remark title'}</td>
2091 <input type='text' name='REMARK' value=' $cgiparams {'REMARK'}' maxlength='50' size="73" />
2096 if (! $cgiparams { 'KEY' }) {
2097 print "<tr><td colspan='3'><input type='checkbox' name='EDIT_ADVANCED' $checked {'EDIT_ADVANCED'}{'on'} /> $Lang ::tr{'edit advanced settings when done'}</td></tr>" ;
2100 & Header
:: closebox
();
2102 if ( $cgiparams { 'KEY' } && $cgiparams { 'AUTH' } eq 'psk' ) {
2103 & Header
:: openbox
( '100%' , 'left' , $Lang :: tr
{ 'authentication' });
2105 <table width='100%' cellpadding='0' cellspacing='5' border='0'>
2106 <tr><td class='base' width='50%'> $Lang ::tr{'use a pre-shared key'}</td>
2107 <td class='base' width='50%'><input type='password' name='PSK' size='30' value=' $cgiparams {'PSK'}' /></td>
2112 & Header
:: closebox
();
2113 } elsif (! $cgiparams { 'KEY' }) {
2114 my $cakeydisabled = ( ! - f
"${General::swroot}/private/cakey.pem" ) ?
"disabled='disabled'" : '' ;
2115 $cgiparams { 'CERT_NAME' } = $Lang :: tr
{ 'vpn no full pki' } if ( $cakeydisabled );
2116 my $cacrtdisabled = ( ! - f
"${General::swroot}/ca/cacert.pem" ) ?
"disabled='disabled'" : '' ;
2118 & Header
:: openbox
( '100%' , 'left' , $Lang :: tr
{ 'authentication' });
2120 <table width='100%' cellpadding='0' cellspacing='5' border='0'>
2121 <tr><td width='5%'><input type='radio' name='AUTH' value='psk' $checked {'AUTH'}{'psk'} /></td>
2122 <td class='base' width='55%'> $Lang ::tr{'use a pre-shared key'}</td>
2123 <td class='base' width='40%'><input type='password' name='PSK' size='30' value=' $cgiparams {'PSK'}' /></td></tr>
2124 <tr><td colspan='3' bgcolor='#000000'></td></tr>
2125 <tr><td><input type='radio' name='AUTH' value='certreq' $checked {'AUTH'}{'certreq'} $cakeydisabled /></td>
2126 <td class='base'><hr /> $Lang ::tr{'upload a certificate request'}</td>
2127 <td class='base' rowspan='3' valign='middle'><input type='file' name='FH' size='30' $cacrtdisabled /></td></tr>
2128 <tr><td><input type='radio' name='AUTH' value='certfile' $checked {'AUTH'}{'certfile'} $cacrtdisabled /></td>
2129 <td class='base'> $Lang ::tr{'upload a certificate'}</td></tr>
2130 <tr><td><input type='radio' name='AUTH' value='pkcs12' $cacrtdisabled /></td>
2131 <td class='base'> $Lang ::tr{'upload p12 file'} $Lang ::tr{'pkcs12 file password'}:<input type='password' name='P12_PASS'/></td></tr>
2132 <tr><td><input type='radio' name='AUTH' value='auth-dn' $checked {'AUTH'}{'auth-dn'} $cacrtdisabled /></td>
2133 <td class='base'><hr /> $Lang ::tr{'vpn auth-dn'}</td></tr>
2134 <tr><td colspan='3' bgcolor='#000000'></td></tr>
2135 <tr><td><input type='radio' name='AUTH' value='certgen' $checked {'AUTH'}{'certgen'} $cakeydisabled /></td>
2136 <td class='base'><hr /> $Lang ::tr{'generate a certificate'}</td><td> </td></tr>
2138 <td class='base'> $Lang ::tr{'users fullname or system hostname'}: <img src='/blob.gif' alt='*' /></td>
2139 <td class='base' nowrap='nowrap'><input type='text' name='CERT_NAME' value=' $cgiparams {'CERT_NAME'}' size='32' $cakeydisabled /></td></tr>
2141 <td class='base'> $Lang ::tr{'users email'}:</td>
2142 <td class='base' nowrap='nowrap'><input type='text' name='CERT_EMAIL' value=' $cgiparams {'CERT_EMAIL'}' size='32' $cakeydisabled /></td></tr>
2144 <td class='base'> $Lang ::tr{'users department'}:</td>
2145 <td class='base' nowrap='nowrap'><input type='text' name='CERT_OU' value=' $cgiparams {'CERT_OU'}' size='32' $cakeydisabled /></td></tr>
2147 <td class='base'> $Lang ::tr{'organization name'}: <img src='/blob.gif' alt='*' /></td>
2148 <td class='base' nowrap='nowrap'><input type='text' name='CERT_ORGANIZATION' value=' $cgiparams {'CERT_ORGANIZATION'}' size='32' $cakeydisabled /></td></tr>
2150 <td class='base'> $Lang ::tr{'city'}:</td>
2151 <td class='base' nowrap='nowrap'><input type='text' name='CERT_CITY' value=' $cgiparams {'CERT_CITY'}' size='32' $cakeydisabled /></td></tr>
2153 <td class='base'> $Lang ::tr{'state or province'}:</td>
2154 <td class='base' nowrap='nowrap'><input type='text' name='CERT_STATE' value=' $cgiparams {'CERT_STATE'}' size='32' $cakeydisabled /></td></tr>
2156 <td class='base'> $Lang ::tr{'country'}:</td>
2157 <td class='base'><select name='CERT_COUNTRY' $cakeydisabled >
2160 foreach my $country ( sort keys %{ Countries
:: countries
}) {
2161 print " \t\t\t <option value=' $Countries ::countries{ $country }'" ;
2162 if ( $Countries :: countries
{ $country } eq $cgiparams { 'CERT_COUNTRY' } ) {
2163 print " selected='selected'" ;
2165 print "> $country </option> \n " ;
2170 <tr><td> </td><td class='base'> $Lang ::tr{'vpn subjectaltname'} (subjectAltName=email:*,URI:*,DNS:*,RID:*)</td>
2171 <td class='base' nowrap='nowrap'><input type='text' name='SUBJECTALTNAME' value=' $cgiparams {'SUBJECTALTNAME'}' size='32' $cakeydisabled /></td></tr>
2173 <td class='base'> $Lang ::tr{'pkcs12 file password'}: <img src='/blob.gif' alt='*' /></td>
2174 <td class='base' nowrap='nowrap'><input type='password' name='CERT_PASS1' value=' $cgiparams {'CERT_PASS1'}' size='32' $cakeydisabled /></td></tr>
2175 <tr><td> </td><td class='base'> $Lang ::tr{'pkcs12 file password'} ( $Lang ::tr{'confirmation'}): <img src='/blob.gif' alt='*' /></td>
2176 <td class='base' nowrap='nowrap'><input type='password' name='CERT_PASS2' value=' $cgiparams {'CERT_PASS2'}' size='32' $cakeydisabled /></td></tr>
2180 & Header
:: closebox
();
2183 print "<div align='center'><input type='submit' name='ACTION' value=' $Lang ::tr{'save'}' />" ;
2184 if ( $cgiparams { 'KEY' }) {
2185 print "<input type='submit' name='ACTION' value=' $Lang ::tr{'advanced'}' />" ;
2187 print "<input type='submit' name='ACTION' value=' $Lang ::tr{'cancel'}' /></div></form>" ;
2188 & Header
:: closebigbox
();
2189 & Header
:: closepage
();
2196 ### Advanced settings
2198 if (( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'advanced' }) ||
2199 ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'save' } && $cgiparams { 'ADVANCED' } eq 'yes' )) {
2200 & General
:: readhash
( "${General::swroot}/vpn/settings" , \
%vpnsettings );
2201 & General
:: readhasharray
( "${General::swroot}/vpn/config" , \
%confighash );
2202 if (! $confighash { $cgiparams { 'KEY' }}) {
2203 $errormessage = $Lang :: tr
{ 'invalid key' };
2207 if ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'save' }) {
2208 my @temp = split ( '\|' , $cgiparams { 'IKE_ENCRYPTION' });
2210 $errormessage = $Lang :: tr
{ 'invalid input' };
2211 goto ADVANCED_ERROR
;
2213 foreach my $val ( @temp ) {
2214 if ( $val !~ /^(aes(256|192|128)(gcm(128|96|64))?|3des|chacha20poly1305|camellia(256|192|128))$/ ) {
2215 $errormessage = $Lang :: tr
{ 'invalid input' };
2216 goto ADVANCED_ERROR
;
2219 @temp = split ( '\|' , $cgiparams { 'IKE_INTEGRITY' });
2221 $errormessage = $Lang :: tr
{ 'invalid input' };
2222 goto ADVANCED_ERROR
;
2224 foreach my $val ( @temp ) {
2225 if ( $val !~ /^(sha2_(512|384|256)|sha|md5|aesxcbc)$/ ) {
2226 $errormessage = $Lang :: tr
{ 'invalid input' };
2227 goto ADVANCED_ERROR
;
2230 @temp = split ( '\|' , $cgiparams { 'IKE_GROUPTYPE' });
2232 $errormessage = $Lang :: tr
{ 'invalid input' };
2233 goto ADVANCED_ERROR
;
2235 foreach my $val ( @temp ) {
2236 if ( $val !~ /^(curve25519|e521|e384|e256|e224|e192|e512bp|e384bp|e256bp|e224bp|768|1024|1536|2048|3072|4096|6144|8192)$/ ) {
2237 $errormessage = $Lang :: tr
{ 'invalid input' };
2238 goto ADVANCED_ERROR
;
2241 if ( $cgiparams { 'IKE_LIFETIME' } !~ /^\d+$/ ) {
2242 $errormessage = $Lang :: tr
{ 'invalid input for ike lifetime' };
2243 goto ADVANCED_ERROR
;
2245 if ( $cgiparams { 'IKE_LIFETIME' } < 1 || $cgiparams { 'IKE_LIFETIME' } > 8 ) {
2246 $errormessage = $Lang :: tr
{ 'ike lifetime should be between 1 and 8 hours' };
2247 goto ADVANCED_ERROR
;
2249 @temp = split ( '\|' , $cgiparams { 'ESP_ENCRYPTION' });
2251 $errormessage = $Lang :: tr
{ 'invalid input' };
2252 goto ADVANCED_ERROR
;
2254 foreach my $val ( @temp ) {
2255 if ( $val !~ /^(aes(256|192|128)(gcm(128|96|64))?|3des|chacha20poly1305|camellia(256|192|128))$/ ) {
2256 $errormessage = $Lang :: tr
{ 'invalid input' };
2257 goto ADVANCED_ERROR
;
2260 @temp = split ( '\|' , $cgiparams { 'ESP_INTEGRITY' });
2262 $errormessage = $Lang :: tr
{ 'invalid input' };
2263 goto ADVANCED_ERROR
;
2265 foreach my $val ( @temp ) {
2266 if ( $val !~ /^(sha2_(512|384|256)|sha1|md5|aesxcbc)$/ ) {
2267 $errormessage = $Lang :: tr
{ 'invalid input' };
2268 goto ADVANCED_ERROR
;
2271 @temp = split ( '\|' , $cgiparams { 'ESP_GROUPTYPE' });
2273 $errormessage = $Lang :: tr
{ 'invalid input' };
2274 goto ADVANCED_ERROR
;
2276 foreach my $val ( @temp ) {
2277 if ( $val !~ /^(curve25519|e521|e384|e256|e224|e192|e512bp|e384bp|e256bp|e224bp|768|1024|1536|2048|3072|4096|6144|8192|none)$/ ) {
2278 $errormessage = $Lang :: tr
{ 'invalid input' };
2279 goto ADVANCED_ERROR
;
2282 if ( $cgiparams { 'ESP_KEYLIFE' } !~ /^\d+$/ ) {
2283 $errormessage = $Lang :: tr
{ 'invalid input for esp keylife' };
2284 goto ADVANCED_ERROR
;
2286 if ( $cgiparams { 'ESP_KEYLIFE' } < 1 || $cgiparams { 'ESP_KEYLIFE' } > 24 ) {
2287 $errormessage = $Lang :: tr
{ 'esp keylife should be between 1 and 24 hours' };
2288 goto ADVANCED_ERROR
;
2291 if (( $cgiparams { 'COMPRESSION' } !~ /^(|on|off)$/ ) ||
2292 ( $cgiparams { 'FORCE_MOBIKE' } !~ /^(|on|off)$/ ) ||
2293 ( $cgiparams { 'ONLY_PROPOSED' } !~ /^(|on|off)$/ ) ||
2294 ( $cgiparams { 'PFS' } !~ /^(|on|off)$/ )) {
2295 $errormessage = $Lang :: tr
{ 'invalid input' };
2296 goto ADVANCED_ERROR
;
2299 if ( $cgiparams { 'DPD_DELAY' } !~ /^\d+$/ ) {
2300 $errormessage = $Lang :: tr
{ 'invalid input for dpd delay' };
2301 goto ADVANCED_ERROR
;
2304 if ( $cgiparams { 'DPD_TIMEOUT' } !~ /^\d+$/ ) {
2305 $errormessage = $Lang :: tr
{ 'invalid input for dpd timeout' };
2306 goto ADVANCED_ERROR
;
2309 if ( $cgiparams { 'INACTIVITY_TIMEOUT' } !~ /^\d+$/ ) {
2310 $errormessage = $Lang :: tr
{ 'invalid input for inactivity timeout' };
2311 goto ADVANCED_ERROR
;
2314 if ( $cgiparams { 'MODE' } !~ /^(tunnel|transport)$/ ) {
2315 $errormessage = $Lang :: tr
{ 'invalid input for mode' };
2316 goto ADVANCED_ERROR
;
2319 if ( $cgiparams { 'INTERFACE_MODE' } !~ /^(|gre|vti)$/ ) {
2320 $errormessage = $Lang :: tr
{ 'invalid input for interface mode' };
2321 goto ADVANCED_ERROR
;
2324 if (( $cgiparams { 'INTERFACE_MODE' } ne "" ) && !& Network
:: check_subnet
( $cgiparams { 'INTERFACE_ADDRESS' })) {
2325 $errormessage = $Lang :: tr
{ 'invalid input for interface address' };
2326 goto ADVANCED_ERROR
;
2329 if ( $cgiparams { 'INTERFACE_MTU' } !~ /^\d+$/ ) {
2330 $errormessage = $Lang :: tr
{ 'invalid input for interface mtu' };
2331 goto ADVANCED_ERROR
;
2334 $confighash { $cgiparams { 'KEY' }}[ 29 ] = $cgiparams { 'IKE_VERSION' };
2335 $confighash { $cgiparams { 'KEY' }}[ 18 ] = $cgiparams { 'IKE_ENCRYPTION' };
2336 $confighash { $cgiparams { 'KEY' }}[ 19 ] = $cgiparams { 'IKE_INTEGRITY' };
2337 $confighash { $cgiparams { 'KEY' }}[ 20 ] = $cgiparams { 'IKE_GROUPTYPE' };
2338 $confighash { $cgiparams { 'KEY' }}[ 16 ] = $cgiparams { 'IKE_LIFETIME' };
2339 $confighash { $cgiparams { 'KEY' }}[ 21 ] = $cgiparams { 'ESP_ENCRYPTION' };
2340 $confighash { $cgiparams { 'KEY' }}[ 22 ] = $cgiparams { 'ESP_INTEGRITY' };
2341 $confighash { $cgiparams { 'KEY' }}[ 23 ] = $cgiparams { 'ESP_GROUPTYPE' };
2342 $confighash { $cgiparams { 'KEY' }}[ 17 ] = $cgiparams { 'ESP_KEYLIFE' };
2343 $confighash { $cgiparams { 'KEY' }}[ 12 ] = 'off' ; #$cgiparams{'AGGRMODE'};
2344 $confighash { $cgiparams { 'KEY' }}[ 13 ] = $cgiparams { 'COMPRESSION' };
2345 $confighash { $cgiparams { 'KEY' }}[ 24 ] = $cgiparams { 'ONLY_PROPOSED' };
2346 $confighash { $cgiparams { 'KEY' }}[ 28 ] = $cgiparams { 'PFS' };
2347 $confighash { $cgiparams { 'KEY' }}[ 27 ] = $cgiparams { 'DPD_ACTION' };
2348 $confighash { $cgiparams { 'KEY' }}[ 30 ] = $cgiparams { 'DPD_TIMEOUT' };
2349 $confighash { $cgiparams { 'KEY' }}[ 31 ] = $cgiparams { 'DPD_DELAY' };
2350 $confighash { $cgiparams { 'KEY' }}[ 32 ] = $cgiparams { 'FORCE_MOBIKE' };
2351 $confighash { $cgiparams { 'KEY' }}[ 33 ] = $cgiparams { 'START_ACTION' };
2352 $confighash { $cgiparams { 'KEY' }}[ 34 ] = $cgiparams { 'INACTIVITY_TIMEOUT' };
2353 $confighash { $cgiparams { 'KEY' }}[ 35 ] = $cgiparams { 'MODE' };
2354 $confighash { $cgiparams { 'KEY' }}[ 36 ] = $cgiparams { 'INTERFACE_MODE' };
2355 $confighash { $cgiparams { 'KEY' }}[ 37 ] = $cgiparams { 'INTERFACE_ADDRESS' };
2356 $confighash { $cgiparams { 'KEY' }}[ 38 ] = $cgiparams { 'INTERFACE_MTU' };
2357 & General
:: writehasharray
( "${General::swroot}/vpn/config" , \
%confighash );
2360 system ( '/usr/local/bin/ipsecctrl' , 'S' , $cgiparams { 'KEY' });
2365 $cgiparams { 'IKE_VERSION' } = $confighash { $cgiparams { 'KEY' }}[ 29 ];
2366 $cgiparams { 'IKE_ENCRYPTION' } = $confighash { $cgiparams { 'KEY' }}[ 18 ];
2367 $cgiparams { 'IKE_INTEGRITY' } = $confighash { $cgiparams { 'KEY' }}[ 19 ];
2368 $cgiparams { 'IKE_GROUPTYPE' } = $confighash { $cgiparams { 'KEY' }}[ 20 ];
2369 $cgiparams { 'IKE_LIFETIME' } = $confighash { $cgiparams { 'KEY' }}[ 16 ];
2370 $cgiparams { 'ESP_ENCRYPTION' } = $confighash { $cgiparams { 'KEY' }}[ 21 ];
2371 $cgiparams { 'ESP_INTEGRITY' } = $confighash { $cgiparams { 'KEY' }}[ 22 ];
2372 $cgiparams { 'ESP_GROUPTYPE' } = $confighash { $cgiparams { 'KEY' }}[ 23 ];
2373 if ( $cgiparams { 'ESP_GROUPTYPE' } eq "" ) {
2374 $cgiparams { 'ESP_GROUPTYPE' } = $cgiparams { 'IKE_GROUPTYPE' };
2376 $cgiparams { 'ESP_KEYLIFE' } = $confighash { $cgiparams { 'KEY' }}[ 17 ];
2377 $cgiparams { 'COMPRESSION' } = $confighash { $cgiparams { 'KEY' }}[ 13 ];
2378 $cgiparams { 'ONLY_PROPOSED' } = $confighash { $cgiparams { 'KEY' }}[ 24 ];
2379 $cgiparams { 'PFS' } = $confighash { $cgiparams { 'KEY' }}[ 28 ];
2380 $cgiparams { 'DPD_ACTION' } = $confighash { $cgiparams { 'KEY' }}[ 27 ];
2381 $cgiparams { 'DPD_TIMEOUT' } = $confighash { $cgiparams { 'KEY' }}[ 30 ];
2382 $cgiparams { 'DPD_DELAY' } = $confighash { $cgiparams { 'KEY' }}[ 31 ];
2383 $cgiparams { 'FORCE_MOBIKE' } = $confighash { $cgiparams { 'KEY' }}[ 32 ];
2384 $cgiparams { 'START_ACTION' } = $confighash { $cgiparams { 'KEY' }}[ 33 ];
2385 $cgiparams { 'INACTIVITY_TIMEOUT' } = $confighash { $cgiparams { 'KEY' }}[ 34 ];
2386 $cgiparams { 'MODE' } = $confighash { $cgiparams { 'KEY' }}[ 35 ];
2387 $cgiparams { 'INTERFACE_MODE' } = $confighash { $cgiparams { 'KEY' }}[ 36 ];
2388 $cgiparams { 'INTERFACE_ADDRESS' } = $confighash { $cgiparams { 'KEY' }}[ 37 ];
2389 $cgiparams { 'INTERFACE_MTU' } = $confighash { $cgiparams { 'KEY' }}[ 38 ];
2391 if (! $cgiparams { 'DPD_DELAY' }) {
2392 $cgiparams { 'DPD_DELAY' } = 30 ;
2395 if (! $cgiparams { 'DPD_TIMEOUT' }) {
2396 $cgiparams { 'DPD_TIMEOUT' } = 120 ;
2399 if (! $cgiparams { 'START_ACTION' }) {
2400 $cgiparams { 'START_ACTION' } = "start" ;
2403 if ( $cgiparams { 'INACTIVITY_TIMEOUT' } eq "" ) {
2404 $cgiparams { 'INACTIVITY_TIMEOUT' } = 900 ; # 15 min
2407 if ( $cgiparams { 'MODE' } eq "" ) {
2408 $cgiparams { 'MODE' } = "tunnel" ;
2413 $checked { 'IKE_ENCRYPTION' }{ 'chacha20poly1305' } = '' ;
2414 $checked { 'IKE_ENCRYPTION' }{ 'aes256' } = '' ;
2415 $checked { 'IKE_ENCRYPTION' }{ 'aes192' } = '' ;
2416 $checked { 'IKE_ENCRYPTION' }{ 'aes128' } = '' ;
2417 $checked { 'IKE_ENCRYPTION' }{ 'aes256gcm128' } = '' ;
2418 $checked { 'IKE_ENCRYPTION' }{ 'aes192gcm128' } = '' ;
2419 $checked { 'IKE_ENCRYPTION' }{ 'aes128gcm128' } = '' ;
2420 $checked { 'IKE_ENCRYPTION' }{ 'aes256gcm96' } = '' ;
2421 $checked { 'IKE_ENCRYPTION' }{ 'aes192gcm96' } = '' ;
2422 $checked { 'IKE_ENCRYPTION' }{ 'aes128gcm96' } = '' ;
2423 $checked { 'IKE_ENCRYPTION' }{ 'aes256gcm64' } = '' ;
2424 $checked { 'IKE_ENCRYPTION' }{ 'aes192gcm64' } = '' ;
2425 $checked { 'IKE_ENCRYPTION' }{ 'aes128gcm64' } = '' ;
2426 $checked { 'IKE_ENCRYPTION' }{ '3des' } = '' ;
2427 $checked { 'IKE_ENCRYPTION' }{ 'camellia256' } = '' ;
2428 $checked { 'IKE_ENCRYPTION' }{ 'camellia192' } = '' ;
2429 $checked { 'IKE_ENCRYPTION' }{ 'camellia128' } = '' ;
2430 my @temp = split ( '\|' , $cgiparams { 'IKE_ENCRYPTION' });
2431 foreach my $key ( @temp ) { $checked { 'IKE_ENCRYPTION' }{ $key } = "selected='selected'" ; }
2432 $checked { 'IKE_INTEGRITY' }{ 'sha2_512' } = '' ;
2433 $checked { 'IKE_INTEGRITY' }{ 'sha2_384' } = '' ;
2434 $checked { 'IKE_INTEGRITY' }{ 'sha2_256' } = '' ;
2435 $checked { 'IKE_INTEGRITY' }{ 'sha' } = '' ;
2436 $checked { 'IKE_INTEGRITY' }{ 'md5' } = '' ;
2437 $checked { 'IKE_INTEGRITY' }{ 'aesxcbc' } = '' ;
2438 @temp = split ( '\|' , $cgiparams { 'IKE_INTEGRITY' });
2439 foreach my $key ( @temp ) { $checked { 'IKE_INTEGRITY' }{ $key } = "selected='selected'" ; }
2440 $checked { 'IKE_GROUPTYPE' }{ 'curve25519' } = '' ;
2441 $checked { 'IKE_GROUPTYPE' }{ '768' } = '' ;
2442 $checked { 'IKE_GROUPTYPE' }{ '1024' } = '' ;
2443 $checked { 'IKE_GROUPTYPE' }{ '1536' } = '' ;
2444 $checked { 'IKE_GROUPTYPE' }{ '2048' } = '' ;
2445 $checked { 'IKE_GROUPTYPE' }{ '3072' } = '' ;
2446 $checked { 'IKE_GROUPTYPE' }{ '4096' } = '' ;
2447 $checked { 'IKE_GROUPTYPE' }{ '6144' } = '' ;
2448 $checked { 'IKE_GROUPTYPE' }{ '8192' } = '' ;
2449 @temp = split ( '\|' , $cgiparams { 'IKE_GROUPTYPE' });
2450 foreach my $key ( @temp ) { $checked { 'IKE_GROUPTYPE' }{ $key } = "selected='selected'" ; }
2452 $checked { 'ESP_ENCRYPTION' }{ 'chacha20poly1305' } = '' ;
2453 $checked { 'ESP_ENCRYPTION' }{ 'aes256' } = '' ;
2454 $checked { 'ESP_ENCRYPTION' }{ 'aes192' } = '' ;
2455 $checked { 'ESP_ENCRYPTION' }{ 'aes128' } = '' ;
2456 $checked { 'ESP_ENCRYPTION' }{ 'aes256gcm128' } = '' ;
2457 $checked { 'ESP_ENCRYPTION' }{ 'aes192gcm128' } = '' ;
2458 $checked { 'ESP_ENCRYPTION' }{ 'aes128gcm128' } = '' ;
2459 $checked { 'ESP_ENCRYPTION' }{ 'aes256gcm96' } = '' ;
2460 $checked { 'ESP_ENCRYPTION' }{ 'aes192gcm96' } = '' ;
2461 $checked { 'ESP_ENCRYPTION' }{ 'aes128gcm96' } = '' ;
2462 $checked { 'ESP_ENCRYPTION' }{ 'aes256gcm64' } = '' ;
2463 $checked { 'ESP_ENCRYPTION' }{ 'aes192gcm64' } = '' ;
2464 $checked { 'ESP_ENCRYPTION' }{ 'aes128gcm64' } = '' ;
2465 $checked { 'ESP_ENCRYPTION' }{ '3des' } = '' ;
2466 $checked { 'ESP_ENCRYPTION' }{ 'camellia256' } = '' ;
2467 $checked { 'ESP_ENCRYPTION' }{ 'camellia192' } = '' ;
2468 $checked { 'ESP_ENCRYPTION' }{ 'camellia128' } = '' ;
2469 @temp = split ( '\|' , $cgiparams { 'ESP_ENCRYPTION' });
2470 foreach my $key ( @temp ) { $checked { 'ESP_ENCRYPTION' }{ $key } = "selected='selected'" ; }
2471 $checked { 'ESP_INTEGRITY' }{ 'sha2_512' } = '' ;
2472 $checked { 'ESP_INTEGRITY' }{ 'sha2_384' } = '' ;
2473 $checked { 'ESP_INTEGRITY' }{ 'sha2_256' } = '' ;
2474 $checked { 'ESP_INTEGRITY' }{ 'sha1' } = '' ;
2475 $checked { 'ESP_INTEGRITY' }{ 'md5' } = '' ;
2476 $checked { 'ESP_INTEGRITY' }{ 'aesxcbc' } = '' ;
2477 @temp = split ( '\|' , $cgiparams { 'ESP_INTEGRITY' });
2478 foreach my $key ( @temp ) { $checked { 'ESP_INTEGRITY' }{ $key } = "selected='selected'" ; }
2479 $checked { 'ESP_GROUPTYPE' }{ 'curve25519' } = '' ;
2480 $checked { 'ESP_GROUPTYPE' }{ '768' } = '' ;
2481 $checked { 'ESP_GROUPTYPE' }{ '1024' } = '' ;
2482 $checked { 'ESP_GROUPTYPE' }{ '1536' } = '' ;
2483 $checked { 'ESP_GROUPTYPE' }{ '2048' } = '' ;
2484 $checked { 'ESP_GROUPTYPE' }{ '3072' } = '' ;
2485 $checked { 'ESP_GROUPTYPE' }{ '4096' } = '' ;
2486 $checked { 'ESP_GROUPTYPE' }{ '6144' } = '' ;
2487 $checked { 'ESP_GROUPTYPE' }{ '8192' } = '' ;
2488 $checked { 'ESP_GROUPTYPE' }{ 'none' } = '' ;
2489 @temp = split ( '\|' , $cgiparams { 'ESP_GROUPTYPE' });
2490 foreach my $key ( @temp ) { $checked { 'ESP_GROUPTYPE' }{ $key } = "selected='selected'" ; }
2492 $checked { 'COMPRESSION' } = $cgiparams { 'COMPRESSION' } eq 'on' ?
"checked='checked'" : '' ;
2493 $checked { 'FORCE_MOBIKE' } = $cgiparams { 'FORCE_MOBIKE' } eq 'on' ?
"checked='checked'" : '' ;
2494 $checked { 'ONLY_PROPOSED' } = $cgiparams { 'ONLY_PROPOSED' } eq 'on' ?
"checked='checked'" : '' ;
2495 $checked { 'PFS' } = $cgiparams { 'PFS' } eq 'on' ?
"checked='checked'" : '' ;
2497 $selected { 'IKE_VERSION' }{ 'ikev1' } = '' ;
2498 $selected { 'IKE_VERSION' }{ 'ikev2' } = '' ;
2499 $selected { 'IKE_VERSION' }{ $cgiparams { 'IKE_VERSION' }} = "selected='selected'" ;
2501 $selected { 'DPD_ACTION' }{ 'clear' } = '' ;
2502 $selected { 'DPD_ACTION' }{ 'hold' } = '' ;
2503 $selected { 'DPD_ACTION' }{ 'restart' } = '' ;
2504 $selected { 'DPD_ACTION' }{ 'none' } = '' ;
2505 $selected { 'DPD_ACTION' }{ $cgiparams { 'DPD_ACTION' }} = "selected='selected'" ;
2507 $selected { 'START_ACTION' }{ 'add' } = '' ;
2508 $selected { 'START_ACTION' }{ 'route' } = '' ;
2509 $selected { 'START_ACTION' }{ 'start' } = '' ;
2510 $selected { 'START_ACTION' }{ $cgiparams { 'START_ACTION' }} = "selected='selected'" ;
2512 $selected { 'INACTIVITY_TIMEOUT' } = ();
2513 foreach my $timeout ( keys %INACTIVITY_TIMEOUTS ) {
2514 $selected { 'INACTIVITY_TIMEOUT' }{ $timeout } = "" ;
2516 $selected { 'INACTIVITY_TIMEOUT' }{ $cgiparams { 'INACTIVITY_TIMEOUT' }} = "selected" ;
2518 $selected { 'MODE' }{ 'tunnel' } = '' ;
2519 $selected { 'MODE' }{ 'transport' } = '' ;
2520 $selected { 'MODE' }{ $cgiparams { 'MODE' }} = "selected='selected'" ;
2522 $selected { 'INTERFACE_MODE' }{ '' } = '' ;
2523 $selected { 'INTERFACE_MODE' }{ 'gre' } = '' ;
2524 $selected { 'INTERFACE_MODE' }{ 'vti' } = '' ;
2525 $selected { 'INTERFACE_MODE' }{ $cgiparams { 'INTERFACE_MODE' }} = "selected='selected'" ;
2527 & Header
:: showhttpheaders
();
2528 & Header
:: openpage
( $Lang :: tr
{ 'ipsec' }, 1 , '' );
2529 & Header
:: openbigbox
( '100%' , 'left' , '' , $errormessage );
2531 if ( $errormessage ) {
2532 & Header
:: openbox
( '100%' , 'left' , $Lang :: tr
{ 'error messages' });
2533 print "<class name='base'> $errormessage " ;
2534 print " </class>" ;
2535 & Header
:: closebox
();
2539 & Header
:: openbox
( '100%' , 'left' , $Lang :: tr
{ 'warning messages' });
2540 print "<class name='base'> $warnmessage " ;
2541 print " </class>" ;
2542 & Header
:: closebox
();
2545 & Header
:: openbox
( '100%' , 'left' , " $Lang ::tr{'advanced'}:" );
2547 <form method='post' enctype='multipart/form-data' action=' $ENV {'SCRIPT_NAME'}'>
2548 <input type='hidden' name='ADVANCED' value='yes' />
2549 <input type='hidden' name='KEY' value=' $cgiparams {'KEY'}' />
2551 <table width="100%">
2554 <td width="15%"> $Lang ::tr{'mode'}:</td>
2556 <select name='MODE'>
2557 <option value='tunnel' $selected {'MODE'}{'tunnel'}> $Lang ::tr{'ipsec mode tunnel'}</option>
2558 <option value='transport' $selected {'MODE'}{'transport'}> $Lang ::tr{'ipsec mode transport'}</option>
2565 <td width="15%"> $Lang ::tr{'interface mode'}:</td>
2568 <select name='INTERFACE_MODE'>
2569 <option value='' $selected {'INTERFACE_MODE'}{''}> $Lang ::tr{'ipsec interface mode none'}</option>
2570 <option value='gre' $selected {'INTERFACE_MODE'}{'gre'}> $Lang ::tr{'ipsec interface mode gre'}</option>
2571 <option value='vti' $selected {'INTERFACE_MODE'}{'vti'}> $Lang ::tr{'ipsec interface mode vti'}</option>
2575 <label> $Lang ::tr{'ip address'}/ $Lang ::tr{'subnet mask'}</label>
2576 <input type="text" name="INTERFACE_ADDRESS" value=" $cgiparams {'INTERFACE_ADDRESS'}">
2579 <label> $Lang ::tr{'mtu'}</label>
2580 <input type="number" name="INTERFACE_MTU" value=" $cgiparams {'INTERFACE_MTU'}" min="576" max="9000">
2588 <h2> $Lang ::tr{'cryptographic settings'}</h2>
2590 <table width='100%'>
2593 <th width="15%"></th>
2600 <td> $Lang ::tr{'vpn keyexchange'}:</td>
2602 <select name='IKE_VERSION'>
2603 <option value='ikev2' $selected {'IKE_VERSION'}{'ikev2'}>IKEv2</option>
2604 <option value='ikev1' $selected {'IKE_VERSION'}{'ikev1'}>IKEv1</option>
2610 <td class='boldbase' width="15%"> $Lang ::tr{'encryption'}</td>
2611 <td class='boldbase'>
2612 <select name='IKE_ENCRYPTION' multiple='multiple' size='6' style='width: 100%'>
2613 <option value='chacha20poly1305' $checked {'IKE_ENCRYPTION'}{'chacha20poly1305'}>256 bit ChaCha20-Poly1305/128 bit ICV</option>
2614 <option value='aes256gcm128' $checked {'IKE_ENCRYPTION'}{'aes256gcm128'}>256 bit AES-GCM/128 bit ICV</option>
2615 <option value='aes256gcm96' $checked {'IKE_ENCRYPTION'}{'aes256gcm96'}>256 bit AES-GCM/96 bit ICV</option>
2616 <option value='aes256gcm64' $checked {'IKE_ENCRYPTION'}{'aes256gcm64'}>256 bit AES-GCM/64 bit ICV</option>
2617 <option value='aes256' $checked {'IKE_ENCRYPTION'}{'aes256'}>256 bit AES-CBC</option>
2618 <option value='camellia256' $checked {'IKE_ENCRYPTION'}{'camellia256'}>256 bit Camellia-CBC</option>
2619 <option value='aes192gcm128' $checked {'IKE_ENCRYPTION'}{'aes192gcm128'}>192 bit AES-GCM/128 bit ICV</option>
2620 <option value='aes192gcm96' $checked {'IKE_ENCRYPTION'}{'aes192gcm96'}>192 bit AES-GCM/96 bit ICV</option>
2621 <option value='aes192gcm64' $checked {'IKE_ENCRYPTION'}{'aes192gcm64'}>192 bit AES-GCM/64 bit ICV</option>
2622 <option value='aes192' $checked {'IKE_ENCRYPTION'}{'aes192'}>192 bit AES-CBC</option>
2623 <option value='camellia192' $checked {'IKE_ENCRYPTION'}{'camellia192'}>192 bit Camellia-CBC</option>
2624 <option value='aes128gcm128' $checked {'IKE_ENCRYPTION'}{'aes128gcm128'}>128 bit AES-GCM/128 bit ICV</option>
2625 <option value='aes128gcm96' $checked {'IKE_ENCRYPTION'}{'aes128gcm96'}>128 bit AES-GCM/96 bit ICV</option>
2626 <option value='aes128gcm64' $checked {'IKE_ENCRYPTION'}{'aes128gcm64'}>128 bit AES-GCM/64 bit ICV</option>
2627 <option value='aes128' $checked {'IKE_ENCRYPTION'}{'aes128'}>128 bit AES-CBC</option>
2628 <option value='camellia128' $checked {'IKE_ENCRYPTION'}{'camellia128'}>128 bit Camellia-CBC</option>
2629 <option value='3des' $checked {'IKE_ENCRYPTION'}{'3des'}>168 bit 3DES-EDE-CBC ( $Lang ::tr{'vpn weak'})</option>
2632 <td class='boldbase'>
2633 <select name='ESP_ENCRYPTION' multiple='multiple' size='6' style='width: 100%'>
2634 <option value='chacha20poly1305' $checked {'ESP_ENCRYPTION'}{'chacha20poly1305'}>256 bit ChaCha20-Poly1305/128 bit ICV</option>
2635 <option value='aes256gcm128' $checked {'ESP_ENCRYPTION'}{'aes256gcm128'}>256 bit AES-GCM/128 bit ICV</option>
2636 <option value='aes256gcm96' $checked {'ESP_ENCRYPTION'}{'aes256gcm96'}>256 bit AES-GCM/96 bit ICV</option>
2637 <option value='aes256gcm64' $checked {'ESP_ENCRYPTION'}{'aes256gcm64'}>256 bit AES-GCM/64 bit ICV</option>
2638 <option value='aes256' $checked {'ESP_ENCRYPTION'}{'aes256'}>256 bit AES-CBC</option>
2639 <option value='camellia256' $checked {'ESP_ENCRYPTION'}{'camellia256'}>256 bit Camellia-CBC</option>
2640 <option value='aes192gcm128' $checked {'ESP_ENCRYPTION'}{'aes192gcm128'}>192 bit AES-GCM/128 bit ICV</option>
2641 <option value='aes192gcm96' $checked {'ESP_ENCRYPTION'}{'aes192gcm96'}>192 bit AES-GCM/96 bit ICV</option>
2642 <option value='aes192gcm64' $checked {'ESP_ENCRYPTION'}{'aes192gcm64'}>192 bit AES-GCM/64 bit ICV</option>
2643 <option value='aes192' $checked {'ESP_ENCRYPTION'}{'aes192'}>192 bit AES-CBC</option>
2644 <option value='camellia192' $checked {'ESP_ENCRYPTION'}{'camellia192'}>192 bit Camellia-CBC</option>
2645 <option value='aes128gcm128' $checked {'ESP_ENCRYPTION'}{'aes128gcm128'}>128 bit AES-GCM/128 bit ICV</option>
2646 <option value='aes128gcm96' $checked {'ESP_ENCRYPTION'}{'aes128gcm96'}>128 bit AES-GCM/96 bit ICV</option>
2647 <option value='aes128gcm64' $checked {'ESP_ENCRYPTION'}{'aes128gcm64'}>128 bit AES-GCM/64 bit ICV</option>
2648 <option value='aes128' $checked {'ESP_ENCRYPTION'}{'aes128'}>128 bit AES-CBC</option>
2649 <option value='camellia128' $checked {'ESP_ENCRYPTION'}{'camellia128'}>128 bit Camellia-CBC</option>
2650 <option value='3des' $checked {'ESP_ENCRYPTION'}{'3des'}>168 bit 3DES-EDE-CBC ( $Lang ::tr{'vpn weak'})</option>
2656 <td class='boldbase' width="15%"> $Lang ::tr{'integrity'}</td>
2657 <td class='boldbase'>
2658 <select name='IKE_INTEGRITY' multiple='multiple' size='6' style='width: 100%'>
2659 <option value='sha2_512' $checked {'IKE_INTEGRITY'}{'sha2_512'}>SHA2 512 bit</option>
2660 <option value='sha2_384' $checked {'IKE_INTEGRITY'}{'sha2_384'}>SHA2 384 bit</option>
2661 <option value='sha2_256' $checked {'IKE_INTEGRITY'}{'sha2_256'}>SHA2 256 bit</option>
2662 <option value='aesxcbc' $checked {'IKE_INTEGRITY'}{'aesxcbc'}>AES XCBC</option>
2663 <option value='sha' $checked {'IKE_INTEGRITY'}{'sha'}>SHA1 ( $Lang ::tr{'vpn weak'})</option>
2664 <option value='md5' $checked {'IKE_INTEGRITY'}{'md5'}>MD5 ( $Lang ::tr{'vpn broken'})</option>
2667 <td class='boldbase'>
2668 <select name='ESP_INTEGRITY' multiple='multiple' size='6' style='width: 100%'>
2669 <option value='sha2_512' $checked {'ESP_INTEGRITY'}{'sha2_512'}>SHA2 512 bit</option>
2670 <option value='sha2_384' $checked {'ESP_INTEGRITY'}{'sha2_384'}>SHA2 384 bit</option>
2671 <option value='sha2_256' $checked {'ESP_INTEGRITY'}{'sha2_256'}>SHA2 256 bit</option>
2672 <option value='aesxcbc' $checked {'ESP_INTEGRITY'}{'aesxcbc'}>AES XCBC</option>
2673 <option value='sha1' $checked {'ESP_INTEGRITY'}{'sha1'}>SHA1 ( $Lang ::tr{'vpn weak'})</option>
2674 <option value='md5' $checked {'ESP_INTEGRITY'}{'md5'}>MD5 ( $Lang ::tr{'vpn broken'})</option>
2679 <td class='boldbase' width="15%"> $Lang ::tr{'lifetime'} <img src='/blob.gif' alt='*' /></td>
2680 <td class='boldbase'>
2681 <input type='text' name='IKE_LIFETIME' value=' $cgiparams {'IKE_LIFETIME'}' size='5' /> $Lang ::tr{'hours'}
2683 <td class='boldbase'>
2684 <input type='text' name='ESP_KEYLIFE' value=' $cgiparams {'ESP_KEYLIFE'}' size='5' /> $Lang ::tr{'hours'}
2688 <td class='boldbase' width="15%"> $Lang ::tr{'grouptype'}</td>
2689 <td class='boldbase'>
2690 <select name='IKE_GROUPTYPE' multiple='multiple' size='6' style='width: 100%'>
2691 <option value='curve25519' $checked {'IKE_GROUPTYPE'}{'curve25519'}>Curve 25519 (256 bit)</option>
2692 <option value='e521' $checked {'IKE_GROUPTYPE'}{'e521'}>ECP-521 (NIST)</option>
2693 <option value='e512bp' $checked {'IKE_GROUPTYPE'}{'e512bp'}>ECP-512 (Brainpool)</option>
2694 <option value='e384' $checked {'IKE_GROUPTYPE'}{'e384'}>ECP-384 (NIST)</option>
2695 <option value='e384bp' $checked {'IKE_GROUPTYPE'}{'e384bp'}>ECP-384 (Brainpool)</option>
2696 <option value='e256' $checked {'IKE_GROUPTYPE'}{'e256'}>ECP-256 (NIST)</option>
2697 <option value='e256bp' $checked {'IKE_GROUPTYPE'}{'e256bp'}>ECP-256 (Brainpool)</option>
2698 <option value='e224' $checked {'IKE_GROUPTYPE'}{'e224'}>ECP-224 (NIST)</option>
2699 <option value='e224bp' $checked {'IKE_GROUPTYPE'}{'e224bp'}>ECP-224 (Brainpool)</option>
2700 <option value='e192' $checked {'IKE_GROUPTYPE'}{'e192'}>ECP-192 (NIST)</option>
2701 <option value='8192' $checked {'IKE_GROUPTYPE'}{'8192'}>MODP-8192</option>
2702 <option value='6144' $checked {'IKE_GROUPTYPE'}{'6144'}>MODP-6144</option>
2703 <option value='4096' $checked {'IKE_GROUPTYPE'}{'4096'}>MODP-4096</option>
2704 <option value='3072' $checked {'IKE_GROUPTYPE'}{'3072'}>MODP-3072</option>
2705 <option value='2048' $checked {'IKE_GROUPTYPE'}{'2048'}>MODP-2048</option>
2706 <option value='1536' $checked {'IKE_GROUPTYPE'}{'1536'}>MODP-1536</option>
2707 <option value='1024' $checked {'IKE_GROUPTYPE'}{'1024'}>MODP-1024 ( $Lang ::tr{'vpn broken'})</option>
2708 <option value='768' $checked {'IKE_GROUPTYPE'}{'768'}>MODP-768 ( $Lang ::tr{'vpn broken'})</option>
2711 <td class='boldbase'>
2712 <select name='ESP_GROUPTYPE' multiple='multiple' size='6' style='width: 100%'>
2713 <option value='curve25519' $checked {'ESP_GROUPTYPE'}{'curve25519'}>Curve 25519 (256 bit)</option>
2714 <option value='e521' $checked {'ESP_GROUPTYPE'}{'e521'}>ECP-521 (NIST)</option>
2715 <option value='e512bp' $checked {'ESP_GROUPTYPE'}{'e512bp'}>ECP-512 (Brainpool)</option>
2716 <option value='e384' $checked {'ESP_GROUPTYPE'}{'e384'}>ECP-384 (NIST)</option>
2717 <option value='e384bp' $checked {'ESP_GROUPTYPE'}{'e384bp'}>ECP-384 (Brainpool)</option>
2718 <option value='e256' $checked {'ESP_GROUPTYPE'}{'e256'}>ECP-256 (NIST)</option>
2719 <option value='e256bp' $checked {'ESP_GROUPTYPE'}{'e256bp'}>ECP-256 (Brainpool)</option>
2720 <option value='e224' $checked {'ESP_GROUPTYPE'}{'e224'}>ECP-224 (NIST)</option>
2721 <option value='e224bp' $checked {'ESP_GROUPTYPE'}{'e224bp'}>ECP-224 (Brainpool)</option>
2722 <option value='e192' $checked {'ESP_GROUPTYPE'}{'e192'}>ECP-192 (NIST)</option>
2723 <option value='8192' $checked {'ESP_GROUPTYPE'}{'8192'}>MODP-8192</option>
2724 <option value='6144' $checked {'ESP_GROUPTYPE'}{'6144'}>MODP-6144</option>
2725 <option value='4096' $checked {'ESP_GROUPTYPE'}{'4096'}>MODP-4096</option>
2726 <option value='3072' $checked {'ESP_GROUPTYPE'}{'3072'}>MODP-3072</option>
2727 <option value='2048' $checked {'ESP_GROUPTYPE'}{'2048'}>MODP-2048</option>
2728 <option value='1536' $checked {'ESP_GROUPTYPE'}{'1536'}>MODP-1536</option>
2729 <option value='1024' $checked {'ESP_GROUPTYPE'}{'1024'}>MODP-1024 ( $Lang ::tr{'vpn broken'})</option>
2730 <option value='768' $checked {'ESP_GROUPTYPE'}{'768'}>MODP-768 ( $Lang ::tr{'vpn broken'})</option>
2731 <option value='none' $checked {'ESP_GROUPTYPE'}{'none'}>- $Lang ::tr{'none'} -</option>
2740 <h2> $Lang ::tr{'dead peer detection'}</h2>
2742 <table width="100%">
2744 <td width="15%"> $Lang ::tr{'dpd action'}:</td>
2746 <select name='DPD_ACTION'>
2747 <option value='none' $selected {'DPD_ACTION'}{'none'}>- $Lang ::tr{'disabled'} -</option>
2748 <option value='clear' $selected {'DPD_ACTION'}{'clear'}>clear</option>
2749 <option value='hold' $selected {'DPD_ACTION'}{'hold'}>hold</option>
2750 <option value='restart' $selected {'DPD_ACTION'}{'restart'}>restart</option>
2755 <td width="15%"> $Lang ::tr{'dpd timeout'}: <img src='/blob.gif' alt='*' /></td>
2757 <input type='text' name='DPD_TIMEOUT' size='5' value=' $cgiparams {'DPD_TIMEOUT'}' />
2761 <td width="15%"> $Lang ::tr{'dpd delay'}: <img src='/blob.gif' alt='*' /></td>
2763 <input type='text' name='DPD_DELAY' size='5' value=' $cgiparams {'DPD_DELAY'}' />
2770 <table width="100%">
2774 <input type='checkbox' name='ONLY_PROPOSED' $checked {'ONLY_PROPOSED'} />
2775 IKE+ESP: $Lang ::tr{'use only proposed settings'}
2779 <label> $Lang ::tr{'vpn start action'}</label>
2780 <select name="START_ACTION">
2781 <option value="route" $selected {'START_ACTION'}{'route'}> $Lang ::tr{'vpn start action route'}</option>
2782 <option value="start" $selected {'START_ACTION'}{'start'}> $Lang ::tr{'vpn start action start'}</option>
2783 <option value="add" $selected {'START_ACTION'}{'add'} > $Lang ::tr{'vpn start action add'}</option>
2790 <input type='checkbox' name='PFS' $checked {'PFS'} />
2791 $Lang ::tr{'pfs yes no'}
2795 <label> $Lang ::tr{'vpn inactivity timeout'}</label>
2796 <select name="INACTIVITY_TIMEOUT">
2798 foreach my $t ( sort { $a <=> $b } keys %INACTIVITY_TIMEOUTS ) {
2799 print "<option value= \" $t \" $selected {'INACTIVITY_TIMEOUT'}{ $t }> $INACTIVITY_TIMEOUTS { $t }</option> \n " ;
2810 <input type='checkbox' name='COMPRESSION' $checked {'COMPRESSION'} />
2811 $Lang ::tr{'vpn payload compression'}
2818 <input type='checkbox' name='FORCE_MOBIKE' $checked {'FORCE_MOBIKE'} />
2819 $Lang ::tr{'vpn force mobike'}
2824 <td align='left'><img src='/blob.gif' align='top' alt='*' /> $Lang ::tr{'required field'}</td>
2826 <input type='submit' name='ACTION' value=' $Lang ::tr{'save'}' />
2827 <input type='submit' name='ACTION' value=' $Lang ::tr{'cancel'}' />
2833 & Header
:: closebox
();
2834 & Header
:: closebigbox
();
2835 & Header
:: closepage
();
2842 ### Default status page
2847 & General
:: readhash
( "${General::swroot}/vpn/settings" , \
%cgiparams );
2848 & General
:: readhasharray
( "${General::swroot}/vpn/caconfig" , \
%cahash );
2849 & General
:: readhasharray
( "${General::swroot}/vpn/config" , \
%confighash );
2850 $cgiparams { 'CA_NAME' } = '' ;
2852 my @status = `/usr/local/bin/ipsecctrl I 2>/dev/null` ;
2854 # suggest a default name for this side
2855 if ( $cgiparams { 'VPN_IP' } eq '' && - e
"${General::swroot}/red/active" ) {
2856 if ( open ( IPADDR
, "${General::swroot}/red/local-ipaddress" )) {
2857 my $ipaddr = < IPADDR
>;
2860 $cgiparams { 'VPN_IP' } = ( gethostbyaddr ( pack ( "C4" , split ( /\./ , $ipaddr )), 2 ))[ 0 ];
2861 if ( $cgiparams { 'VPN_IP' } eq '' ) {
2862 $cgiparams { 'VPN_IP' } = $ipaddr ;
2866 # no IP found, use %defaultroute
2867 $cgiparams { 'VPN_IP' } = ' %defaultroute ' if ( $cgiparams { 'VPN_IP' } eq '' );
2869 $cgiparams { 'VPN_DELAYED_START' } = 0 if (! defined ( $cgiparams { 'VPN_DELAYED_START' }));
2870 $checked { 'ENABLED' } = $cgiparams { 'ENABLED' } eq 'on' ?
"checked='checked'" : '' ;
2872 & Header
:: showhttpheaders
();
2873 & Header
:: openpage
( $Lang :: tr
{ 'ipsec' }, 1 , '' );
2874 & Header
:: openbigbox
( '100%' , 'left' , '' , $errormessage );
2876 if ( $errormessage ) {
2877 & Header
:: openbox
( '100%' , 'left' , $Lang :: tr
{ 'error messages' });
2878 print "<class name='base'> $errormessage \n " ;
2879 print " </class> \n " ;
2880 & Header
:: closebox
();
2884 & Header
:: openbox
( '100%' , 'left' , $Lang :: tr
{ 'warning messages' });
2885 print " $warnmessage <br>" ;
2886 print " $Lang ::tr{'fwdfw warn1'}<br>" ;
2887 & Header
:: closebox
();
2888 print "<center><form method='post'><input type='submit' name='ACTION' value=' $Lang ::tr{'ok'}' style='width: 5em;'></form>" ;
2889 & Header
:: closepage
();
2893 & Header
:: openbox
( '100%' , 'left' , $Lang :: tr
{ 'global settings' });
2895 <form method='post' action=' $ENV {'SCRIPT_NAME'}'>
2896 <table width='100%'>
2898 <td width='20%' class='base' nowrap='nowrap'> $Lang ::tr{'vpn red name'}: <img src='/blob.gif' alt='*' /></td>
2899 <td width='20%'><input type='text' name='VPN_IP' value=' $cgiparams {'VPN_IP'}' /></td>
2900 <td width='20%' class='base'> $Lang ::tr{'enabled'}<input type='checkbox' name='ENABLED' $checked {'ENABLED'} /></td>
2906 <td class='base' nowrap='nowrap'> $Lang ::tr{'vpn delayed start'}: <img src='/blob.gif' alt='*' /><img src='/blob.gif' alt='*' /></td>
2907 <td ><input type='text' name='VPN_DELAYED_START' value=' $cgiparams {'VPN_DELAYED_START'}' /></td>
2910 <td class='base' nowrap='nowrap'> $Lang ::tr{'host to net vpn'}:</td>
2911 <td ><input type='text' name='RW_NET' value=' $cgiparams {'RW_NET'}' /></td>
2916 <table width='100%'>
2918 <td class='base' valign='top'><img src='/blob.gif' alt='*' /></td>
2919 <td width='70%' class='base' valign='top'> $Lang ::tr{'required field'}</td><td width='30%' align='right' class='base'><input type='submit' name='ACTION' value=' $Lang ::tr{'save'}' /></td>
2922 <td class='base' valign='top' nowrap='nowrap'><img src='/blob.gif' alt='*' /><img src='/blob.gif' alt='*' /> </td>
2923 <td class='base'> <font class='base'> $Lang ::tr{'vpn delayed start help'}</font></td>
2930 & Header
:: closebox
();
2932 & Header
:: openbox
( '100%' , 'left' , $Lang :: tr
{ 'connection status and controlc' });
2934 <table width='100%' cellspacing='1' cellpadding='0' class='tbl'>
2936 <th width='10%' class='boldbase' align='center'><b> $Lang ::tr{'name'}</b></th>
2937 <th width='22%' class='boldbase' align='center'><b> $Lang ::tr{'type'}</b></th>
2938 <th width='23%' class='boldbase' align='center'><b> $Lang ::tr{'common name'}</b></th>
2939 <th width='30%' class='boldbase' align='center'><b> $Lang ::tr{'remark'}</b></th>
2940 <th width='10%' class='boldbase' align='center'><b> $Lang ::tr{'status'}</b></th>
2941 <th class='boldbase' align='center' colspan='6'><b> $Lang ::tr{'action'}</b></th>
2947 foreach my $key ( sort { ncmp
( $confighash { $a }[ 1 ], $confighash { $b }[ 1 ]) } keys %confighash ) {
2948 if ( $confighash { $key }[ 0 ] eq 'on' ) { $gif = 'on.gif' ; } else { $gif = 'off.gif' ; }
2952 $col = "bgcolor=' $color {'color20'}'" ;
2955 $col = "bgcolor=' $color {'color22'}'" ;
2957 print "<td align='center' nowrap='nowrap' $col > $confighash { $key }[1]</td>" ;
2958 print "<td align='center' nowrap='nowrap' $col >" . $Lang :: tr
{ " $confighash { $key }[3]" } . " (" . $Lang :: tr
{ " $confighash { $key }[4]" } . ") $confighash { $key }[29]</td>" ;
2959 if ( $confighash { $key }[ 2 ] eq ' %auth -dn' ) {
2960 print "<td align='left' nowrap='nowrap' $col > $confighash { $key }[9]</td>" ;
2961 } elsif ( $confighash { $key }[ 4 ] eq 'cert' ) {
2962 print "<td align='left' nowrap='nowrap' $col > $confighash { $key }[2]</td>" ;
2964 print "<td align='left' $col > </td>" ;
2966 print "<td align='center' $col > $confighash { $key }[25]</td>" ;
2967 my $col1 = "bgcolor='${Header::colourred}'" ;
2968 my $active = "<b><font color='#FFFFFF'> $Lang ::tr{'capsclosed'}</font></b>" ;
2969 if ( $confighash { $key }[ 33 ] eq "add" ) {
2970 $col1 = "bgcolor='${Header::colourorange}'" ;
2971 $active = "<b><font color='#FFFFFF'> $Lang ::tr{'vpn wait'}</font></b>" ;
2973 foreach my $line ( @status ) {
2974 if (( $line =~ /\"$confighash{$key}[1]\".*IPsec SA established/ ) ||
2975 ( $line =~ /$confighash{$key}[1]\{.*INSTALLED/ )) {
2976 $col1 = "bgcolor='${Header::colourgreen}'" ;
2977 $active = "<b><font color='#FFFFFF'> $Lang ::tr{'capsopen'}</font></b>" ;
2978 } elsif ( $line =~ /$confighash{$key}[1]\[.*CONNECTING/ ) {
2979 $col1 = "bgcolor='${Header::colourorange}'" ;
2980 $active = "<b><font color='#FFFFFF'> $Lang ::tr{'vpn connecting'}</font></b>" ;
2981 } elsif ( $line =~ /$confighash{$key}[1]\{.*ROUTED/ ) {
2982 $col1 = "bgcolor='${Header::colourorange}'" ;
2983 $active = "<b><font color='#FFFFFF'> $Lang ::tr{'vpn on-demand'}</font></b>" ;
2986 # move to blue if really down
2987 if ( $confighash { $key }[ 0 ] eq 'off' && $col1 =~ /${Header::colourred}/ ) {
2988 $col1 = "bgcolor='${Header::colourblue}'" ;
2989 $active = "<b><font color='#FFFFFF'> $Lang ::tr{'capsclosed'}</font></b>" ;
2992 <td align='center' $col1 > $active </td>
2993 <td align='center' $col >
2994 <form method='post' action=' $ENV {'SCRIPT_NAME'}'>
2995 <input type='image' name=' $Lang ::tr{'restart'}' src='/images/reload.gif' alt=' $Lang ::tr{'restart'}' title=' $Lang ::tr{'restart'}' />
2996 <input type='hidden' name='ACTION' value=' $Lang ::tr{'restart'}' />
2997 <input type='hidden' name='KEY' value=' $key ' />
3002 if (( $confighash { $key }[ 4 ] eq 'cert' ) && ( $confighash { $key }[ 2 ] ne ' %auth -dn' )) {
3004 <td align='center' $col >
3005 <form method='post' action=' $ENV {'SCRIPT_NAME'}'>
3006 <input type='image' name=' $Lang ::tr{'show certificate'}' src='/images/info.gif' alt=' $Lang ::tr{'show certificate'}' title=' $Lang ::tr{'show certificate'}' />
3007 <input type='hidden' name='ACTION' value=' $Lang ::tr{'show certificate'}' />
3008 <input type='hidden' name='KEY' value=' $key ' />
3014 print "<td width='2%' $col > </td>" ;
3016 if ( $confighash { $key }[ 4 ] eq 'cert' && - f
"${General::swroot}/certs/ $confighash { $key }[1].p12" ) {
3018 <td align='center' $col >
3019 <form method='post' action=' $ENV {'SCRIPT_NAME'}'>
3020 <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'}' />
3021 <input type='hidden' name='ACTION' value=' $Lang ::tr{'download pkcs12 file'}' />
3022 <input type='hidden' name='KEY' value=' $key ' />
3027 } elsif (( $confighash { $key }[ 4 ] eq 'cert' ) && ( $confighash { $key }[ 2 ] ne ' %auth -dn' )) {
3029 <td align='center' $col >
3030 <form method='post' action=' $ENV {'SCRIPT_NAME'}'>
3031 <input type='image' name=' $Lang ::tr{'download certificate'}' src='/images/floppy.gif' alt=' $Lang ::tr{'download certificate'}' title=' $Lang ::tr{'download certificate'}' />
3032 <input type='hidden' name='ACTION' value=' $Lang ::tr{'download certificate'}' />
3033 <input type='hidden' name='KEY' value=' $key ' />
3039 print "<td width='2%' $col > </td>" ;
3042 <td align='center' $col >
3043 <form method='post' action=' $ENV {'SCRIPT_NAME'}'>
3044 <input type='image' name=' $Lang ::tr{'toggle enable disable'}' src='/images/ $gif ' alt=' $Lang ::tr{'toggle enable disable'}' title=' $Lang ::tr{'toggle enable disable'}' />
3045 <input type='hidden' name='ACTION' value=' $Lang ::tr{'toggle enable disable'}' />
3046 <input type='hidden' name='KEY' value=' $key ' />
3050 <td align='center' $col >
3051 <form method='post' action=' $ENV {'SCRIPT_NAME'}'>
3052 <input type='hidden' name='ACTION' value=' $Lang ::tr{'edit'}' />
3053 <input type='image' name=' $Lang ::tr{'edit'}' src='/images/edit.gif' alt=' $Lang ::tr{'edit'}' title=' $Lang ::tr{'edit'}' />
3054 <input type='hidden' name='KEY' value=' $key ' />
3057 <td align='center' $col >
3058 <form method='post' action=' $ENV {'SCRIPT_NAME'}'>
3059 <input type='hidden' name='ACTION' value=' $Lang ::tr{'remove'}' />
3060 <input type='image' name=' $Lang ::tr{'remove'}' src='/images/delete.gif' alt=' $Lang ::tr{'remove'}' title=' $Lang ::tr{'remove'}' />
3061 <input type='hidden' name='KEY' value=' $key ' />
3071 # If the config file contains entries, print Key to action icons
3076 <td class='boldbase'> <b> $Lang ::tr{'legend'}:</b></td>
3077 <td> <img src='/images/on.gif' alt=' $Lang ::tr{'click to disable'}' /></td>
3078 <td class='base'> $Lang ::tr{'click to disable'}</td>
3079 <td> <img src='/images/info.gif' alt=' $Lang ::tr{'show certificate'}' /></td>
3080 <td class='base'> $Lang ::tr{'show certificate'}</td>
3081 <td> <img src='/images/edit.gif' alt=' $Lang ::tr{'edit'}' /></td>
3082 <td class='base'> $Lang ::tr{'edit'}</td>
3083 <td> <img src='/images/delete.gif' alt=' $Lang ::tr{'remove'}' /></td>
3084 <td class='base'> $Lang ::tr{'remove'}</td>
3088 <td> <img src='/images/off.gif' alt='?OFF' /></td>
3089 <td class='base'> $Lang ::tr{'click to enable'}</td>
3090 <td> <img src='/images/floppy.gif' alt='?FLOPPY' /></td>
3091 <td class='base'> $Lang ::tr{'download certificate'}</td>
3092 <td> <img src='/images/reload.gif' alt='?RELOAD'/></td>
3093 <td class='base'> $Lang ::tr{'restart'}</td>
3101 <table width='100%'>
3102 <tr><td align='right' colspan='9'>
3103 <form method='post' action=' $ENV {'SCRIPT_NAME'}'>
3104 <input type='submit' name='ACTION' value=' $Lang ::tr{'add'}' />
3110 & Header
:: closebox
();
3112 & Header
:: openbox
( '100%' , 'left' , " $Lang ::tr{'certificate authorities'}" );
3114 <table width='100%' cellspacing='1' cellpadding='0' class='tbl'>
3116 <th width='25%' class='boldbase' align='center'><b> $Lang ::tr{'name'}</b></th>
3117 <th width='65%' class='boldbase' align='center'><b> $Lang ::tr{'subject'}</b></th>
3118 <th width='10%' class='boldbase' colspan='3' align='center'><b> $Lang ::tr{'action'}</b></th>
3122 my $col1 = "bgcolor=' $color {'color22'}'" ;
3123 my $col2 = "bgcolor=' $color {'color20'}'" ;
3124 if (- f
"${General::swroot}/ca/cacert.pem" ) {
3125 my $casubject = & Header
:: cleanhtml
( getsubjectfromcert
( "${General::swroot}/ca/cacert.pem" ));
3128 <td class='base' $col1 > $Lang ::tr{'root certificate'}</td>
3129 <td class='base' $col1 > $casubject </td>
3130 <td width='3%' align='center' $col1 >
3131 <form method='post' action=' $ENV {'SCRIPT_NAME'}'>
3132 <input type='hidden' name='ACTION' value=' $Lang ::tr{'show root certificate'}' />
3133 <input type='image' name=' $Lang ::tr{'edit'}' src='/images/info.gif' alt=' $Lang ::tr{'show root certificate'}' title=' $Lang ::tr{'show root certificate'}' />
3136 <td width='3%' align='center' $col1 >
3137 <form method='post' action=' $ENV {'SCRIPT_NAME'}'>
3138 <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'}' />
3139 <input type='hidden' name='ACTION' value=' $Lang ::tr{'download root certificate'}' />
3142 <td width='4%' $col1 > </td></tr>
3146 # display rootcert generation buttons
3149 <td class='base' $col1 > $Lang ::tr{'root certificate'}:</td>
3150 <td class='base' $col1 > $Lang ::tr{'not present'}</td>
3151 <td colspan='3' $col1 > </td></tr>
3156 if (- f
"${General::swroot}/certs/hostcert.pem" ) {
3157 my $hostsubject = & Header
:: cleanhtml
( getsubjectfromcert
( "${General::swroot}/certs/hostcert.pem" ));
3161 <td class='base' $col2 > $Lang ::tr{'host certificate'}</td>
3162 <td class='base' $col2 > $hostsubject </td>
3163 <td width='3%' align='center' $col2 >
3164 <form method='post' action=' $ENV {'SCRIPT_NAME'}'>
3165 <input type='hidden' name='ACTION' value=' $Lang ::tr{'show host certificate'}' />
3166 <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'}' />
3169 <td width='3%' align='center' $col2 >
3170 <form method='post' action=' $ENV {'SCRIPT_NAME'}'>
3171 <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'}" />
3172 <input type='hidden' name='ACTION' value=" $Lang ::tr{'download host certificate'}" />
3175 <td width='4%' $col2 > </td></tr>
3182 <td width='25%' class='base' $col2 > $Lang ::tr{'host certificate'}:</td>
3183 <td class='base' $col2 > $Lang ::tr{'not present'}</td>
3184 <td colspan='3' $col2 > </td></tr>
3190 if ( keys %cahash > 0 ) {
3191 foreach my $key ( keys %cahash ) {
3192 if ( $rowcolor ++ % 2 ) {
3194 $col = "bgcolor=' $color {'color20'}'" ;
3197 $col = "bgcolor=' $color {'color22'}'" ;
3199 print "<td class='base' $col > $cahash { $key }[0]</td> \n " ;
3200 print "<td class='base' $col > $cahash { $key }[1]</td> \n " ;
3202 <td align='center' $col >
3203 <form method='post' name='cafrm${key}a' action=' $ENV {'SCRIPT_NAME'}'>
3204 <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'}' />
3205 <input type='hidden' name='ACTION' value=' $Lang ::tr{'show ca certificate'}' />
3206 <input type='hidden' name='KEY' value=' $key ' />
3209 <td align='center' $col >
3210 <form method='post' name='cafrm${key}b' action=' $ENV {'SCRIPT_NAME'}'>
3211 <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'}' />
3212 <input type='hidden' name='ACTION' value=' $Lang ::tr{'download ca certificate'}' />
3213 <input type='hidden' name='KEY' value=' $key ' />
3216 <td align='center' $col >
3217 <form method='post' name='cafrm${key}c' action=' $ENV {'SCRIPT_NAME'}'>
3218 <input type='hidden' name='ACTION' value=' $Lang ::tr{'remove ca certificate'}' />
3219 <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'}' />
3220 <input type='hidden' name='KEY' value=' $key ' />
3230 # If the file contains entries, print Key to action icons
3231 if ( - f
"${General::swroot}/ca/cacert.pem" ) {
3234 <td class='boldbase'> <b> $Lang ::tr{'legend'}:</b></td>
3235 <td> <img src='/images/info.gif' alt=' $Lang ::tr{'show certificate'}' /></td>
3236 <td class='base'> $Lang ::tr{'show certificate'}</td>
3237 <td> <img src='/images/floppy.gif' alt=' $Lang ::tr{'download certificate'}' /></td>
3238 <td class='base'> $Lang ::tr{'download certificate'}</td>
3243 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>" ;
3247 <form method='post' enctype='multipart/form-data' action=' $ENV {'SCRIPT_NAME'}'>
3248 <table width='100%' border='0' cellspacing='1' cellpadding='0'>
3251 <td class='base' nowrap='nowrap'> $Lang ::tr{'ca name'}: <img src='/blob.gif' alt='*' /></td>
3252 <td nowrap='nowrap'><input type='text' name='CA_NAME' value=' $cgiparams {'CA_NAME'}' size='15' /> </td>
3253 <td nowrap='nowrap'><input type='file' name='FH' size='30' /></td>
3254 <td nowrap='nowrap'><input type='submit' name='ACTION' value=' $Lang ::tr{'upload ca certificate'}' /></td>
3257 <td colspan='3'> $Lang ::tr{'resetting the vpn configuration will remove the root ca, the host certificate and all certificate based connections'}:</td>
3258 <td align='right'><input type='submit' name='ACTION' value=' $Lang ::tr{'remove x509'}' /></td>
3264 & Header
:: closebox
();
3265 & Header
:: closebigbox
();
3266 & Header
:: closepage
();
3268 sub array_unique
($) {
3273 foreach my $e ( @
$array ) {
3274 next if $seen { $e }++;
3281 sub make_algos
($$$$$) {
3282 my ( $mode , $encs , $ints , $grps , $pfs ) = @_ ;
3285 foreach my $enc ( @
$encs ) {
3286 foreach my $int ( @
$ints ) {
3287 foreach my $grp ( @
$grps ) {
3290 if ( $mode eq "ike" ) {
3293 if ( $grp =~ m/^e(.*)$/ ) {
3294 push ( @algo , "ecp $1 " );
3295 } elsif ( $grp =~ m/curve25519/ ) {
3296 push ( @algo , " $grp " );
3298 push ( @algo , "modp $grp " );
3301 } elsif ( $mode eq "esp" && $pfs ) {
3302 my $is_aead = ( $enc =~ m/[cg]cm/ );
3308 if ( $grp eq "none" ) {
3310 } elsif ( $grp =~ m/^e(.*)$/ ) {
3311 push ( @algo , "ecp $1 " );
3312 } elsif ( $grp =~ m/curve25519/ ) {
3313 push ( @algo , " $grp " );
3315 push ( @algo , "modp $grp " );
3319 push ( @algos , join ( "-" , @algo ));
3324 return & array_unique
( \
@algos );
3327 sub make_subnets
($) {
3328 my $subnets = shift ;
3330 my @nets = split ( /\|/ , $subnets );
3332 foreach my $net ( @nets ) {
3333 my $cidr_net = & General
:: ipcidr
( $net );
3334 push ( @cidr_nets , $cidr_net );
3337 return join ( "," , @cidr_nets );