]>
git.ipfire.org Git - people/mfischer/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' } = 'start' ;
113 $cgiparams { 'INACTIVITY_TIMEOUT' } = 900 ;
114 $cgiparams { 'MODE' } = "tunnel" ;
115 $cgiparams { 'INTERFACE_MODE' } = "" ;
116 & Header
:: getcgihash
( \
%cgiparams , { 'wantfile' => 1 , 'filevar' => 'FH' });
122 my $hostname = $_ [ 0 ];
123 unless ( $hostname ) { return "No hostname" };
124 my $res = new Net
:: DNS
:: Resolver
;
125 my $query = $res -> search ( " $hostname " );
127 foreach my $rr ( $query -> answer ) {
128 ## Potential bug - we are only looking at A records:
129 return 0 if $rr -> type eq "A" ;
132 return $res -> errorstring ;
136 ### Just return true is one interface is vpn enabled
139 return ( $vpnsettings { 'ENABLED' } eq 'on' );
142 ### old version: maintain serial number to one, without explication.
143 ### this: let the counter go, so that each cert is numbered.
145 sub cleanssldatabase
{
146 if ( open ( FILE
, ">${General::swroot}/certs/serial" )) {
150 if ( open ( FILE
, ">${General::swroot}/certs/index.txt" )) {
154 if ( open ( FILE
, ">${General::swroot}/certs/index.txt.attr" )) {
158 unlink ( "${General::swroot}/certs/index.txt.old" );
159 unlink ( "${General::swroot}/certs/index.txt.attr.old" );
160 unlink ( "${General::swroot}/certs/serial.old" );
161 unlink ( "${General::swroot}/certs/01.pem" );
163 sub newcleanssldatabase
{
164 if (! - s
"${General::swroot}/certs/serial" ) {
165 open ( FILE
, ">${General::swroot}/certs/serial" );
169 if (! - s
">${General::swroot}/certs/index.txt" ) {
170 system ( "touch ${General::swroot}/certs/index.txt" );
172 if (! - s
">${General::swroot}/certs/index.txt.attr" ) {
173 system ( "touch ${General::swroot}/certs/index.txt.attr" );
175 unlink ( "${General::swroot}/certs/index.txt.old" );
176 unlink ( "${General::swroot}/certs/index.txt.attr.old" );
177 unlink ( "${General::swroot}/certs/serial.old" );
178 # unlink ("${General::swroot}/certs/01.pem"); numbering evolves. Wrong place to delete
182 ### Call openssl and return errormessage if any
186 my $retssl = `/usr/bin/openssl $opt 2>&1` ; #redirect stderr
188 foreach my $line ( split ( /\n/ , $retssl )) {
189 & General
:: log ( "ipsec" , " $line " ) if ( 0 ); # 1 for verbose logging
190 $ret .= '<br>' . $line if ( $line =~ /error|unknown/ );
193 $ret = & Header
:: cleanhtml
( $ret );
195 return $ret ?
" $Lang ::tr{'openssl produced an error'}: $ret " : '' ;
198 ### Obtain a CN from given cert
200 sub getCNfromcert
($) {
201 #&General::log("ipsec", "Extracting name from $_[0]...");
202 my $temp = `/usr/bin/openssl x509 -text -in $_ [0]` ;
203 $temp =~ /Subject:.*CN = (.*)[\n]/ ;
205 $temp =~ s
+/ Email
+, E
+;
206 $temp =~ s/ ST = / S = / ;
212 ### Obtain Subject from given cert
214 sub getsubjectfromcert
($) {
215 #&General::log("ipsec", "Extracting subject from $_[0]...");
216 my $temp = `/usr/bin/openssl x509 -text -in $_ [0]` ;
217 $temp =~ /Subject: (.*)[\n]/ ;
219 $temp =~ s
+/ Email
+, E
+;
220 $temp =~ s/ ST = / S = / ;
224 ### Combine local subnet and connection name to make a unique name for each connection section
225 ### (this sub is not used now)
227 sub makeconnname
($) {
231 $subnet =~ /^(.*?)\/ (.* ?
)$/; # $1=IP $2=mask
232 my $ip = unpack ( 'N' , & Socket
:: inet_aton
( $1 ));
233 if ( length ( $2 ) > 2 ) {
234 my $mm = unpack ( 'N' , & Socket
:: inet_aton
( $2 ));
235 while ( ( $mm & 1 )== 0 ) {
242 return sprintf ( " %s - %X " , $conn , $ip );
245 ### Write a config file.
247 ###Type=Host : GUI can choose the interface used (RED,GREEN,BLUE) and
248 ### the side is always defined as 'left'.
251 sub writeipsecfiles
{
252 my %lconfighash = ();
253 my %lvpnsettings = ();
254 & General
:: readhasharray
( "${General::swroot}/vpn/config" , \
%lconfighash );
255 & General
:: readhash
( "${General::swroot}/vpn/settings" , \
%lvpnsettings );
257 open ( CONF
, ">${General::swroot}/vpn/ipsec.conf" ) or die "Unable to open ${General::swroot}/vpn/ipsec.conf: $!" ;
258 open ( SECRETS
, ">${General::swroot}/vpn/ipsec.secrets" ) or die "Unable to open ${General::swroot}/vpn/ipsec.secrets: $!" ;
261 print CONF
"version 2 \n\n " ;
262 print CONF
"conn %default \n " ;
263 print CONF
" \t keyingtries= %forever \n " ;
266 # Add user includes to config file
267 if (- e
"/etc/ipsec.user.conf" ) {
268 print CONF
"include /etc/ipsec.user.conf \n " ;
272 print SECRETS
"include /etc/ipsec.user.secrets \n " ;
274 if (- f
"${General::swroot}/certs/hostkey.pem" ) {
275 print SECRETS
": RSA ${General::swroot}/certs/hostkey.pem \n "
277 my $last_secrets = '' ; # old the less specifics connections
279 foreach my $key ( keys %lconfighash ) {
280 next if ( $lconfighash { $key }[ 0 ] ne 'on' );
282 #remote peer is not set? => use '%any'
283 $lconfighash { $key }[ 10 ] = ' %any ' if ( $lconfighash { $key }[ 10 ] eq '' );
286 if ( $lconfighash { $key }[ 26 ] eq 'BLUE' ) {
287 $localside = $netsettings { 'BLUE_ADDRESS' };
288 } elsif ( $lconfighash { $key }[ 26 ] eq 'GREEN' ) {
289 $localside = $netsettings { 'GREEN_ADDRESS' };
290 } elsif ( $lconfighash { $key }[ 26 ] eq 'ORANGE' ) {
291 $localside = $netsettings { 'ORANGE_ADDRESS' };
293 $localside = $lvpnsettings { 'VPN_IP' };
296 print CONF
"conn $lconfighash { $key }[1] \n " ;
297 print CONF
" \t left= $localside \n " ;
298 print CONF
" \t leftsubnet=" . & make_subnets
( $lconfighash { $key }[ 8 ]) . " \n " ;
299 print CONF
" \t leftfirewall=yes \n " ;
300 print CONF
" \t lefthostaccess=yes \n " ;
301 print CONF
" \t right= $lconfighash { $key }[10] \n " ;
303 if ( $lconfighash { $key }[ 3 ] eq 'net' ) {
304 print CONF
" \t rightsubnet=" . & make_subnets
( $lconfighash { $key }[ 11 ]) . " \n " ;
307 # Local Cert and Remote Cert (unless auth is DN dn-auth)
308 if ( $lconfighash { $key }[ 4 ] eq 'cert' ) {
309 print CONF
" \t leftcert=${General::swroot}/certs/hostcert.pem \n " ;
310 print CONF
" \t rightcert=${General::swroot}/certs/ $lconfighash { $key }[1]cert.pem \n " if ( $lconfighash { $key }[ 2 ] ne ' %auth -dn' );
313 # Local and Remote IDs
314 print CONF
" \t leftid= \" $lconfighash { $key }[7] \"\n " if ( $lconfighash { $key }[ 7 ]);
315 print CONF
" \t rightid= \" $lconfighash { $key }[9] \"\n " if ( $lconfighash { $key }[ 9 ]);
318 if ( $lconfighash { $key }[ 35 ] eq "transport" ) {
319 print CONF
" \t type=transport \n " ;
321 print CONF
" \t type=tunnel \n " ;
325 my $pfs = $lconfighash { $key }[ 28 ] eq 'on' ?
'on' : 'off' ;
328 if ( $lconfighash { $key }[ 18 ] && $lconfighash { $key }[ 19 ] && $lconfighash { $key }[ 20 ]) {
329 my @encs = split ( '\|' , $lconfighash { $key }[ 18 ]);
330 my @ints = split ( '\|' , $lconfighash { $key }[ 19 ]);
331 my @groups = split ( '\|' , $lconfighash { $key }[ 20 ]);
333 my @algos = & make_algos
( "ike" , \
@encs , \
@ints , \
@groups , 1 );
334 print CONF
" \t ike=" . join ( "," , @algos );
336 if ( $lconfighash { $key }[ 24 ] eq 'on' ) { #only proposed algorythms?
343 if ( $lconfighash { $key }[ 21 ] && $lconfighash { $key }[ 22 ]) {
344 my @encs = split ( '\|' , $lconfighash { $key }[ 21 ]);
345 my @ints = split ( '\|' , $lconfighash { $key }[ 22 ]);
346 my @groups = split ( '\|' , $lconfighash { $key }[ 23 ]);
348 # Use IKE grouptype if no ESP group type has been selected
349 # (for backwards compatibility)
350 if ( $lconfighash { $key }[ 23 ] eq "" ) {
351 @groups = split ( '\|' , $lconfighash { $key }[ 20 ]);
354 my @algos = & make_algos
( "esp" , \
@encs , \
@ints , \
@groups , ( $pfs eq "on" ));
355 print CONF
" \t esp=" . join ( "," , @algos );
357 if ( $lconfighash { $key }[ 24 ] eq 'on' ) { #only proposed algorythms?
365 if (! $lconfighash { $key }[ 29 ]) {
366 $lconfighash { $key }[ 29 ] = "ikev1" ;
369 print CONF
" \t keyexchange= $lconfighash { $key }[29] \n " ;
372 print CONF
" \t ikelifetime= $lconfighash { $key }[16]h \n " if ( $lconfighash { $key }[ 16 ]);
373 print CONF
" \t keylife= $lconfighash { $key }[17]h \n " if ( $lconfighash { $key }[ 17 ]);
376 print CONF
" \t compress=yes \n " if ( $lconfighash { $key }[ 13 ] eq 'on' );
379 if (( $lconfighash { $key }[ 29 ] eq "ikev2" ) && ( $lconfighash { $key }[ 32 ] eq 'on' )) {
380 print CONF
" \t mobike=yes \n " ;
383 # Dead Peer Detection
384 my $dpdaction = $lconfighash { $key }[ 27 ];
385 print CONF
" \t dpdaction= $dpdaction \n " ;
387 # If the dead peer detection is disabled and IKEv2 is used,
388 # dpddelay must be set to zero, too.
389 if ( $dpdaction eq "none" ) {
390 if ( $lconfighash { $key }[ 29 ] eq "ikev2" ) {
391 print CONF
" \t dpddelay=0 \n " ;
394 my $dpddelay = $lconfighash { $key }[ 31 ];
398 print CONF
" \t dpddelay= $dpddelay \n " ;
399 my $dpdtimeout = $lconfighash { $key }[ 30 ];
403 print CONF
" \t dpdtimeout= $dpdtimeout \n " ;
406 # Build Authentication details: LEFTid RIGHTid : PSK psk
408 if ( $lconfighash { $key }[ 4 ] eq 'psk' ) {
409 $psk_line = ( $lconfighash { $key }[ 7 ] ?
$lconfighash { $key }[ 7 ] : $localside ) . " " ;
410 $psk_line .= $lconfighash { $key }[ 9 ] ?
$lconfighash { $key }[ 9 ] : $lconfighash { $key }[ 10 ]; #remoteid or remote address?
411 $psk_line .= " : PSK ' $lconfighash { $key }[5]' \n " ;
412 # if the line contains %any, it is less specific than two IP or ID, so move it at end of file.
413 if ( $psk_line =~ /%any/ ) {
414 $last_secrets .= $psk_line ;
416 print SECRETS
$psk_line ;
418 print CONF
" \t authby=secret \n " ;
420 print CONF
" \t authby=rsasig \n " ;
421 print CONF
" \t leftrsasigkey= %cert \n " ;
422 print CONF
" \t rightrsasigkey= %cert \n " ;
425 my $start_action = $lconfighash { $key }[ 33 ];
426 if (! $start_action ) {
427 $start_action = "start" ;
430 my $inactivity_timeout = $lconfighash { $key }[ 34 ];
431 if ( $inactivity_timeout eq "" ) {
432 $inactivity_timeout = 900 ;
435 # Automatically start only if a net-to-net connection
436 if ( $lconfighash { $key }[ 3 ] eq 'host' ) {
437 print CONF
" \t auto=add \n " ;
438 print CONF
" \t rightsourceip= $lvpnsettings {'RW_NET'} \n " ;
440 print CONF
" \t auto= $start_action \n " ;
442 # If in on-demand mode, we terminate the tunnel
443 # after 15 min of no traffic
444 if ( $start_action eq 'route' && $inactivity_timeout > 0 ) {
445 print CONF
" \t inactivity= $inactivity_timeout \n " ;
450 print CONF
" \t fragmentation=yes \n " ;
455 # Add post user includes to config file
456 # After the GUI-connections allows to patch connections.
457 if (- e
"/etc/ipsec.user-post.conf" ) {
458 print CONF
"include /etc/ipsec.user-post.conf \n " ;
462 print SECRETS
$last_secrets if ( $last_secrets );
467 # Hook to regenerate the configuration files.
468 if ( $ENV { "REMOTE_ADDR" } eq "" ) {
474 ### Save main settings
476 if ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'save' } && $cgiparams { 'TYPE' } eq '' && $cgiparams { 'KEY' } eq '' ) {
477 & General
:: readhash
( "${General::swroot}/vpn/settings" , \
%vpnsettings );
479 unless (& General
:: validfqdn
( $cgiparams { 'VPN_IP' }) || & General
:: validip
( $cgiparams { 'VPN_IP' })
480 || $cgiparams { 'VPN_IP' } eq ' %defaultroute ' ) {
481 $errormessage = $Lang :: tr
{ 'invalid input for hostname' };
485 unless ( $cgiparams { 'VPN_DELAYED_START' } =~ /^[0-9]{1,3}$/ ) { #allow 0-999 seconds !
486 $errormessage = $Lang :: tr
{ 'invalid time period' };
490 if ( $cgiparams { 'RW_NET' } ne '' and !& General
:: validipandmask
( $cgiparams { 'RW_NET' }) ) {
491 $errormessage = $Lang :: tr
{ 'urlfilter invalid ip or mask error' };
495 $vpnsettings { 'ENABLED' } = $cgiparams { 'ENABLED' };
496 $vpnsettings { 'VPN_IP' } = $cgiparams { 'VPN_IP' };
497 $vpnsettings { 'VPN_DELAYED_START' } = $cgiparams { 'VPN_DELAYED_START' };
498 $vpnsettings { 'RW_NET' } = $cgiparams { 'RW_NET' };
499 & General
:: writehash
( "${General::swroot}/vpn/settings" , \
%vpnsettings );
502 system ( '/usr/local/bin/ipsecctrl' , 'S' );
504 system ( '/usr/local/bin/ipsecctrl' , 'D' );
511 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'remove x509' } && $cgiparams { 'AREUSURE' } eq 'yes' ) {
512 & General
:: readhasharray
( "${General::swroot}/vpn/config" , \
%confighash );
514 foreach my $key ( keys %confighash ) {
515 if ( $confighash { $key }[ 4 ] eq 'cert' ) {
516 delete $confighash { $key };
519 while ( my $file = glob ( "${General::swroot}/{ca,certs,crls,private}/*" )) {
523 if ( open ( FILE
, ">${General::swroot}/vpn/caconfig" )) {
527 & General
:: writehasharray
( "${General::swroot}/vpn/config" , \
%confighash );
529 system ( '/usr/local/bin/ipsecctrl' , 'R' );
535 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'remove x509' }) {
536 & Header
:: showhttpheaders
();
537 & Header
:: openpage
( $Lang :: tr
{ 'ipsec' }, 1 , '' );
538 & Header
:: openbigbox
( '100%' , 'left' , '' , '' );
539 & Header
:: openbox
( '100%' , 'left' , $Lang :: tr
{ 'are you sure' });
541 <form method='post' action=' $ENV {'SCRIPT_NAME'}'>
545 <input type='hidden' name='AREUSURE' value='yes' />
546 <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'}
550 <input type='submit' name='ACTION' value=' $Lang ::tr{'remove x509'}' />
551 <input type='submit' name='ACTION' value=' $Lang ::tr{'cancel'}' /></td>
558 & Header
:: closebigbox
();
559 & Header
:: closepage
();
563 ### Upload CA Certificate
565 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'upload ca certificate' }) {
566 & General
:: readhasharray
( "${General::swroot}/vpn/caconfig" , \
%cahash );
568 if ( $cgiparams { 'CA_NAME' } !~ /^[a-zA-Z0-9]+$/ ) {
569 $errormessage = $Lang :: tr
{ 'name must only contain characters' };
573 if ( length ( $cgiparams { 'CA_NAME' }) > 60 ) {
574 $errormessage = $Lang :: tr
{ 'name too long' };
578 if ( $cgiparams { 'CA_NAME' } eq 'ca' ) {
579 $errormessage = $Lang :: tr
{ 'name is invalid' };
580 goto UPLOAD_CA_ERROR
;
583 # Check if there is no other entry with this name
584 foreach my $key ( keys %cahash ) {
585 if ( $cahash { $key }[ 0 ] eq $cgiparams { 'CA_NAME' }) {
586 $errormessage = $Lang :: tr
{ 'a ca certificate with this name already exists' };
591 if ( ref ( $cgiparams { 'FH' }) ne 'Fh' ) {
592 $errormessage = $Lang :: tr
{ 'there was no file upload' };
595 # Move uploaded ca to a temporary file
596 ( my $fh , my $filename ) = tempfile
( );
597 if ( copy
( $cgiparams { 'FH' }, $fh ) != 1 ) {
601 my $temp = `/usr/bin/openssl x509 -text -in $filename ` ;
602 if ( $temp !~ /CA:TRUE/i ) {
603 $errormessage = $Lang :: tr
{ 'not a valid ca certificate' };
607 move
( $filename , "${General::swroot}/ca/ $cgiparams {'CA_NAME'}cert.pem" );
609 $errormessage = " $Lang ::tr{'certificate file move failed'}: $!" ;
615 my $key = & General
:: findhasharraykey
( \
%cahash );
616 $cahash { $key }[ 0 ] = $cgiparams { 'CA_NAME' };
617 $cahash { $key }[ 1 ] = & Header
:: cleanhtml
( getsubjectfromcert
( "${General::swroot}/ca/ $cgiparams {'CA_NAME'}cert.pem" ));
618 & General
:: writehasharray
( "${General::swroot}/vpn/caconfig" , \
%cahash );
620 system ( '/usr/local/bin/ipsecctrl' , 'R' );
626 ### Display ca certificate
628 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'show ca certificate' }) {
629 & General
:: readhasharray
( "${General::swroot}/vpn/caconfig" , \
%cahash );
631 if ( - f
"${General::swroot}/ca/ $cahash { $cgiparams {'KEY'}}[0]cert.pem" ) {
632 & Header
:: showhttpheaders
();
633 & Header
:: openpage
( $Lang :: tr
{ 'ipsec' }, 1 , '' );
634 & Header
:: openbigbox
( '100%' , 'left' , '' , '' );
635 & Header
:: openbox
( '100%' , 'left' , " $Lang ::tr{'ca certificate'}:" );
636 my $output = `/usr/bin/openssl x509 -text -in ${General::swroot}/ca/ $cahash { $cgiparams {'KEY'}}[0]cert.pem` ;
637 $output = & Header
:: cleanhtml
( $output , "y" );
638 print "<pre> $output </pre> \n " ;
640 print "<div align='center'><a href='/cgi-bin/vpnmain.cgi'> $Lang ::tr{'back'}</a></div>" ;
641 & Header
:: closebigbox
();
642 & Header
:: closepage
();
645 $errormessage = $Lang :: tr
{ 'invalid key' };
649 ### Export ca certificate to browser
651 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'download ca certificate' }) {
652 & General
:: readhasharray
( "${General::swroot}/vpn/caconfig" , \
%cahash );
654 if ( - f
"${General::swroot}/ca/ $cahash { $cgiparams {'KEY'}}[0]cert.pem" ) {
655 print "Content-Type: application/force-download \n " ;
656 print "Content-Type: application/octet-stream \r\n " ;
657 print "Content-Disposition: attachment; filename= $cahash { $cgiparams {'KEY'}}[0]cert.pem \r\n\r\n " ;
658 print `/usr/bin/openssl x509 -in ${General::swroot}/ca/ $cahash { $cgiparams {'KEY'}}[0]cert.pem` ;
661 $errormessage = $Lang :: tr
{ 'invalid key' };
665 ### Remove ca certificate (step 2)
667 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'remove ca certificate' } && $cgiparams { 'AREUSURE' } eq 'yes' ) {
668 & General
:: readhasharray
( "${General::swroot}/vpn/config" , \
%confighash );
669 & General
:: readhasharray
( "${General::swroot}/vpn/caconfig" , \
%cahash );
671 if ( - f
"${General::swroot}/ca/ $cahash { $cgiparams {'KEY'}}[0]cert.pem" ) {
672 foreach my $key ( keys %confighash ) {
673 my $test = `/usr/bin/openssl verify -CAfile ${General::swroot}/ca/ $cahash { $cgiparams {'KEY'}}[0]cert.pem ${General::swroot}/certs/ $confighash { $key }[1]cert.pem` ;
674 if ( $test =~ /: OK/ ) {
676 system ( '/usr/local/bin/ipsecctrl' , 'D' , $key ) if (& vpnenabled
);
677 unlink ( "${General::swroot}/certs/ $confighash { $key }[1]cert.pem" );
678 unlink ( "${General::swroot}/certs/ $confighash { $key }[1].p12" );
679 delete $confighash { $key };
680 & General
:: writehasharray
( "${General::swroot}/vpn/config" , \
%confighash );
684 unlink ( "${General::swroot}/ca/ $cahash { $cgiparams {'KEY'}}[0]cert.pem" );
685 delete $cahash { $cgiparams { 'KEY' }};
686 & General
:: writehasharray
( "${General::swroot}/vpn/caconfig" , \
%cahash );
687 system ( '/usr/local/bin/ipsecctrl' , 'R' );
690 $errormessage = $Lang :: tr
{ 'invalid key' };
693 ### Remove ca certificate (step 1)
695 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'remove ca certificate' }) {
696 & General
:: readhasharray
( "${General::swroot}/vpn/config" , \
%confighash );
697 & General
:: readhasharray
( "${General::swroot}/vpn/caconfig" , \
%cahash );
699 my $assignedcerts = 0 ;
700 if ( - f
"${General::swroot}/ca/ $cahash { $cgiparams {'KEY'}}[0]cert.pem" ) {
701 foreach my $key ( keys %confighash ) {
702 my $test = `/usr/bin/openssl verify -CAfile ${General::swroot}/ca/ $cahash { $cgiparams {'KEY'}}[0]cert.pem ${General::swroot}/certs/ $confighash { $key }[1]cert.pem` ;
703 if ( $test =~ /: OK/ ) {
707 if ( $assignedcerts ) {
708 & Header
:: showhttpheaders
();
709 & Header
:: openpage
( $Lang :: tr
{ 'ipsec' }, 1 , '' );
710 & Header
:: openbigbox
( '100%' , 'left' , '' , '' );
711 & Header
:: openbox
( '100%' , 'left' , $Lang :: tr
{ 'are you sure' });
713 <form method='post' action=' $ENV {'SCRIPT_NAME'}'>
717 <input type='hidden' name='KEY' value=' $cgiparams {'KEY'}' />
718 <input type='hidden' name='AREUSURE' value='yes' /></td>
721 <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>
724 <input type='submit' name='ACTION' value=' $Lang ::tr{'remove ca certificate'}' />
725 <input type='submit' name='ACTION' value=' $Lang ::tr{'cancel'}' /></td>
732 & Header
:: closebigbox
();
733 & Header
:: closepage
();
736 unlink ( "${General::swroot}/ca/ $cahash { $cgiparams {'KEY'}}[0]cert.pem" );
737 delete $cahash { $cgiparams { 'KEY' }};
738 & General
:: writehasharray
( "${General::swroot}/vpn/caconfig" , \
%cahash );
739 system ( '/usr/local/bin/ipsecctrl' , 'R' );
743 $errormessage = $Lang :: tr
{ 'invalid key' };
747 ### Display root certificate
749 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'show root certificate' } ||
750 $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'show host certificate' }) {
752 & Header
:: showhttpheaders
();
753 & Header
:: openpage
( $Lang :: tr
{ 'ipsec' }, 1 , '' );
754 & Header
:: openbigbox
( '100%' , 'left' , '' , '' );
755 if ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'show root certificate' }) {
756 & Header
:: openbox
( '100%' , 'left' , " $Lang ::tr{'root certificate'}:" );
757 $output = `/usr/bin/openssl x509 -text -in ${General::swroot}/ca/cacert.pem` ;
759 & Header
:: openbox
( '100%' , 'left' , " $Lang ::tr{'host certificate'}:" );
760 $output = `/usr/bin/openssl x509 -text -in ${General::swroot}/certs/hostcert.pem` ;
762 $output = & Header
:: cleanhtml
( $output , "y" );
763 print "<pre> $output </pre> \n " ;
765 print "<div align='center'><a href='/cgi-bin/vpnmain.cgi'> $Lang ::tr{'back'}</a></div>" ;
766 & Header
:: closebigbox
();
767 & Header
:: closepage
();
771 ### Export root certificate to browser
773 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'download root certificate' }) {
774 if ( - f
"${General::swroot}/ca/cacert.pem" ) {
775 print "Content-Type: application/force-download \n " ;
776 print "Content-Disposition: attachment; filename=cacert.pem \r\n\r\n " ;
777 print `/usr/bin/openssl x509 -in ${General::swroot}/ca/cacert.pem` ;
781 ### Export host certificate to browser
783 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'download host certificate' }) {
784 if ( - f
"${General::swroot}/certs/hostcert.pem" ) {
785 print "Content-Type: application/force-download \n " ;
786 print "Content-Disposition: attachment; filename=hostcert.pem \r\n\r\n " ;
787 print `/usr/bin/openssl x509 -in ${General::swroot}/certs/hostcert.pem` ;
791 ### Form for generating/importing the caroot+host certificate
793 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'generate root/host certificates' } ||
794 $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'upload p12 file' }) {
796 if (- f
"${General::swroot}/ca/cacert.pem" ) {
797 $errormessage = $Lang :: tr
{ 'valid root certificate already exists' };
801 & General
:: readhash
( "${General::swroot}/vpn/settings" , \
%vpnsettings );
802 # fill in initial values
803 if ( $cgiparams { 'ROOTCERT_HOSTNAME' } eq '' ) {
804 if (- e
"${General::swroot}/red/active" && open ( IPADDR
, "${General::swroot}/red/local-ipaddress" )) {
805 my $ipaddr = < IPADDR
>;
808 $cgiparams { 'ROOTCERT_HOSTNAME' } = ( gethostbyaddr ( pack ( "C4" , split ( /\./ , $ipaddr )), 2 ))[ 0 ];
809 if ( $cgiparams { 'ROOTCERT_HOSTNAME' } eq '' ) {
810 $cgiparams { 'ROOTCERT_HOSTNAME' } = $ipaddr ;
813 $cgiparams { 'ROOTCERT_COUNTRY' } = $vpnsettings { 'ROOTCERT_COUNTRY' } if (! $cgiparams { 'ROOTCERT_COUNTRY' });
814 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'upload p12 file' }) {
815 & General
:: log ( "ipsec" , "Importing from p12..." );
817 if ( ref ( $cgiparams { 'FH' }) ne 'Fh' ) {
818 $errormessage = $Lang :: tr
{ 'there was no file upload' };
822 # Move uploaded certificate request to a temporary file
823 ( my $fh , my $filename ) = tempfile
( );
824 if ( copy
( $cgiparams { 'FH' }, $fh ) != 1 ) {
829 # Extract the CA certificate from the file
830 & General
:: log ( "ipsec" , "Extracting caroot from p12..." );
831 if ( open ( STDIN
, "-|" )) {
832 my $opt = " pkcs12 -cacerts -nokeys" ;
833 $opt .= " -in $filename " ;
834 $opt .= " -out /tmp/newcacert" ;
835 $errormessage = & callssl
( $opt );
837 print " $cgiparams {'P12_PASS'} \n " ;
841 # Extract the Host certificate from the file
842 if (! $errormessage ) {
843 & General
:: log ( "ipsec" , "Extracting host cert from p12..." );
844 if ( open ( STDIN
, "-|" )) {
845 my $opt = " pkcs12 -clcerts -nokeys" ;
846 $opt .= " -in $filename " ;
847 $opt .= " -out /tmp/newhostcert" ;
848 $errormessage = & callssl
( $opt );
850 print " $cgiparams {'P12_PASS'} \n " ;
855 # Extract the Host key from the file
856 if (! $errormessage ) {
857 & General
:: log ( "ipsec" , "Extracting private key from p12..." );
858 if ( open ( STDIN
, "-|" )) {
859 my $opt = " pkcs12 -nocerts -nodes" ;
860 $opt .= " -in $filename " ;
861 $opt .= " -out /tmp/newhostkey" ;
862 $errormessage = & callssl
( $opt );
864 print " $cgiparams {'P12_PASS'} \n " ;
869 if (! $errormessage ) {
870 & General
:: log ( "ipsec" , "Moving cacert..." );
871 move
( "/tmp/newcacert" , "${General::swroot}/ca/cacert.pem" );
872 $errormessage = " $Lang ::tr{'certificate file move failed'}: $!" if ($ ?
ne 0 );
875 if (! $errormessage ) {
876 & General
:: log ( "ipsec" , "Moving host cert..." );
877 move
( "/tmp/newhostcert" , "${General::swroot}/certs/hostcert.pem" );
878 $errormessage = " $Lang ::tr{'certificate file move failed'}: $!" if ($ ?
ne 0 );
881 if (! $errormessage ) {
882 & General
:: log ( "ipsec" , "Moving private key..." );
883 move
( "/tmp/newhostkey" , "${General::swroot}/certs/hostkey.pem" );
884 $errormessage = " $Lang ::tr{'certificate file move failed'}: $!" if ($ ?
ne 0 );
889 unlink ( '/tmp/newcacert' );
890 unlink ( '/tmp/newhostcert' );
891 unlink ( '/tmp/newhostkey' );
893 unlink ( "${General::swroot}/ca/cacert.pem" );
894 unlink ( "${General::swroot}/certs/hostcert.pem" );
895 unlink ( "${General::swroot}/certs/hostkey.pem" );
899 # Create empty CRL cannot be done because we don't have
900 # the private key for this CAROOT
901 # IPFire can only import certificates
903 & General
:: log ( "ipsec" , "p12 import completed!" );
905 goto ROOTCERT_SUCCESS
;
907 } elsif ( $cgiparams { 'ROOTCERT_COUNTRY' } ne '' ) {
909 # Validate input since the form was submitted
910 if ( $cgiparams { 'ROOTCERT_ORGANIZATION' } eq '' ){
911 $errormessage = $Lang :: tr
{ 'organization cant be empty' };
914 if ( length ( $cgiparams { 'ROOTCERT_ORGANIZATION' }) > 60 ) {
915 $errormessage = $Lang :: tr
{ 'organization too long' };
918 if ( $cgiparams { 'ROOTCERT_ORGANIZATION' } !~ /^[a-zA-Z0-9 ,\.\-_]*$/ ) {
919 $errormessage = $Lang :: tr
{ 'invalid input for organization' };
922 if ( $cgiparams { 'ROOTCERT_HOSTNAME' } eq '' ){
923 $errormessage = $Lang :: tr
{ 'hostname cant be empty' };
926 unless (& General
:: validfqdn
( $cgiparams { 'ROOTCERT_HOSTNAME' }) || & General
:: validip
( $cgiparams { 'ROOTCERT_HOSTNAME' })) {
927 $errormessage = $Lang :: tr
{ 'invalid input for hostname' };
930 if ( $cgiparams { 'ROOTCERT_EMAIL' } ne '' && (! & General
:: validemail
( $cgiparams { 'ROOTCERT_EMAIL' }))) {
931 $errormessage = $Lang :: tr
{ 'invalid input for e-mail address' };
934 if ( length ( $cgiparams { 'ROOTCERT_EMAIL' }) > 40 ) {
935 $errormessage = $Lang :: tr
{ 'e-mail address too long' };
938 if ( $cgiparams { 'ROOTCERT_OU' } ne '' && $cgiparams { 'ROOTCERT_OU' } !~ /^[a-zA-Z0-9 ,\.\-_]*$/ ) {
939 $errormessage = $Lang :: tr
{ 'invalid input for department' };
942 if ( $cgiparams { 'ROOTCERT_CITY' } ne '' && $cgiparams { 'ROOTCERT_CITY' } !~ /^[a-zA-Z0-9 ,\.\-_]*$/ ) {
943 $errormessage = $Lang :: tr
{ 'invalid input for city' };
946 if ( $cgiparams { 'ROOTCERT_STATE' } ne '' && $cgiparams { 'ROOTCERT_STATE' } !~ /^[a-zA-Z0-9 ,\.\-_]*$/ ) {
947 $errormessage = $Lang :: tr
{ 'invalid input for state or province' };
950 if ( $cgiparams { 'ROOTCERT_COUNTRY' } !~ /^[A-Z]*$/ ) {
951 $errormessage = $Lang :: tr
{ 'invalid input for country' };
954 #the exact syntax is a list comma separated of
955 # email:any-validemail
956 # URI: a uniform resource indicator
957 # DNS: a DNS domain name
958 # RID: a registered OBJECT IDENTIFIER
960 # example: email:franck@foo.com,IP:10.0.0.10,DNS:franck.foo.com
962 if ( $cgiparams { 'SUBJECTALTNAME' } ne '' && $cgiparams { 'SUBJECTALTNAME' } !~ /^(email|URI|DNS|RID|IP):[a-zA-Z0-9 :\/ , \
. \
- _@
]*$/) {
963 $errormessage = $Lang :: tr
{ 'vpn altname syntax' };
967 # Copy the cgisettings to vpnsettings and save the configfile
968 $vpnsettings { 'ROOTCERT_ORGANIZATION' } = $cgiparams { 'ROOTCERT_ORGANIZATION' };
969 $vpnsettings { 'ROOTCERT_HOSTNAME' } = $cgiparams { 'ROOTCERT_HOSTNAME' };
970 $vpnsettings { 'ROOTCERT_EMAIL' } = $cgiparams { 'ROOTCERT_EMAIL' };
971 $vpnsettings { 'ROOTCERT_OU' } = $cgiparams { 'ROOTCERT_OU' };
972 $vpnsettings { 'ROOTCERT_CITY' } = $cgiparams { 'ROOTCERT_CITY' };
973 $vpnsettings { 'ROOTCERT_STATE' } = $cgiparams { 'ROOTCERT_STATE' };
974 $vpnsettings { 'ROOTCERT_COUNTRY' } = $cgiparams { 'ROOTCERT_COUNTRY' };
975 & General
:: writehash
( "${General::swroot}/vpn/settings" , \
%vpnsettings );
977 # Replace empty strings with a .
978 ( my $ou = $cgiparams { 'ROOTCERT_OU' }) =~ s/^\s*$/\./ ;
979 ( my $city = $cgiparams { 'ROOTCERT_CITY' }) =~ s/^\s*$/\./ ;
980 ( my $state = $cgiparams { 'ROOTCERT_STATE' }) =~ s/^\s*$/\./ ;
982 # Create the CA certificate
983 if (! $errormessage ) {
984 & General
:: log ( "ipsec" , "Creating cacert..." );
985 if ( open ( STDIN
, "-|" )) {
986 my $opt = " req -x509 -sha256 -nodes" ;
987 $opt .= " -days 999999" ;
988 $opt .= " -newkey rsa:4096" ;
989 $opt .= " -keyout ${General::swroot}/private/cakey.pem" ;
990 $opt .= " -out ${General::swroot}/ca/cacert.pem" ;
992 $errormessage = & callssl
( $opt );
994 print " $cgiparams {'ROOTCERT_COUNTRY'} \n " ;
997 print " $cgiparams {'ROOTCERT_ORGANIZATION'} \n " ;
999 print " $cgiparams {'ROOTCERT_ORGANIZATION'} CA \n " ;
1000 print " $cgiparams {'ROOTCERT_EMAIL'} \n " ;
1005 # Create the Host certificate request
1006 if (! $errormessage ) {
1007 & General
:: log ( "ipsec" , "Creating host cert..." );
1008 if ( open ( STDIN
, "-|" )) {
1009 my $opt = " req -sha256 -nodes" ;
1010 $opt .= " -newkey rsa:2048" ;
1011 $opt .= " -keyout ${General::swroot}/certs/hostkey.pem" ;
1012 $opt .= " -out ${General::swroot}/certs/hostreq.pem" ;
1013 $errormessage = & callssl
( $opt );
1015 print " $cgiparams {'ROOTCERT_COUNTRY'} \n " ;
1018 print " $cgiparams {'ROOTCERT_ORGANIZATION'} \n " ;
1020 print " $cgiparams {'ROOTCERT_HOSTNAME'} \n " ;
1021 print " $cgiparams {'ROOTCERT_EMAIL'} \n " ;
1028 # Sign the host certificate request
1029 if (! $errormessage ) {
1030 & General
:: log ( "ipsec" , "Self signing host cert..." );
1032 #No easy way for specifying the contain of subjectAltName without writing a config file...
1033 my ( $fh , $v3extname ) = tempfile
( '/tmp/XXXXXXXX' );
1035 basicConstraints=CA:FALSE
1036 nsComment="OpenSSL Generated Certificate"
1037 subjectKeyIdentifier=hash
1038 authorityKeyIdentifier=keyid,issuer:always
1039 extendedKeyUsage = serverAuth
1042 print $fh "subjectAltName= $cgiparams {'SUBJECTALTNAME'}" if ( $cgiparams { 'SUBJECTALTNAME' });
1045 my $opt = " ca -md sha256 -days 999999" ;
1046 $opt .= " -batch -notext" ;
1047 $opt .= " -in ${General::swroot}/certs/hostreq.pem" ;
1048 $opt .= " -out ${General::swroot}/certs/hostcert.pem" ;
1049 $opt .= " -extfile $v3extname " ;
1050 $errormessage = & callssl
( $opt );
1051 unlink ( "${General::swroot}/certs/hostreq.pem" ); #no more needed
1052 unlink ( $v3extname );
1055 # Create an empty CRL
1056 if (! $errormessage ) {
1057 & General
:: log ( "ipsec" , "Creating emptycrl..." );
1058 my $opt = " ca -gencrl" ;
1059 $opt .= " -out ${General::swroot}/crls/cacrl.pem" ;
1060 $errormessage = & callssl
( $opt );
1063 # Successfully build CA / CERT!
1064 if (! $errormessage ) {
1065 & cleanssldatabase
();
1066 goto ROOTCERT_SUCCESS
;
1070 unlink ( "${General::swroot}/ca/cacert.pem" );
1071 unlink ( "${General::swroot}/certs/hostkey.pem" );
1072 unlink ( "${General::swroot}/certs/hostcert.pem" );
1073 unlink ( "${General::swroot}/crls/cacrl.pem" );
1074 & cleanssldatabase
();
1078 & Header
:: showhttpheaders
();
1079 & Header
:: openpage
( $Lang :: tr
{ 'ipsec' }, 1 , '' );
1080 & Header
:: openbigbox
( '100%' , 'left' , '' , $errormessage );
1081 if ( $errormessage ) {
1082 & Header
:: openbox
( '100%' , 'left' , $Lang :: tr
{ 'error messages' });
1083 print "<class name='base'> $errormessage " ;
1084 print " </class>" ;
1085 & Header
:: closebox
();
1087 & Header
:: openbox
( '100%' , 'left' , " $Lang ::tr{'generate root/host certificates'}:" );
1089 <form method='post' enctype='multipart/form-data' action=' $ENV {'SCRIPT_NAME'}'>
1090 <table width='100%' border='0' cellspacing='1' cellpadding='0'>
1091 <tr><td width='40%' class='base'> $Lang ::tr{'organization name'}: <img src='/blob.gif' alt='*' /></td>
1092 <td width='60%' class='base' nowrap='nowrap'><input type='text' name='ROOTCERT_ORGANIZATION' value=' $cgiparams {'ROOTCERT_ORGANIZATION'}' size='32' /></td></tr>
1093 <tr><td class='base'> $Lang ::tr{'ipfires hostname'}: <img src='/blob.gif' alt='*' /></td>
1094 <td class='base' nowrap='nowrap'><input type='text' name='ROOTCERT_HOSTNAME' value=' $cgiparams {'ROOTCERT_HOSTNAME'}' size='32' /></td></tr>
1095 <tr><td class='base'> $Lang ::tr{'your e-mail'}:</td>
1096 <td class='base' nowrap='nowrap'><input type='text' name='ROOTCERT_EMAIL' value=' $cgiparams {'ROOTCERT_EMAIL'}' size='32' /></td></tr>
1097 <tr><td class='base'> $Lang ::tr{'your department'}:</td>
1098 <td class='base' nowrap='nowrap'><input type='text' name='ROOTCERT_OU' value=' $cgiparams {'ROOTCERT_OU'}' size='32' /></td></tr>
1099 <tr><td class='base'> $Lang ::tr{'city'}:</td>
1100 <td class='base' nowrap='nowrap'><input type='text' name='ROOTCERT_CITY' value=' $cgiparams {'ROOTCERT_CITY'}' size='32' /></td></tr>
1101 <tr><td class='base'> $Lang ::tr{'state or province'}:</td>
1102 <td class='base' nowrap='nowrap'><input type='text' name='ROOTCERT_STATE' value=' $cgiparams {'ROOTCERT_STATE'}' size='32' /></td></tr>
1103 <tr><td class='base'> $Lang ::tr{'country'}:</td>
1104 <td class='base'><select name='ROOTCERT_COUNTRY'>
1107 foreach my $country ( sort keys %{ Countries
:: countries
}) {
1108 print "<option value=' $Countries ::countries{ $country }'" ;
1109 if ( $Countries :: countries
{ $country } eq $cgiparams { 'ROOTCERT_COUNTRY' } ) {
1110 print " selected='selected'" ;
1112 print "> $country </option>" ;
1116 <tr><td class='base'> $Lang ::tr{'vpn subjectaltname'} (subjectAltName=email:*,URI:*,DNS:*,RID:*)</td>
1117 <td class='base' nowrap='nowrap'><input type='text' name='SUBJECTALTNAME' value=' $cgiparams {'SUBJECTALTNAME'}' size='32' /></td></tr>
1119 <td><br /><input type='submit' name='ACTION' value=' $Lang ::tr{'generate root/host certificates'}' /><br /><br /></td></tr>
1120 <tr><td class='base' colspan='2' align='left'>
1121 <b><font color='${Header::colourred}'> $Lang ::tr{'capswarning'}</font></b>:
1122 $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'}
1124 <tr><td colspan='2'><hr></td></tr>
1125 <tr><td class='base' nowrap='nowrap'> $Lang ::tr{'upload p12 file'}:</td>
1126 <td nowrap='nowrap'><input type='file' name='FH' size='32' /></td></tr>
1127 <tr><td class='base'> $Lang ::tr{'pkcs12 file password'}:</td>
1128 <td class='base' nowrap='nowrap'><input type='password' name='P12_PASS' value=' $cgiparams {'P12_PASS'}' size='32' /></td></tr>
1130 <td><input type='submit' name='ACTION' value=' $Lang ::tr{'upload p12 file'}' /></td></tr>
1131 <tr><td class='base' colspan='2' align='left'>
1132 <img src='/blob.gif' alt='*' /> $Lang ::tr{'required field'}</td></tr>
1136 & Header
:: closebox
();
1137 & Header
:: closebigbox
();
1138 & Header
:: closepage
();
1143 system ( '/usr/local/bin/ipsecctrl' , 'S' );
1148 ### Export PKCS12 file to browser
1150 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'download pkcs12 file' }) {
1151 & General
:: readhasharray
( "${General::swroot}/vpn/config" , \
%confighash );
1152 print "Content-Type: application/force-download \n " ;
1153 print "Content-Disposition: attachment; filename=" . $confighash { $cgiparams { 'KEY' }}[ 1 ] . ".p12 \r\n " ;
1154 print "Content-Type: application/octet-stream \r\n\r\n " ;
1155 print `/bin/cat ${General::swroot}/certs/ $confighash { $cgiparams {'KEY'}}[1].p12` ;
1159 ### Display certificate
1161 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'show certificate' }) {
1162 & General
:: readhasharray
( "${General::swroot}/vpn/config" , \
%confighash );
1164 if ( - f
"${General::swroot}/certs/ $confighash { $cgiparams {'KEY'}}[1]cert.pem" ) {
1165 & Header
:: showhttpheaders
();
1166 & Header
:: openpage
( $Lang :: tr
{ 'ipsec' }, 1 , '' );
1167 & Header
:: openbigbox
( '100%' , 'left' , '' , '' );
1168 & Header
:: openbox
( '100%' , 'left' , " $Lang ::tr{'cert'}:" );
1169 my $output = `/usr/bin/openssl x509 -text -in ${General::swroot}/certs/ $confighash { $cgiparams {'KEY'}}[1]cert.pem` ;
1170 $output = & Header
:: cleanhtml
( $output , "y" );
1171 print "<pre> $output </pre> \n " ;
1172 & Header
:: closebox
();
1173 print "<div align='center'><a href='/cgi-bin/vpnmain.cgi'> $Lang ::tr{'back'}</a></div>" ;
1174 & Header
:: closebigbox
();
1175 & Header
:: closepage
();
1180 ### Export Certificate to browser
1182 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'download certificate' }) {
1183 & General
:: readhasharray
( "${General::swroot}/vpn/config" , \
%confighash );
1185 if ( - f
"${General::swroot}/certs/ $confighash { $cgiparams {'KEY'}}[1]cert.pem" ) {
1186 print "Content-Type: application/force-download \n " ;
1187 print "Content-Disposition: attachment; filename=" . $confighash { $cgiparams { 'KEY' }}[ 1 ] . "cert.pem \n\n " ;
1188 print `/bin/cat ${General::swroot}/certs/ $confighash { $cgiparams {'KEY'}}[1]cert.pem` ;
1193 ### Enable/Disable connection
1195 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'toggle enable disable' }) {
1197 & General
:: readhash
( "${General::swroot}/vpn/settings" , \
%vpnsettings );
1198 & General
:: readhasharray
( "${General::swroot}/vpn/config" , \
%confighash );
1200 if ( $confighash { $cgiparams { 'KEY' }}) {
1201 if ( $confighash { $cgiparams { 'KEY' }}[ 0 ] eq 'off' ) {
1202 $confighash { $cgiparams { 'KEY' }}[ 0 ] = 'on' ;
1203 & General
:: writehasharray
( "${General::swroot}/vpn/config" , \
%confighash );
1205 system ( '/usr/local/bin/ipsecctrl' , 'S' , $cgiparams { 'KEY' }) if (& vpnenabled
);
1207 system ( '/usr/local/bin/ipsecctrl' , 'D' , $cgiparams { 'KEY' }) if (& vpnenabled
);
1208 $confighash { $cgiparams { 'KEY' }}[ 0 ] = 'off' ;
1209 & General
:: writehasharray
( "${General::swroot}/vpn/config" , \
%confighash );
1214 $errormessage = $Lang :: tr
{ 'invalid key' };
1218 ### Restart connection
1220 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'restart' }) {
1221 & General
:: readhash
( "${General::swroot}/vpn/settings" , \
%vpnsettings );
1222 & General
:: readhasharray
( "${General::swroot}/vpn/config" , \
%confighash );
1224 if ( $confighash { $cgiparams { 'KEY' }}) {
1226 system ( '/usr/local/bin/ipsecctrl' , 'S' , $cgiparams { 'KEY' });
1230 $errormessage = $Lang :: tr
{ 'invalid key' };
1234 ### Remove connection
1236 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'remove' }) {
1237 & General
:: readhash
( "${General::swroot}/vpn/settings" , \
%vpnsettings );
1238 & General
:: readhasharray
( "${General::swroot}/vpn/config" , \
%confighash );
1240 if ( $confighash { $cgiparams { 'KEY' }}) {
1241 system ( '/usr/local/bin/ipsecctrl' , 'D' , $cgiparams { 'KEY' }) if (& vpnenabled
);
1242 unlink ( "${General::swroot}/certs/ $confighash { $cgiparams {'KEY'}}[1]cert.pem" );
1243 unlink ( "${General::swroot}/certs/ $confighash { $cgiparams {'KEY'}}[1].p12" );
1244 delete $confighash { $cgiparams { 'KEY' }};
1245 & General
:: writehasharray
( "${General::swroot}/vpn/config" , \
%confighash );
1248 $errormessage = $Lang :: tr
{ 'invalid key' };
1250 & General
:: firewall_reload
();
1252 ### Choose between adding a host-net or net-net connection
1254 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'add' } && $cgiparams { 'TYPE' } eq '' ) {
1255 & Header
:: showhttpheaders
();
1256 & Header
:: openpage
( $Lang :: tr
{ 'ipsec' }, 1 , '' );
1257 & Header
:: openbigbox
( '100%' , 'left' , '' , '' );
1258 & Header
:: openbox
( '100%' , 'left' , $Lang :: tr
{ 'connection type' });
1260 <form method='post' action=' $ENV {'SCRIPT_NAME'}'>
1261 <b> $Lang ::tr{'connection type'}:</b><br />
1263 <tr><td><input type='radio' name='TYPE' value='host' checked='checked' /></td>
1264 <td class='base'> $Lang ::tr{'host to net vpn'}</td>
1266 <td><input type='radio' name='TYPE' value='net' /></td>
1267 <td class='base'> $Lang ::tr{'net to net vpn'}</td>
1269 <td align='center' colspan='2'><input type='submit' name='ACTION' value=' $Lang ::tr{'add'}' /></td>
1274 & Header
:: closebox
();
1275 & Header
:: closebigbox
();
1276 & Header
:: closepage
();
1279 ### Adding/Editing/Saving a connection
1281 } elsif (( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'add' }) ||
1282 ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'edit' }) ||
1283 ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'save' } && $cgiparams { 'ADVANCED' } eq '' )) {
1285 & General
:: readhash
( "${General::swroot}/vpn/settings" , \
%vpnsettings );
1286 & General
:: readhasharray
( "${General::swroot}/vpn/caconfig" , \
%cahash );
1287 & General
:: readhasharray
( "${General::swroot}/vpn/config" , \
%confighash );
1289 if ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'edit' }) {
1290 if (! $confighash { $cgiparams { 'KEY' }}[ 0 ]) {
1291 $errormessage = $Lang :: tr
{ 'invalid key' };
1294 $cgiparams { 'ENABLED' } = $confighash { $cgiparams { 'KEY' }}[ 0 ];
1295 $cgiparams { 'NAME' } = $confighash { $cgiparams { 'KEY' }}[ 1 ];
1296 $cgiparams { 'TYPE' } = $confighash { $cgiparams { 'KEY' }}[ 3 ];
1297 $cgiparams { 'AUTH' } = $confighash { $cgiparams { 'KEY' }}[ 4 ];
1298 $cgiparams { 'PSK' } = $confighash { $cgiparams { 'KEY' }}[ 5 ];
1299 #$cgiparams{'free'} = $confighash{$cgiparams{'KEY'}}[6];
1300 $cgiparams { 'LOCAL_ID' } = $confighash { $cgiparams { 'KEY' }}[ 7 ];
1301 my @local_subnets = split ( "," , $confighash { $cgiparams { 'KEY' }}[ 8 ]);
1302 $cgiparams { 'LOCAL_SUBNET' } = join ( /\|/ , @local_subnets );
1303 $cgiparams { 'REMOTE_ID' } = $confighash { $cgiparams { 'KEY' }}[ 9 ];
1304 $cgiparams { 'REMOTE' } = $confighash { $cgiparams { 'KEY' }}[ 10 ];
1305 my @remote_subnets = split ( "," , $confighash { $cgiparams { 'KEY' }}[ 11 ]);
1306 $cgiparams { 'REMOTE_SUBNET' } = join ( /\|/ , @remote_subnets );
1307 $cgiparams { 'REMARK' } = $confighash { $cgiparams { 'KEY' }}[ 25 ];
1308 $cgiparams { 'DPD_ACTION' } = $confighash { $cgiparams { 'KEY' }}[ 27 ];
1309 $cgiparams { 'IKE_VERSION' } = $confighash { $cgiparams { 'KEY' }}[ 29 ];
1310 $cgiparams { 'IKE_ENCRYPTION' } = $confighash { $cgiparams { 'KEY' }}[ 18 ];
1311 $cgiparams { 'IKE_INTEGRITY' } = $confighash { $cgiparams { 'KEY' }}[ 19 ];
1312 $cgiparams { 'IKE_GROUPTYPE' } = $confighash { $cgiparams { 'KEY' }}[ 20 ];
1313 $cgiparams { 'IKE_LIFETIME' } = $confighash { $cgiparams { 'KEY' }}[ 16 ];
1314 $cgiparams { 'ESP_ENCRYPTION' } = $confighash { $cgiparams { 'KEY' }}[ 21 ];
1315 $cgiparams { 'ESP_INTEGRITY' } = $confighash { $cgiparams { 'KEY' }}[ 22 ];
1316 $cgiparams { 'ESP_GROUPTYPE' } = $confighash { $cgiparams { 'KEY' }}[ 23 ];
1317 if ( $cgiparams { 'ESP_GROUPTYPE' } eq "" ) {
1318 $cgiparams { 'ESP_GROUPTYPE' } = $cgiparams { 'IKE_GROUPTYPE' };
1320 $cgiparams { 'ESP_KEYLIFE' } = $confighash { $cgiparams { 'KEY' }}[ 17 ];
1321 $cgiparams { 'COMPRESSION' } = $confighash { $cgiparams { 'KEY' }}[ 13 ];
1322 $cgiparams { 'ONLY_PROPOSED' } = $confighash { $cgiparams { 'KEY' }}[ 24 ];
1323 $cgiparams { 'PFS' } = $confighash { $cgiparams { 'KEY' }}[ 28 ];
1324 $cgiparams { 'DPD_TIMEOUT' } = $confighash { $cgiparams { 'KEY' }}[ 30 ];
1325 $cgiparams { 'DPD_DELAY' } = $confighash { $cgiparams { 'KEY' }}[ 31 ];
1326 $cgiparams { 'FORCE_MOBIKE' } = $confighash { $cgiparams { 'KEY' }}[ 32 ];
1327 $cgiparams { 'INACTIVITY_TIMEOUT' } = $confighash { $cgiparams { 'KEY' }}[ 34 ];
1328 $cgiparams { 'MODE' } = $confighash { $cgiparams { 'KEY' }}[ 35 ];
1329 $cgiparams { 'INTERFACE_MODE' } = $confighash { $cgiparams { 'KEY' }}[ 36 ];
1331 if (! $cgiparams { 'DPD_DELAY' }) {
1332 $cgiparams { 'DPD_DELAY' } = 30 ;
1335 if (! $cgiparams { 'DPD_TIMEOUT' }) {
1336 $cgiparams { 'DPD_TIMEOUT' } = 120 ;
1339 if ( $cgiparams { 'INACTIVITY_TIMEOUT' } eq "" ) {
1340 $cgiparams { 'INACTIVITY_TIMEOUT' } = 900 ;
1343 if ( $cgiparams { 'MODE' } eq "" ) {
1344 $cgiparams { 'MODE' } = "tunnel" ;
1347 } elsif ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'save' }) {
1348 $cgiparams { 'REMARK' } = & Header
:: cleanhtml
( $cgiparams { 'REMARK' });
1349 if ( $cgiparams { 'TYPE' } !~ /^(host|net)$/ ) {
1350 $errormessage = $Lang :: tr
{ 'connection type is invalid' };
1354 if ( $cgiparams { 'NAME' } !~ /^[a-zA-Z0-9]+$/ ) {
1355 $errormessage = $Lang :: tr
{ 'name must only contain characters' };
1359 if ( $cgiparams { 'NAME' } =~ /^(host|01|block|private|clear|packetdefault)$/ ) {
1360 $errormessage = $Lang :: tr
{ 'name is invalid' };
1364 if ( length ( $cgiparams { 'NAME' }) > 60 ) {
1365 $errormessage = $Lang :: tr
{ 'name too long' };
1369 # Check if there is no other entry with this name
1370 if (! $cgiparams { 'KEY' }) { #only for add
1371 foreach my $key ( keys %confighash ) {
1372 if ( $confighash { $key }[ 1 ] eq $cgiparams { 'NAME' }) {
1373 $errormessage = $Lang :: tr
{ 'a connection with this name already exists' };
1379 if (( $cgiparams { 'TYPE' } eq 'net' ) && (! $cgiparams { 'REMOTE' })) {
1380 $errormessage = $Lang :: tr
{ 'invalid input for remote host/ip' };
1384 if ( $cgiparams { 'REMOTE' }) {
1385 if (( $cgiparams { 'REMOTE' } ne ' %any ' ) && (! & General
:: validip
( $cgiparams { 'REMOTE' }))) {
1386 if (! & General
:: validfqdn
( $cgiparams { 'REMOTE' })) {
1387 $errormessage = $Lang :: tr
{ 'invalid input for remote host/ip' };
1390 if (& valid_dns_host
( $cgiparams { 'REMOTE' })) {
1391 $warnmessage = " $Lang ::tr{'check vpn lr'} $cgiparams {'REMOTE'}. $Lang ::tr{'dns check failed'}" ;
1397 my @local_subnets = split ( "," , $cgiparams { 'LOCAL_SUBNET' });
1398 foreach my $subnet ( @local_subnets ) {
1399 unless (& Network
:: check_subnet
( $subnet )) {
1400 $errormessage = $Lang :: tr
{ 'local subnet is invalid' };
1405 # Allow only one roadwarrior/psk without remote IP-address
1406 if ( $cgiparams { 'REMOTE' } eq '' && $cgiparams { 'AUTH' } eq 'psk' ) {
1407 foreach my $key ( keys %confighash ) {
1408 if ( ( $cgiparams { 'KEY' } ne $key ) &&
1409 ( $confighash { $key }[ 4 ] eq 'psk' ) &&
1410 ( $confighash { $key }[ 10 ] eq '' ) ) {
1411 $errormessage = $Lang :: tr
{ 'you can only define one roadwarrior connection when using pre-shared key authentication' };
1417 if ( $cgiparams { 'TYPE' } eq 'net' ) {
1418 my @remote_subnets = split ( "," , $cgiparams { 'REMOTE_SUBNET' });
1419 foreach my $subnet ( @remote_subnets ) {
1420 unless (& Network
:: check_subnet
( $subnet )) {
1421 $errormessage = $Lang :: tr
{ 'remote subnet is invalid' };
1427 if ( $cgiparams { 'ENABLED' } !~ /^(on|off)$/ ) {
1428 $errormessage = $Lang :: tr
{ 'invalid input' };
1431 if ( $cgiparams { 'EDIT_ADVANCED' } !~ /^(on|off)$/ ) {
1432 $errormessage = $Lang :: tr
{ 'invalid input' };
1436 # Allow nothing or a string (DN,FDQN,) beginning with @
1437 # with no comma but slashes between RID eg @O=FR/C=Paris/OU=myhome/CN=franck
1438 if ( ( $cgiparams { 'LOCAL_ID' } !~ /^(|[\w.-]*@[\w. =*\/ -]+| \d
+ \
. \d
+ \
. \d
+ \
. \d
+)$/) ||
1439 ( $cgiparams { 'REMOTE_ID' } !~ /^(|[\w.-]*@[\w. =*\/ -]+| \d
+ \
. \d
+ \
. \d
+ \
. \d
+)$/) ||
1440 (( $cgiparams { 'REMOTE_ID' } eq $cgiparams { 'LOCAL_ID' }) && ( $cgiparams { 'LOCAL_ID' } ne '' ))
1442 $errormessage = $Lang :: tr
{ 'invalid local-remote id' } . '<br />' .
1443 'DER_ASN1_DN: @c =FR/ou=Paris/ou=Home/cn=*<br />' .
1444 'FQDN: @ipfire .org<br />' .
1445 'USER_FQDN: info @ipfire .org<br />' .
1446 'IPV4_ADDR: 123.123.123.123' ;
1449 # If Auth is DN, verify existance of Remote ID.
1450 if ( $cgiparams { 'REMOTE_ID' } eq '' && (
1451 $cgiparams { 'AUTH' } eq 'auth-dn' || # while creation
1452 $confighash { $cgiparams { 'KEY' }}[ 2 ] eq ' %auth -dn' )){ # while editing
1453 $errormessage = $Lang :: tr
{ 'vpn missing remote id' };
1457 if ( $cgiparams { 'TYPE' } eq 'net' ){
1458 $warnmessage =& General
:: checksubnets
( '' , $cgiparams { 'REMOTE_SUBNET' }, 'ipsec' );
1459 if ( $warnmessage ne '' ){
1460 $warnmessage = $Lang :: tr
{ 'remote subnet' }. " ( $cgiparams {'REMOTE_SUBNET'}) <br>" . $warnmessage ;
1464 if ( $cgiparams { 'AUTH' } eq 'psk' ) {
1465 if (! length ( $cgiparams { 'PSK' }) ) {
1466 $errormessage = $Lang :: tr
{ 'pre-shared key is too short' };
1469 if ( $cgiparams { 'PSK' } =~ /'/ ) {
1470 $cgiparams { 'PSK' } =~ tr/'/ / ;
1471 $errormessage = $Lang :: tr
{ 'invalid characters found in pre-shared key' };
1474 } elsif ( $cgiparams { 'AUTH' } eq 'certreq' ) {
1475 if ( $cgiparams { 'KEY' }) {
1476 $errormessage = $Lang :: tr
{ 'cant change certificates' };
1479 if ( ref ( $cgiparams { 'FH' }) ne 'Fh' ) {
1480 $errormessage = $Lang :: tr
{ 'there was no file upload' };
1484 # Move uploaded certificate request to a temporary file
1485 ( my $fh , my $filename ) = tempfile
( );
1486 if ( copy
( $cgiparams { 'FH' }, $fh ) != 1 ) {
1491 # Sign the certificate request
1492 & General
:: log ( "ipsec" , "Signing your cert $cgiparams {'NAME'}..." );
1493 my $opt = " ca -md sha256 -days 999999" ;
1494 $opt .= " -batch -notext" ;
1495 $opt .= " -in $filename " ;
1496 $opt .= " -out ${General::swroot}/certs/ $cgiparams {'NAME'}cert.pem" ;
1498 if ( $errormessage = & callssl
( $opt ) ) {
1500 unlink ( "${General::swroot}/certs/ $cgiparams {'NAME'}cert.pem" );
1501 & cleanssldatabase
();
1505 & cleanssldatabase
();
1508 $cgiparams { 'CERT_NAME' } = getCNfromcert
( "${General::swroot}/certs/ $cgiparams {'NAME'}cert.pem" );
1509 if ( $cgiparams { 'CERT_NAME' } eq '' ) {
1510 $errormessage = $Lang :: tr
{ 'could not retrieve common name from certificate' };
1513 } elsif ( $cgiparams { 'AUTH' } eq 'pkcs12' ) {
1514 & General
:: log ( "ipsec" , "Importing from p12..." );
1516 if ( ref ( $cgiparams { 'FH' }) ne 'Fh' ) {
1517 $errormessage = $Lang :: tr
{ 'there was no file upload' };
1518 goto ROOTCERT_ERROR
;
1521 # Move uploaded certificate request to a temporary file
1522 ( my $fh , my $filename ) = tempfile
( );
1523 if ( copy
( $cgiparams { 'FH' }, $fh ) != 1 ) {
1525 goto ROOTCERT_ERROR
;
1528 # Extract the CA certificate from the file
1529 & General
:: log ( "ipsec" , "Extracting caroot from p12..." );
1530 if ( open ( STDIN
, "-|" )) {
1531 my $opt = " pkcs12 -cacerts -nokeys" ;
1532 $opt .= " -in $filename " ;
1533 $opt .= " -out /tmp/newcacert" ;
1534 $errormessage = & callssl
( $opt );
1536 print " $cgiparams {'P12_PASS'} \n " ;
1540 # Extract the Host certificate from the file
1541 if (! $errormessage ) {
1542 & General
:: log ( "ipsec" , "Extracting host cert from p12..." );
1543 if ( open ( STDIN
, "-|" )) {
1544 my $opt = " pkcs12 -clcerts -nokeys" ;
1545 $opt .= " -in $filename " ;
1546 $opt .= " -out /tmp/newhostcert" ;
1547 $errormessage = & callssl
( $opt );
1549 print " $cgiparams {'P12_PASS'} \n " ;
1554 if (! $errormessage ) {
1555 & General
:: log ( "ipsec" , "Moving cacert..." );
1556 #If CA have new subject, add it to our list of CA
1557 my $casubject = & Header
:: cleanhtml
( getsubjectfromcert
( '/tmp/newcacert' ));
1559 foreach my $x ( keys %cahash ) {
1560 $casubject = '' if ( $cahash { $x }[ 1 ] eq $casubject );
1561 unshift ( @names , $cahash { $x }[ 0 ]);
1563 if ( $casubject ) { # a new one!
1564 my $temp = `/usr/bin/openssl x509 -text -in /tmp/newcacert` ;
1565 if ( $temp !~ /CA:TRUE/i ) {
1566 $errormessage = $Lang :: tr
{ 'not a valid ca certificate' };
1568 #compute a name for it
1570 while ( grep ( /Imported-$idx/ , @names ) ) { $idx ++};
1571 $cgiparams { 'CA_NAME' }= "Imported- $idx " ;
1572 $cgiparams { 'CERT_NAME' }=& Header
:: cleanhtml
( getCNfromcert
( '/tmp/newhostcert' ));
1573 move
( "/tmp/newcacert" , "${General::swroot}/ca/ $cgiparams {'CA_NAME'}cert.pem" );
1574 $errormessage = " $Lang ::tr{'certificate file move failed'}: $!" if ($ ?
ne 0 );
1575 if (! $errormessage ) {
1576 my $key = & General
:: findhasharraykey
( \
%cahash );
1577 $cahash { $key }[ 0 ] = $cgiparams { 'CA_NAME' };
1578 $cahash { $key }[ 1 ] = $casubject ;
1579 & General
:: writehasharray
( "${General::swroot}/vpn/caconfig" , \
%cahash );
1580 system ( '/usr/local/bin/ipsecctrl' , 'R' );
1585 if (! $errormessage ) {
1586 & General
:: log ( "ipsec" , "Moving host cert..." );
1587 move
( "/tmp/newhostcert" , "${General::swroot}/certs/ $cgiparams {'NAME'}cert.pem" );
1588 $errormessage = " $Lang ::tr{'certificate file move failed'}: $!" if ($ ?
ne 0 );
1593 unlink ( '/tmp/newcacert' );
1594 unlink ( '/tmp/newhostcert' );
1595 if ( $errormessage ) {
1596 unlink ( "${General::swroot}/ca/ $cgiparams {'CA_NAME'}cert.pem" );
1597 unlink ( "${General::swroot}/certs/ $cgiparams {'NAME'}cert.pem" );
1600 & General
:: log ( "ipsec" , "p12 import completed!" );
1601 } elsif ( $cgiparams { 'AUTH' } eq 'certfile' ) {
1602 if ( $cgiparams { 'KEY' }) {
1603 $errormessage = $Lang :: tr
{ 'cant change certificates' };
1606 if ( ref ( $cgiparams { 'FH' }) ne 'Fh' ) {
1607 $errormessage = $Lang :: tr
{ 'there was no file upload' };
1610 # Move uploaded certificate to a temporary file
1611 ( my $fh , my $filename ) = tempfile
( );
1612 if ( copy
( $cgiparams { 'FH' }, $fh ) != 1 ) {
1617 # Verify the certificate has a valid CA and move it
1618 & General
:: log ( "ipsec" , "Validating imported cert against our known CA..." );
1619 my $validca = 1 ; #assume ok
1620 my $test = `/usr/bin/openssl verify -CAfile ${General::swroot}/ca/cacert.pem $filename ` ;
1621 if ( $test !~ /: OK/ ) {
1623 foreach my $key ( keys %cahash ) {
1624 $test = `/usr/bin/openssl verify -CAfile ${General::swroot}/ca/ $cahash { $key }[0]cert.pem $filename ` ;
1625 if ( $test =~ /: OK/ ) {
1632 $errormessage = $Lang :: tr
{ 'certificate does not have a valid ca associated with it' };
1636 move
( $filename , "${General::swroot}/certs/ $cgiparams {'NAME'}cert.pem" );
1638 $errormessage = " $Lang ::tr{'certificate file move failed'}: $!" ;
1644 $cgiparams { 'CERT_NAME' } = getCNfromcert
( "${General::swroot}/certs/ $cgiparams {'NAME'}cert.pem" );
1645 if ( $cgiparams { 'CERT_NAME' } eq '' ) {
1646 unlink ( "${General::swroot}/certs/ $cgiparams {'NAME'}cert.pem" );
1647 $errormessage = $Lang :: tr
{ 'could not retrieve common name from certificate' };
1650 } elsif ( $cgiparams { 'AUTH' } eq 'certgen' ) {
1651 if ( $cgiparams { 'KEY' }) {
1652 $errormessage = $Lang :: tr
{ 'cant change certificates' };
1655 # Validate input since the form was submitted
1656 if ( length ( $cgiparams { 'CERT_NAME' }) > 60 ) {
1657 $errormessage = $Lang :: tr
{ 'name too long' };
1660 if ( $cgiparams { 'CERT_NAME' } !~ /^[a-zA-Z0-9 ,\.\-_]+$/ ) {
1661 $errormessage = $Lang :: tr
{ 'invalid input for name' };
1664 if ( $cgiparams { 'CERT_EMAIL' } ne '' && (! & General
:: validemail
( $cgiparams { 'CERT_EMAIL' }))) {
1665 $errormessage = $Lang :: tr
{ 'invalid input for e-mail address' };
1668 if ( length ( $cgiparams { 'CERT_EMAIL' }) > 40 ) {
1669 $errormessage = $Lang :: tr
{ 'e-mail address too long' };
1672 if ( $cgiparams { 'CERT_OU' } ne '' && $cgiparams { 'CERT_OU' } !~ /^[a-zA-Z0-9 ,\.\-_]*$/ ) {
1673 $errormessage = $Lang :: tr
{ 'invalid input for department' };
1676 if ( length ( $cgiparams { 'CERT_ORGANIZATION' }) > 60 ) {
1677 $errormessage = $Lang :: tr
{ 'organization too long' };
1680 if ( $cgiparams { 'CERT_ORGANIZATION' } !~ /^[a-zA-Z0-9 ,\.\-_]+$/ ) {
1681 $errormessage = $Lang :: tr
{ 'invalid input for organization' };
1684 if ( $cgiparams { 'CERT_CITY' } ne '' && $cgiparams { 'CERT_CITY' } !~ /^[a-zA-Z0-9 ,\.\-_]*$/ ) {
1685 $errormessage = $Lang :: tr
{ 'invalid input for city' };
1688 if ( $cgiparams { 'CERT_STATE' } ne '' && $cgiparams { 'CERT_STATE' } !~ /^[a-zA-Z0-9 ,\.\-_]*$/ ) {
1689 $errormessage = $Lang :: tr
{ 'invalid input for state or province' };
1692 if ( $cgiparams { 'CERT_COUNTRY' } !~ /^[A-Z]*$/ ) {
1693 $errormessage = $Lang :: tr
{ 'invalid input for country' };
1696 #the exact syntax is a list comma separated of
1697 # email:any-validemail
1698 # URI: a uniform resource indicator
1699 # DNS: a DNS domain name
1700 # RID: a registered OBJECT IDENTIFIER
1702 # example: email:franck@foo.com,IP:10.0.0.10,DNS:franck.foo.com
1704 if ( $cgiparams { 'SUBJECTALTNAME' } ne '' && $cgiparams { 'SUBJECTALTNAME' } !~ /^(email|URI|DNS|RID|IP):[a-zA-Z0-9 :\/ , \
. \
- _@
]*$/) {
1705 $errormessage = $Lang :: tr
{ 'vpn altname syntax' };
1709 if ( length ( $cgiparams { 'CERT_PASS1' }) < 5 ) {
1710 $errormessage = $Lang :: tr
{ 'password too short' };
1713 if ( $cgiparams { 'CERT_PASS1' } ne $cgiparams { 'CERT_PASS2' }) {
1714 $errormessage = $Lang :: tr
{ 'passwords do not match' };
1718 # Replace empty strings with a .
1719 ( my $ou = $cgiparams { 'CERT_OU' }) =~ s/^\s*$/\./ ;
1720 ( my $city = $cgiparams { 'CERT_CITY' }) =~ s/^\s*$/\./ ;
1721 ( my $state = $cgiparams { 'CERT_STATE' }) =~ s/^\s*$/\./ ;
1723 # Create the Client certificate request
1724 & General
:: log ( "ipsec" , "Creating a cert..." );
1726 if ( open ( STDIN
, "-|" )) {
1727 my $opt = " req -nodes -rand /proc/interrupts:/proc/net/rt_cache" ;
1728 $opt .= " -newkey rsa:2048" ;
1729 $opt .= " -keyout ${General::swroot}/certs/ $cgiparams {'NAME'}key.pem" ;
1730 $opt .= " -out ${General::swroot}/certs/ $cgiparams {'NAME'}req.pem" ;
1732 if ( $errormessage = & callssl
( $opt ) ) {
1733 unlink ( "${General::swroot}/certs/ $cgiparams {'NAME'}key.pem" );
1734 unlink ( "${General::swroot}/certs/ $cgiparams {'NAME'}req.pem" );
1738 print " $cgiparams {'CERT_COUNTRY'} \n " ;
1741 print " $cgiparams {'CERT_ORGANIZATION'} \n " ;
1743 print " $cgiparams {'CERT_NAME'} \n " ;
1744 print " $cgiparams {'CERT_EMAIL'} \n " ;
1750 # Sign the client certificate request
1751 & General
:: log ( "ipsec" , "Signing the cert $cgiparams {'NAME'}..." );
1753 #No easy way for specifying the contain of subjectAltName without writing a config file...
1754 my ( $fh , $v3extname ) = tempfile
( '/tmp/XXXXXXXX' );
1756 basicConstraints=CA:FALSE
1757 nsComment="OpenSSL Generated Certificate"
1758 subjectKeyIdentifier=hash
1759 extendedKeyUsage=clientAuth
1760 authorityKeyIdentifier=keyid,issuer:always
1763 print $fh "subjectAltName= $cgiparams {'SUBJECTALTNAME'}" if ( $cgiparams { 'SUBJECTALTNAME' });
1766 my $opt = " ca -md sha256 -days 999999 -batch -notext" ;
1767 $opt .= " -in ${General::swroot}/certs/ $cgiparams {'NAME'}req.pem" ;
1768 $opt .= " -out ${General::swroot}/certs/ $cgiparams {'NAME'}cert.pem" ;
1769 $opt .= " -extfile $v3extname " ;
1771 if ( $errormessage = & callssl
( $opt ) ) {
1772 unlink ( $v3extname );
1773 unlink ( "${General::swroot}/certs/ $cgiparams {'NAME'}key.pem" );
1774 unlink ( "${General::swroot}/certs/ $cgiparams {'NAME'}req.pem" );
1775 unlink ( "${General::swroot}/certs/ $cgiparams {'NAME'}cert.pem" );
1776 & cleanssldatabase
();
1779 unlink ( $v3extname );
1780 unlink ( "${General::swroot}/certs/ $cgiparams {'NAME'}req.pem" );
1781 & cleanssldatabase
();
1784 # Create the pkcs12 file
1785 & General
:: log ( "ipsec" , "Packing a pkcs12 file..." );
1786 $opt = " pkcs12 -export" ;
1787 $opt .= " -inkey ${General::swroot}/certs/ $cgiparams {'NAME'}key.pem" ;
1788 $opt .= " -in ${General::swroot}/certs/ $cgiparams {'NAME'}cert.pem" ;
1789 $opt .= " -name \" $cgiparams {'NAME'} \" " ;
1790 $opt .= " -passout pass: $cgiparams {'CERT_PASS1'}" ;
1791 $opt .= " -certfile ${General::swroot}/ca/cacert.pem" ;
1792 $opt .= " -caname \" $vpnsettings {'ROOTCERT_ORGANIZATION'} CA \" " ;
1793 $opt .= " -out ${General::swroot}/certs/ $cgiparams {'NAME'}.p12" ;
1795 if ( $errormessage = & callssl
( $opt ) ) {
1796 unlink ( "${General::swroot}/certs/ $cgiparams {'NAME'}key.pem" );
1797 unlink ( "${General::swroot}/certs/ $cgiparams {'NAME'}cert.pem" );
1798 unlink ( "${General::swroot}/certs/ $cgiparams {'NAME'}.p12" );
1801 unlink ( "${General::swroot}/certs/ $cgiparams {'NAME'}key.pem" );
1803 } elsif ( $cgiparams { 'AUTH' } eq 'cert' ) {
1804 ; # Nothing, just editing
1805 } elsif ( $cgiparams { 'AUTH' } eq 'auth-dn' ) {
1806 $cgiparams { 'CERT_NAME' } = ' %auth -dn' ; # a special value saying 'no cert file'
1808 $errormessage = $Lang :: tr
{ 'invalid input for authentication method' };
1812 # 1)Error message here is not accurate.
1813 # 2)Test is superfluous, openswan can reference same cert multiple times
1814 # 3)Present since initial version (1.3.2.11), it isn't a bug correction
1815 # Check if there is no other entry with this certificate name
1816 #if ((! $cgiparams{'KEY'}) && ($cgiparams{'AUTH'} ne 'psk') && ($cgiparams{'AUTH'} ne 'auth-dn')) {
1817 # foreach my $key (keys %confighash) {
1818 # if ($confighash{$key}[2] eq $cgiparams{'CERT_NAME'}) {
1819 # $errormessage = $Lang::tr{'a connection with this common name already exists'};
1820 # goto VPNCONF_ERROR;
1826 my $key = $cgiparams { 'KEY' };
1828 $key = & General
:: findhasharraykey
( \
%confighash );
1829 foreach my $i ( 0 .. 36 ) { $confighash { $key }[ $i ] = "" ;}
1831 $confighash { $key }[ 0 ] = $cgiparams { 'ENABLED' };
1832 $confighash { $key }[ 1 ] = $cgiparams { 'NAME' };
1833 if ((! $cgiparams { 'KEY' }) && $cgiparams { 'AUTH' } ne 'psk' ) {
1834 $confighash { $key }[ 2 ] = $cgiparams { 'CERT_NAME' };
1836 $confighash { $key }[ 3 ] = $cgiparams { 'TYPE' };
1837 if ( $cgiparams { 'AUTH' } eq 'psk' ) {
1838 $confighash { $key }[ 4 ] = 'psk' ;
1839 $confighash { $key }[ 5 ] = $cgiparams { 'PSK' };
1841 $confighash { $key }[ 4 ] = 'cert' ;
1843 if ( $cgiparams { 'TYPE' } eq 'net' ) {
1844 my @remote_subnets = split ( "," , $cgiparams { 'REMOTE_SUBNET' });
1845 $confighash { $key }[ 11 ] = join ( '|' , @remote_subnets );
1847 $confighash { $key }[ 7 ] = $cgiparams { 'LOCAL_ID' };
1848 my @local_subnets = split ( "," , $cgiparams { 'LOCAL_SUBNET' });
1849 $confighash { $key }[ 8 ] = join ( '|' , @local_subnets );
1850 $confighash { $key }[ 9 ] = $cgiparams { 'REMOTE_ID' };
1851 $confighash { $key }[ 10 ] = $cgiparams { 'REMOTE' };
1852 $confighash { $key }[ 25 ] = $cgiparams { 'REMARK' };
1853 $confighash { $key }[ 26 ] = "" ; # Formerly INTERFACE
1854 $confighash { $key }[ 27 ] = $cgiparams { 'DPD_ACTION' };
1855 $confighash { $key }[ 29 ] = $cgiparams { 'IKE_VERSION' };
1857 # don't forget advanced value
1858 $confighash { $key }[ 18 ] = $cgiparams { 'IKE_ENCRYPTION' };
1859 $confighash { $key }[ 19 ] = $cgiparams { 'IKE_INTEGRITY' };
1860 $confighash { $key }[ 20 ] = $cgiparams { 'IKE_GROUPTYPE' };
1861 $confighash { $key }[ 16 ] = $cgiparams { 'IKE_LIFETIME' };
1862 $confighash { $key }[ 21 ] = $cgiparams { 'ESP_ENCRYPTION' };
1863 $confighash { $key }[ 22 ] = $cgiparams { 'ESP_INTEGRITY' };
1864 $confighash { $key }[ 23 ] = $cgiparams { 'ESP_GROUPTYPE' };
1865 $confighash { $key }[ 17 ] = $cgiparams { 'ESP_KEYLIFE' };
1866 $confighash { $key }[ 12 ] = 'off' ; # $cgiparams{'AGGRMODE'};
1867 $confighash { $key }[ 13 ] = $cgiparams { 'COMPRESSION' };
1868 $confighash { $key }[ 24 ] = $cgiparams { 'ONLY_PROPOSED' };
1869 $confighash { $key }[ 28 ] = $cgiparams { 'PFS' };
1870 $confighash { $key }[ 30 ] = $cgiparams { 'DPD_TIMEOUT' };
1871 $confighash { $key }[ 31 ] = $cgiparams { 'DPD_DELAY' };
1872 $confighash { $key }[ 32 ] = $cgiparams { 'FORCE_MOBIKE' };
1873 $confighash { $key }[ 34 ] = $cgiparams { 'INACTIVITY_TIMEOUT' };
1874 $confighash { $key }[ 35 ] = $cgiparams { 'MODE' };
1875 $confighash { $key }[ 36 ] = $cgiparams { 'INTERFACE_MODE' };
1877 # free unused fields!
1878 $confighash { $key }[ 6 ] = 'off' ;
1879 $confighash { $key }[ 15 ] = 'off' ;
1881 & General
:: writehasharray
( "${General::swroot}/vpn/config" , \
%confighash );
1884 system ( '/usr/local/bin/ipsecctrl' , 'S' , $key );
1887 if ( $cgiparams { 'EDIT_ADVANCED' } eq 'on' ) {
1888 $cgiparams { 'KEY' } = $key ;
1889 $cgiparams { 'ACTION' } = $Lang :: tr
{ 'advanced' };
1892 } else { # add new connection
1893 $cgiparams { 'ENABLED' } = 'on' ;
1894 if ( ! - f
"${General::swroot}/private/cakey.pem" ) {
1895 $cgiparams { 'AUTH' } = 'psk' ;
1896 } elsif ( ! - f
"${General::swroot}/ca/cacert.pem" ) {
1897 $cgiparams { 'AUTH' } = 'certfile' ;
1899 $cgiparams { 'AUTH' } = 'certgen' ;
1901 $cgiparams { 'LOCAL_SUBNET' } = " $netsettings {'GREEN_NETADDRESS'}/ $netsettings {'GREEN_NETMASK'}" ;
1902 $cgiparams { 'CERT_EMAIL' } = $vpnsettings { 'ROOTCERT_EMAIL' };
1903 $cgiparams { 'CERT_OU' } = $vpnsettings { 'ROOTCERT_OU' };
1904 $cgiparams { 'CERT_ORGANIZATION' } = $vpnsettings { 'ROOTCERT_ORGANIZATION' };
1905 $cgiparams { 'CERT_CITY' } = $vpnsettings { 'ROOTCERT_CITY' };
1906 $cgiparams { 'CERT_STATE' } = $vpnsettings { 'ROOTCERT_STATE' };
1907 $cgiparams { 'CERT_COUNTRY' } = $vpnsettings { 'ROOTCERT_COUNTRY' };
1909 # choose appropriate dpd action
1910 if ( $cgiparams { 'TYPE' } eq 'host' ) {
1911 $cgiparams { 'DPD_ACTION' } = 'clear' ;
1913 $cgiparams { 'DPD_ACTION' } = 'restart' ;
1916 if (! $cgiparams { 'DPD_DELAY' }) {
1917 $cgiparams { 'DPD_DELAY' } = 30 ;
1920 if (! $cgiparams { 'DPD_TIMEOUT' }) {
1921 $cgiparams { 'DPD_TIMEOUT' } = 120 ;
1924 if (! $cgiparams { 'FORCE_MOBIKE' }) {
1925 $cgiparams { 'FORCE_MOBIKE' } = 'no' ;
1928 # Default IKE Version to v2
1929 if (! $cgiparams { 'IKE_VERSION' }) {
1930 $cgiparams { 'IKE_VERSION' } = 'ikev2' ;
1934 $cgiparams { 'LOCAL_ID' } = '' ;
1935 $cgiparams { 'REMOTE_ID' } = '' ;
1937 #use default advanced value
1938 $cgiparams { 'IKE_ENCRYPTION' } = 'chacha20poly1305|aes256gcm128|aes256gcm96|aes256gcm64|aes256|aes192gcm128|aes192gcm96|aes192gcm64|aes192|aes128gcm128|aes128gcm96|aes128gcm64|aes128' ; #[18];
1939 $cgiparams { 'IKE_INTEGRITY' } = 'sha2_512|sha2_256' ; #[19];
1940 $cgiparams { 'IKE_GROUPTYPE' } = 'curve25519|4096|3072|2048' ; #[20];
1941 $cgiparams { 'IKE_LIFETIME' } = '3' ; #[16];
1942 $cgiparams { 'ESP_ENCRYPTION' } = 'chacha20poly1305|aes256gcm128|aes256gcm96|aes256gcm64|aes256|aes192gcm128|aes192gcm96|aes192gcm64|aes192|aes128gcm128|aes128gcm96|aes128gcm64|aes128' ; #[21];
1943 $cgiparams { 'ESP_INTEGRITY' } = 'sha2_512|sha2_256' ; #[22];
1944 $cgiparams { 'ESP_GROUPTYPE' } = 'curve25519|4096|3072|2048' ; #[23];
1945 $cgiparams { 'ESP_KEYLIFE' } = '1' ; #[17];
1946 $cgiparams { 'COMPRESSION' } = 'off' ; #[13];
1947 $cgiparams { 'ONLY_PROPOSED' } = 'on' ; #[24];
1948 $cgiparams { 'PFS' } = 'on' ; #[28];
1949 $cgiparams { 'INACTIVITY_TIMEOUT' } = 900 ;
1950 $cgiparams { 'MODE' } = "tunnel" ;
1951 $cgiparams { 'INTERFACE_MODE' } = "" ;
1955 $checked { 'ENABLED' }{ 'off' } = '' ;
1956 $checked { 'ENABLED' }{ 'on' } = '' ;
1957 $checked { 'ENABLED' }{ $cgiparams { 'ENABLED' }} = "checked='checked'" ;
1959 $checked { 'EDIT_ADVANCED' }{ 'off' } = '' ;
1960 $checked { 'EDIT_ADVANCED' }{ 'on' } = '' ;
1961 $checked { 'EDIT_ADVANCED' }{ $cgiparams { 'EDIT_ADVANCED' }} = "checked='checked'" ;
1963 $checked { 'AUTH' }{ 'psk' } = '' ;
1964 $checked { 'AUTH' }{ 'certreq' } = '' ;
1965 $checked { 'AUTH' }{ 'certgen' } = '' ;
1966 $checked { 'AUTH' }{ 'certfile' } = '' ;
1967 $checked { 'AUTH' }{ 'pkcs12' } = '' ;
1968 $checked { 'AUTH' }{ 'auth-dn' } = '' ;
1969 $checked { 'AUTH' }{ $cgiparams { 'AUTH' }} = "checked='checked'" ;
1971 & Header
:: showhttpheaders
();
1972 & Header
:: openpage
( $Lang :: tr
{ 'ipsec' }, 1 , '' );
1973 & Header
:: openbigbox
( '100%' , 'left' , '' , $errormessage );
1974 if ( $errormessage ) {
1975 & Header
:: openbox
( '100%' , 'left' , $Lang :: tr
{ 'error messages' });
1976 print "<class name='base'> $errormessage " ;
1977 print " </class>" ;
1978 & Header
:: closebox
();
1982 & Header
:: openbox
( '100%' , 'left' , " $Lang ::tr{'warning messages'}:" );
1983 print "<class name='base'> $warnmessage " ;
1984 print " </class>" ;
1985 & Header
:: closebox
();
1988 print "<form method='post' enctype='multipart/form-data' action=' $ENV {'SCRIPT_NAME'}'>" ;
1990 <input type='hidden' name='TYPE' value=' $cgiparams {'TYPE'}' />
1991 <input type='hidden' name='IKE_VERSION' value=' $cgiparams {'IKE_VERSION'}' />
1992 <input type='hidden' name='IKE_ENCRYPTION' value=' $cgiparams {'IKE_ENCRYPTION'}' />
1993 <input type='hidden' name='IKE_INTEGRITY' value=' $cgiparams {'IKE_INTEGRITY'}' />
1994 <input type='hidden' name='IKE_GROUPTYPE' value=' $cgiparams {'IKE_GROUPTYPE'}' />
1995 <input type='hidden' name='IKE_LIFETIME' value=' $cgiparams {'IKE_LIFETIME'}' />
1996 <input type='hidden' name='ESP_ENCRYPTION' value=' $cgiparams {'ESP_ENCRYPTION'}' />
1997 <input type='hidden' name='ESP_INTEGRITY' value=' $cgiparams {'ESP_INTEGRITY'}' />
1998 <input type='hidden' name='ESP_GROUPTYPE' value=' $cgiparams {'ESP_GROUPTYPE'}' />
1999 <input type='hidden' name='ESP_KEYLIFE' value=' $cgiparams {'ESP_KEYLIFE'}' />
2000 <input type='hidden' name='COMPRESSION' value=' $cgiparams {'COMPRESSION'}' />
2001 <input type='hidden' name='ONLY_PROPOSED' value=' $cgiparams {'ONLY_PROPOSED'}' />
2002 <input type='hidden' name='PFS' value=' $cgiparams {'PFS'}' />
2003 <input type='hidden' name='DPD_ACTION' value=' $cgiparams {'DPD_ACTION'}' />
2004 <input type='hidden' name='DPD_DELAY' value=' $cgiparams {'DPD_DELAY'}' />
2005 <input type='hidden' name='DPD_TIMEOUT' value=' $cgiparams {'DPD_TIMEOUT'}' />
2006 <input type='hidden' name='FORCE_MOBIKE' value=' $cgiparams {'FORCE_MOBIKE'}' />
2007 <input type='hidden' name='INACTIVITY_TIMEOUT' value=' $cgiparams {'INACTIVITY_TIMEOUT'}' />
2008 <input type='hidden' name='MODE' value=' $cgiparams {'MODE'}' />
2009 <input type='hidden' name='INTERFACE_MODE' value=' $cgiparams {'INTERFACE_MODE'}' />
2012 if ( $cgiparams { 'KEY' }) {
2013 print "<input type='hidden' name='KEY' value=' $cgiparams {'KEY'}' />" ;
2014 print "<input type='hidden' name='NAME' value=' $cgiparams {'NAME'}' />" ;
2015 print "<input type='hidden' name='AUTH' value=' $cgiparams {'AUTH'}' />" ;
2018 & Header
:: openbox
( '100%' , 'left' , " $Lang ::tr{'connection'}: $cgiparams {'NAME'}" );
2019 print "<table width='100%'>" ;
2020 if (! $cgiparams { 'KEY' }) {
2023 <td width='20%'> $Lang ::tr{'name'}: <img src='/blob.gif' alt='*' /></td>
2025 <input type='text' name='NAME' value=' $cgiparams {'NAME'}' size='25' />
2027 <td colspan="2"></td>
2034 if ( $cgiparams { 'TYPE' } eq 'host' ) {
2035 $disabled = "disabled='disabled'" ;
2036 } elsif ( $cgiparams { 'TYPE' } eq 'net' ) {
2037 $blob = "<img src='/blob.gif' alt='*' />" ;
2040 my @local_subnets = split ( /\|/ , $cgiparams { 'LOCAL_SUBNET' });
2041 my $local_subnets = join ( "," , @local_subnets );
2043 my @remote_subnets = split ( /\|/ , $cgiparams { 'REMOTE_SUBNET' });
2044 my $remote_subnets = join ( "," , @remote_subnets );
2048 <td width='20%'> $Lang ::tr{'enabled'}</td>
2050 <input type='checkbox' name='ENABLED' $checked {'ENABLED'}{'on'} />
2052 <td class='boldbase' nowrap='nowrap' width='20%'> $Lang ::tr{'local subnet'} <img src='/blob.gif' alt='*' /></td>
2054 <input type='text' name='LOCAL_SUBNET' value=' $local_subnets ' />
2058 <td class='boldbase' width='20%'> $Lang ::tr{'remote host/ip'}: $blob </td>
2060 <input type='text' name='REMOTE' value=' $cgiparams {'REMOTE'}' size="25" />
2062 <td class='boldbase' nowrap='nowrap' width='20%'> $Lang ::tr{'remote subnet'} $blob </td>
2064 <input $disabled type='text' name='REMOTE_SUBNET' value=' $remote_subnets ' />
2068 <td class='boldbase' width='20%'> $Lang ::tr{'vpn local id'}:</td>
2070 <input type='text' name='LOCAL_ID' value=' $cgiparams {'LOCAL_ID'}' size="25" />
2072 <td class='boldbase' width='20%'> $Lang ::tr{'vpn remote id'}:</td>
2074 <input type='text' name='REMOTE_ID' value=' $cgiparams {'REMOTE_ID'}' size="25" />
2077 <tr><td colspan="4"><br /></td></tr>
2079 <td class='boldbase' width='20%'> $Lang ::tr{'remark title'}</td>
2081 <input type='text' name='REMARK' value=' $cgiparams {'REMARK'}' maxlength='50' size="73" />
2086 if (! $cgiparams { 'KEY' }) {
2087 print "<tr><td colspan='3'><input type='checkbox' name='EDIT_ADVANCED' $checked {'EDIT_ADVANCED'}{'on'} /> $Lang ::tr{'edit advanced settings when done'}</td></tr>" ;
2090 & Header
:: closebox
();
2092 if ( $cgiparams { 'KEY' } && $cgiparams { 'AUTH' } eq 'psk' ) {
2093 & Header
:: openbox
( '100%' , 'left' , $Lang :: tr
{ 'authentication' });
2095 <table width='100%' cellpadding='0' cellspacing='5' border='0'>
2096 <tr><td class='base' width='50%'> $Lang ::tr{'use a pre-shared key'}</td>
2097 <td class='base' width='50%'><input type='password' name='PSK' size='30' value=' $cgiparams {'PSK'}' /></td>
2102 & Header
:: closebox
();
2103 } elsif (! $cgiparams { 'KEY' }) {
2104 my $cakeydisabled = ( ! - f
"${General::swroot}/private/cakey.pem" ) ?
"disabled='disabled'" : '' ;
2105 $cgiparams { 'CERT_NAME' } = $Lang :: tr
{ 'vpn no full pki' } if ( $cakeydisabled );
2106 my $cacrtdisabled = ( ! - f
"${General::swroot}/ca/cacert.pem" ) ?
"disabled='disabled'" : '' ;
2108 & Header
:: openbox
( '100%' , 'left' , $Lang :: tr
{ 'authentication' });
2110 <table width='100%' cellpadding='0' cellspacing='5' border='0'>
2111 <tr><td width='5%'><input type='radio' name='AUTH' value='psk' $checked {'AUTH'}{'psk'} /></td>
2112 <td class='base' width='55%'> $Lang ::tr{'use a pre-shared key'}</td>
2113 <td class='base' width='40%'><input type='password' name='PSK' size='30' value=' $cgiparams {'PSK'}' /></td></tr>
2114 <tr><td colspan='3' bgcolor='#000000'></td></tr>
2115 <tr><td><input type='radio' name='AUTH' value='certreq' $checked {'AUTH'}{'certreq'} $cakeydisabled /></td>
2116 <td class='base'><hr /> $Lang ::tr{'upload a certificate request'}</td>
2117 <td class='base' rowspan='3' valign='middle'><input type='file' name='FH' size='30' $cacrtdisabled /></td></tr>
2118 <tr><td><input type='radio' name='AUTH' value='certfile' $checked {'AUTH'}{'certfile'} $cacrtdisabled /></td>
2119 <td class='base'> $Lang ::tr{'upload a certificate'}</td></tr>
2120 <tr><td><input type='radio' name='AUTH' value='pkcs12' $cacrtdisabled /></td>
2121 <td class='base'> $Lang ::tr{'upload p12 file'} $Lang ::tr{'pkcs12 file password'}:<input type='password' name='P12_PASS'/></td></tr>
2122 <tr><td><input type='radio' name='AUTH' value='auth-dn' $checked {'AUTH'}{'auth-dn'} $cacrtdisabled /></td>
2123 <td class='base'><hr /> $Lang ::tr{'vpn auth-dn'}</td></tr>
2124 <tr><td colspan='3' bgcolor='#000000'></td></tr>
2125 <tr><td><input type='radio' name='AUTH' value='certgen' $checked {'AUTH'}{'certgen'} $cakeydisabled /></td>
2126 <td class='base'><hr /> $Lang ::tr{'generate a certificate'}</td><td> </td></tr>
2128 <td class='base'> $Lang ::tr{'users fullname or system hostname'}: <img src='/blob.gif' alt='*' /></td>
2129 <td class='base' nowrap='nowrap'><input type='text' name='CERT_NAME' value=' $cgiparams {'CERT_NAME'}' size='32' $cakeydisabled /></td></tr>
2131 <td class='base'> $Lang ::tr{'users email'}:</td>
2132 <td class='base' nowrap='nowrap'><input type='text' name='CERT_EMAIL' value=' $cgiparams {'CERT_EMAIL'}' size='32' $cakeydisabled /></td></tr>
2134 <td class='base'> $Lang ::tr{'users department'}:</td>
2135 <td class='base' nowrap='nowrap'><input type='text' name='CERT_OU' value=' $cgiparams {'CERT_OU'}' size='32' $cakeydisabled /></td></tr>
2137 <td class='base'> $Lang ::tr{'organization name'}: <img src='/blob.gif' alt='*' /></td>
2138 <td class='base' nowrap='nowrap'><input type='text' name='CERT_ORGANIZATION' value=' $cgiparams {'CERT_ORGANIZATION'}' size='32' $cakeydisabled /></td></tr>
2140 <td class='base'> $Lang ::tr{'city'}:</td>
2141 <td class='base' nowrap='nowrap'><input type='text' name='CERT_CITY' value=' $cgiparams {'CERT_CITY'}' size='32' $cakeydisabled /></td></tr>
2143 <td class='base'> $Lang ::tr{'state or province'}:</td>
2144 <td class='base' nowrap='nowrap'><input type='text' name='CERT_STATE' value=' $cgiparams {'CERT_STATE'}' size='32' $cakeydisabled /></td></tr>
2146 <td class='base'> $Lang ::tr{'country'}:</td>
2147 <td class='base'><select name='CERT_COUNTRY' $cakeydisabled >
2150 foreach my $country ( sort keys %{ Countries
:: countries
}) {
2151 print " \t\t\t <option value=' $Countries ::countries{ $country }'" ;
2152 if ( $Countries :: countries
{ $country } eq $cgiparams { 'CERT_COUNTRY' } ) {
2153 print " selected='selected'" ;
2155 print "> $country </option> \n " ;
2160 <tr><td> </td><td class='base'> $Lang ::tr{'vpn subjectaltname'} (subjectAltName=email:*,URI:*,DNS:*,RID:*)</td>
2161 <td class='base' nowrap='nowrap'><input type='text' name='SUBJECTALTNAME' value=' $cgiparams {'SUBJECTALTNAME'}' size='32' $cakeydisabled /></td></tr>
2163 <td class='base'> $Lang ::tr{'pkcs12 file password'}: <img src='/blob.gif' alt='*' /></td>
2164 <td class='base' nowrap='nowrap'><input type='password' name='CERT_PASS1' value=' $cgiparams {'CERT_PASS1'}' size='32' $cakeydisabled /></td></tr>
2165 <tr><td> </td><td class='base'> $Lang ::tr{'pkcs12 file password'} ( $Lang ::tr{'confirmation'}): <img src='/blob.gif' alt='*' /></td>
2166 <td class='base' nowrap='nowrap'><input type='password' name='CERT_PASS2' value=' $cgiparams {'CERT_PASS2'}' size='32' $cakeydisabled /></td></tr>
2170 & Header
:: closebox
();
2173 print "<div align='center'><input type='submit' name='ACTION' value=' $Lang ::tr{'save'}' />" ;
2174 if ( $cgiparams { 'KEY' }) {
2175 print "<input type='submit' name='ACTION' value=' $Lang ::tr{'advanced'}' />" ;
2177 print "<input type='submit' name='ACTION' value=' $Lang ::tr{'cancel'}' /></div></form>" ;
2178 & Header
:: closebigbox
();
2179 & Header
:: closepage
();
2186 ### Advanced settings
2188 if (( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'advanced' }) ||
2189 ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'save' } && $cgiparams { 'ADVANCED' } eq 'yes' )) {
2190 & General
:: readhash
( "${General::swroot}/vpn/settings" , \
%vpnsettings );
2191 & General
:: readhasharray
( "${General::swroot}/vpn/config" , \
%confighash );
2192 if (! $confighash { $cgiparams { 'KEY' }}) {
2193 $errormessage = $Lang :: tr
{ 'invalid key' };
2197 if ( $cgiparams { 'ACTION' } eq $Lang :: tr
{ 'save' }) {
2198 my @temp = split ( '\|' , $cgiparams { 'IKE_ENCRYPTION' });
2200 $errormessage = $Lang :: tr
{ 'invalid input' };
2201 goto ADVANCED_ERROR
;
2203 foreach my $val ( @temp ) {
2204 if ( $val !~ /^(aes(256|192|128)(gcm(128|96|64))?|3des|chacha20poly1305|camellia(256|192|128))$/ ) {
2205 $errormessage = $Lang :: tr
{ 'invalid input' };
2206 goto ADVANCED_ERROR
;
2209 @temp = split ( '\|' , $cgiparams { 'IKE_INTEGRITY' });
2211 $errormessage = $Lang :: tr
{ 'invalid input' };
2212 goto ADVANCED_ERROR
;
2214 foreach my $val ( @temp ) {
2215 if ( $val !~ /^(sha2_(512|384|256)|sha|md5|aesxcbc)$/ ) {
2216 $errormessage = $Lang :: tr
{ 'invalid input' };
2217 goto ADVANCED_ERROR
;
2220 @temp = split ( '\|' , $cgiparams { 'IKE_GROUPTYPE' });
2222 $errormessage = $Lang :: tr
{ 'invalid input' };
2223 goto ADVANCED_ERROR
;
2225 foreach my $val ( @temp ) {
2226 if ( $val !~ /^(curve25519|e521|e384|e256|e224|e192|e512bp|e384bp|e256bp|e224bp|768|1024|1536|2048|3072|4096|6144|8192)$/ ) {
2227 $errormessage = $Lang :: tr
{ 'invalid input' };
2228 goto ADVANCED_ERROR
;
2231 if ( $cgiparams { 'IKE_LIFETIME' } !~ /^\d+$/ ) {
2232 $errormessage = $Lang :: tr
{ 'invalid input for ike lifetime' };
2233 goto ADVANCED_ERROR
;
2235 if ( $cgiparams { 'IKE_LIFETIME' } < 1 || $cgiparams { 'IKE_LIFETIME' } > 8 ) {
2236 $errormessage = $Lang :: tr
{ 'ike lifetime should be between 1 and 8 hours' };
2237 goto ADVANCED_ERROR
;
2239 @temp = split ( '\|' , $cgiparams { 'ESP_ENCRYPTION' });
2241 $errormessage = $Lang :: tr
{ 'invalid input' };
2242 goto ADVANCED_ERROR
;
2244 foreach my $val ( @temp ) {
2245 if ( $val !~ /^(aes(256|192|128)(gcm(128|96|64))?|3des|chacha20poly1305|camellia(256|192|128))$/ ) {
2246 $errormessage = $Lang :: tr
{ 'invalid input' };
2247 goto ADVANCED_ERROR
;
2250 @temp = split ( '\|' , $cgiparams { 'ESP_INTEGRITY' });
2252 $errormessage = $Lang :: tr
{ 'invalid input' };
2253 goto ADVANCED_ERROR
;
2255 foreach my $val ( @temp ) {
2256 if ( $val !~ /^(sha2_(512|384|256)|sha1|md5|aesxcbc)$/ ) {
2257 $errormessage = $Lang :: tr
{ 'invalid input' };
2258 goto ADVANCED_ERROR
;
2261 @temp = split ( '\|' , $cgiparams { 'ESP_GROUPTYPE' });
2263 $errormessage = $Lang :: tr
{ 'invalid input' };
2264 goto ADVANCED_ERROR
;
2266 foreach my $val ( @temp ) {
2267 if ( $val !~ /^(curve25519|e521|e384|e256|e224|e192|e512bp|e384bp|e256bp|e224bp|768|1024|1536|2048|3072|4096|6144|8192|none)$/ ) {
2268 $errormessage = $Lang :: tr
{ 'invalid input' };
2269 goto ADVANCED_ERROR
;
2272 if ( $cgiparams { 'ESP_KEYLIFE' } !~ /^\d+$/ ) {
2273 $errormessage = $Lang :: tr
{ 'invalid input for esp keylife' };
2274 goto ADVANCED_ERROR
;
2276 if ( $cgiparams { 'ESP_KEYLIFE' } < 1 || $cgiparams { 'ESP_KEYLIFE' } > 24 ) {
2277 $errormessage = $Lang :: tr
{ 'esp keylife should be between 1 and 24 hours' };
2278 goto ADVANCED_ERROR
;
2281 if (( $cgiparams { 'COMPRESSION' } !~ /^(|on|off)$/ ) ||
2282 ( $cgiparams { 'FORCE_MOBIKE' } !~ /^(|on|off)$/ ) ||
2283 ( $cgiparams { 'ONLY_PROPOSED' } !~ /^(|on|off)$/ ) ||
2284 ( $cgiparams { 'PFS' } !~ /^(|on|off)$/ )) {
2285 $errormessage = $Lang :: tr
{ 'invalid input' };
2286 goto ADVANCED_ERROR
;
2289 if ( $cgiparams { 'DPD_DELAY' } !~ /^\d+$/ ) {
2290 $errormessage = $Lang :: tr
{ 'invalid input for dpd delay' };
2291 goto ADVANCED_ERROR
;
2294 if ( $cgiparams { 'DPD_TIMEOUT' } !~ /^\d+$/ ) {
2295 $errormessage = $Lang :: tr
{ 'invalid input for dpd timeout' };
2296 goto ADVANCED_ERROR
;
2299 if ( $cgiparams { 'INACTIVITY_TIMEOUT' } !~ /^\d+$/ ) {
2300 $errormessage = $Lang :: tr
{ 'invalid input for inactivity timeout' };
2301 goto ADVANCED_ERROR
;
2304 if ( $cgiparams { 'MODE' } !~ /^(tunnel|transport)$/ ) {
2305 $errormessage = $Lang :: tr
{ 'invalid input for mode' };
2306 goto ADVANCED_ERROR
;
2309 if ( $cgiparams { 'INTERFACE_MODE' } !~ /^(|gre|vti)$/ ) {
2310 $errormessage = $Lang :: tr
{ 'invalid input for interface mode' };
2311 goto ADVANCED_ERROR
;
2314 $confighash { $cgiparams { 'KEY' }}[ 29 ] = $cgiparams { 'IKE_VERSION' };
2315 $confighash { $cgiparams { 'KEY' }}[ 18 ] = $cgiparams { 'IKE_ENCRYPTION' };
2316 $confighash { $cgiparams { 'KEY' }}[ 19 ] = $cgiparams { 'IKE_INTEGRITY' };
2317 $confighash { $cgiparams { 'KEY' }}[ 20 ] = $cgiparams { 'IKE_GROUPTYPE' };
2318 $confighash { $cgiparams { 'KEY' }}[ 16 ] = $cgiparams { 'IKE_LIFETIME' };
2319 $confighash { $cgiparams { 'KEY' }}[ 21 ] = $cgiparams { 'ESP_ENCRYPTION' };
2320 $confighash { $cgiparams { 'KEY' }}[ 22 ] = $cgiparams { 'ESP_INTEGRITY' };
2321 $confighash { $cgiparams { 'KEY' }}[ 23 ] = $cgiparams { 'ESP_GROUPTYPE' };
2322 $confighash { $cgiparams { 'KEY' }}[ 17 ] = $cgiparams { 'ESP_KEYLIFE' };
2323 $confighash { $cgiparams { 'KEY' }}[ 12 ] = 'off' ; #$cgiparams{'AGGRMODE'};
2324 $confighash { $cgiparams { 'KEY' }}[ 13 ] = $cgiparams { 'COMPRESSION' };
2325 $confighash { $cgiparams { 'KEY' }}[ 24 ] = $cgiparams { 'ONLY_PROPOSED' };
2326 $confighash { $cgiparams { 'KEY' }}[ 28 ] = $cgiparams { 'PFS' };
2327 $confighash { $cgiparams { 'KEY' }}[ 27 ] = $cgiparams { 'DPD_ACTION' };
2328 $confighash { $cgiparams { 'KEY' }}[ 30 ] = $cgiparams { 'DPD_TIMEOUT' };
2329 $confighash { $cgiparams { 'KEY' }}[ 31 ] = $cgiparams { 'DPD_DELAY' };
2330 $confighash { $cgiparams { 'KEY' }}[ 32 ] = $cgiparams { 'FORCE_MOBIKE' };
2331 $confighash { $cgiparams { 'KEY' }}[ 33 ] = $cgiparams { 'START_ACTION' };
2332 $confighash { $cgiparams { 'KEY' }}[ 34 ] = $cgiparams { 'INACTIVITY_TIMEOUT' };
2333 $confighash { $cgiparams { 'KEY' }}[ 35 ] = $cgiparams { 'MODE' };
2334 $confighash { $cgiparams { 'KEY' }}[ 36 ] = $cgiparams { 'INTERFACE_MODE' };
2335 & General
:: writehasharray
( "${General::swroot}/vpn/config" , \
%confighash );
2338 system ( '/usr/local/bin/ipsecctrl' , 'S' , $cgiparams { 'KEY' });
2343 $cgiparams { 'IKE_VERSION' } = $confighash { $cgiparams { 'KEY' }}[ 29 ];
2344 $cgiparams { 'IKE_ENCRYPTION' } = $confighash { $cgiparams { 'KEY' }}[ 18 ];
2345 $cgiparams { 'IKE_INTEGRITY' } = $confighash { $cgiparams { 'KEY' }}[ 19 ];
2346 $cgiparams { 'IKE_GROUPTYPE' } = $confighash { $cgiparams { 'KEY' }}[ 20 ];
2347 $cgiparams { 'IKE_LIFETIME' } = $confighash { $cgiparams { 'KEY' }}[ 16 ];
2348 $cgiparams { 'ESP_ENCRYPTION' } = $confighash { $cgiparams { 'KEY' }}[ 21 ];
2349 $cgiparams { 'ESP_INTEGRITY' } = $confighash { $cgiparams { 'KEY' }}[ 22 ];
2350 $cgiparams { 'ESP_GROUPTYPE' } = $confighash { $cgiparams { 'KEY' }}[ 23 ];
2351 if ( $cgiparams { 'ESP_GROUPTYPE' } eq "" ) {
2352 $cgiparams { 'ESP_GROUPTYPE' } = $cgiparams { 'IKE_GROUPTYPE' };
2354 $cgiparams { 'ESP_KEYLIFE' } = $confighash { $cgiparams { 'KEY' }}[ 17 ];
2355 $cgiparams { 'COMPRESSION' } = $confighash { $cgiparams { 'KEY' }}[ 13 ];
2356 $cgiparams { 'ONLY_PROPOSED' } = $confighash { $cgiparams { 'KEY' }}[ 24 ];
2357 $cgiparams { 'PFS' } = $confighash { $cgiparams { 'KEY' }}[ 28 ];
2358 $cgiparams { 'DPD_ACTION' } = $confighash { $cgiparams { 'KEY' }}[ 27 ];
2359 $cgiparams { 'DPD_TIMEOUT' } = $confighash { $cgiparams { 'KEY' }}[ 30 ];
2360 $cgiparams { 'DPD_DELAY' } = $confighash { $cgiparams { 'KEY' }}[ 31 ];
2361 $cgiparams { 'FORCE_MOBIKE' } = $confighash { $cgiparams { 'KEY' }}[ 32 ];
2362 $cgiparams { 'START_ACTION' } = $confighash { $cgiparams { 'KEY' }}[ 33 ];
2363 $cgiparams { 'INACTIVITY_TIMEOUT' } = $confighash { $cgiparams { 'KEY' }}[ 34 ];
2364 $cgiparams { 'MODE' } = $confighash { $cgiparams { 'KEY' }}[ 35 ];
2365 $cgiparams { 'INTERFACE_MODE' } = $confighash { $cgiparams { 'KEY' }}[ 36 ];
2367 if (! $cgiparams { 'DPD_DELAY' }) {
2368 $cgiparams { 'DPD_DELAY' } = 30 ;
2371 if (! $cgiparams { 'DPD_TIMEOUT' }) {
2372 $cgiparams { 'DPD_TIMEOUT' } = 120 ;
2375 if (! $cgiparams { 'START_ACTION' }) {
2376 $cgiparams { 'START_ACTION' } = "start" ;
2379 if ( $cgiparams { 'INACTIVITY_TIMEOUT' } eq "" ) {
2380 $cgiparams { 'INACTIVITY_TIMEOUT' } = 900 ; # 15 min
2383 if ( $cgiparams { 'MODE' } eq "" ) {
2384 $cgiparams { 'MODE' } = "tunnel" ;
2389 $checked { 'IKE_ENCRYPTION' }{ 'chacha20poly1305' } = '' ;
2390 $checked { 'IKE_ENCRYPTION' }{ 'aes256' } = '' ;
2391 $checked { 'IKE_ENCRYPTION' }{ 'aes192' } = '' ;
2392 $checked { 'IKE_ENCRYPTION' }{ 'aes128' } = '' ;
2393 $checked { 'IKE_ENCRYPTION' }{ 'aes256gcm128' } = '' ;
2394 $checked { 'IKE_ENCRYPTION' }{ 'aes192gcm128' } = '' ;
2395 $checked { 'IKE_ENCRYPTION' }{ 'aes128gcm128' } = '' ;
2396 $checked { 'IKE_ENCRYPTION' }{ 'aes256gcm96' } = '' ;
2397 $checked { 'IKE_ENCRYPTION' }{ 'aes192gcm96' } = '' ;
2398 $checked { 'IKE_ENCRYPTION' }{ 'aes128gcm96' } = '' ;
2399 $checked { 'IKE_ENCRYPTION' }{ 'aes256gcm64' } = '' ;
2400 $checked { 'IKE_ENCRYPTION' }{ 'aes192gcm64' } = '' ;
2401 $checked { 'IKE_ENCRYPTION' }{ 'aes128gcm64' } = '' ;
2402 $checked { 'IKE_ENCRYPTION' }{ '3des' } = '' ;
2403 $checked { 'IKE_ENCRYPTION' }{ 'camellia256' } = '' ;
2404 $checked { 'IKE_ENCRYPTION' }{ 'camellia192' } = '' ;
2405 $checked { 'IKE_ENCRYPTION' }{ 'camellia128' } = '' ;
2406 my @temp = split ( '\|' , $cgiparams { 'IKE_ENCRYPTION' });
2407 foreach my $key ( @temp ) { $checked { 'IKE_ENCRYPTION' }{ $key } = "selected='selected'" ; }
2408 $checked { 'IKE_INTEGRITY' }{ 'sha2_512' } = '' ;
2409 $checked { 'IKE_INTEGRITY' }{ 'sha2_384' } = '' ;
2410 $checked { 'IKE_INTEGRITY' }{ 'sha2_256' } = '' ;
2411 $checked { 'IKE_INTEGRITY' }{ 'sha' } = '' ;
2412 $checked { 'IKE_INTEGRITY' }{ 'md5' } = '' ;
2413 $checked { 'IKE_INTEGRITY' }{ 'aesxcbc' } = '' ;
2414 @temp = split ( '\|' , $cgiparams { 'IKE_INTEGRITY' });
2415 foreach my $key ( @temp ) { $checked { 'IKE_INTEGRITY' }{ $key } = "selected='selected'" ; }
2416 $checked { 'IKE_GROUPTYPE' }{ 'curve25519' } = '' ;
2417 $checked { 'IKE_GROUPTYPE' }{ '768' } = '' ;
2418 $checked { 'IKE_GROUPTYPE' }{ '1024' } = '' ;
2419 $checked { 'IKE_GROUPTYPE' }{ '1536' } = '' ;
2420 $checked { 'IKE_GROUPTYPE' }{ '2048' } = '' ;
2421 $checked { 'IKE_GROUPTYPE' }{ '3072' } = '' ;
2422 $checked { 'IKE_GROUPTYPE' }{ '4096' } = '' ;
2423 $checked { 'IKE_GROUPTYPE' }{ '6144' } = '' ;
2424 $checked { 'IKE_GROUPTYPE' }{ '8192' } = '' ;
2425 @temp = split ( '\|' , $cgiparams { 'IKE_GROUPTYPE' });
2426 foreach my $key ( @temp ) { $checked { 'IKE_GROUPTYPE' }{ $key } = "selected='selected'" ; }
2428 $checked { 'ESP_ENCRYPTION' }{ 'chacha20poly1305' } = '' ;
2429 $checked { 'ESP_ENCRYPTION' }{ 'aes256' } = '' ;
2430 $checked { 'ESP_ENCRYPTION' }{ 'aes192' } = '' ;
2431 $checked { 'ESP_ENCRYPTION' }{ 'aes128' } = '' ;
2432 $checked { 'ESP_ENCRYPTION' }{ 'aes256gcm128' } = '' ;
2433 $checked { 'ESP_ENCRYPTION' }{ 'aes192gcm128' } = '' ;
2434 $checked { 'ESP_ENCRYPTION' }{ 'aes128gcm128' } = '' ;
2435 $checked { 'ESP_ENCRYPTION' }{ 'aes256gcm96' } = '' ;
2436 $checked { 'ESP_ENCRYPTION' }{ 'aes192gcm96' } = '' ;
2437 $checked { 'ESP_ENCRYPTION' }{ 'aes128gcm96' } = '' ;
2438 $checked { 'ESP_ENCRYPTION' }{ 'aes256gcm64' } = '' ;
2439 $checked { 'ESP_ENCRYPTION' }{ 'aes192gcm64' } = '' ;
2440 $checked { 'ESP_ENCRYPTION' }{ 'aes128gcm64' } = '' ;
2441 $checked { 'ESP_ENCRYPTION' }{ '3des' } = '' ;
2442 $checked { 'ESP_ENCRYPTION' }{ 'camellia256' } = '' ;
2443 $checked { 'ESP_ENCRYPTION' }{ 'camellia192' } = '' ;
2444 $checked { 'ESP_ENCRYPTION' }{ 'camellia128' } = '' ;
2445 @temp = split ( '\|' , $cgiparams { 'ESP_ENCRYPTION' });
2446 foreach my $key ( @temp ) { $checked { 'ESP_ENCRYPTION' }{ $key } = "selected='selected'" ; }
2447 $checked { 'ESP_INTEGRITY' }{ 'sha2_512' } = '' ;
2448 $checked { 'ESP_INTEGRITY' }{ 'sha2_384' } = '' ;
2449 $checked { 'ESP_INTEGRITY' }{ 'sha2_256' } = '' ;
2450 $checked { 'ESP_INTEGRITY' }{ 'sha1' } = '' ;
2451 $checked { 'ESP_INTEGRITY' }{ 'md5' } = '' ;
2452 $checked { 'ESP_INTEGRITY' }{ 'aesxcbc' } = '' ;
2453 @temp = split ( '\|' , $cgiparams { 'ESP_INTEGRITY' });
2454 foreach my $key ( @temp ) { $checked { 'ESP_INTEGRITY' }{ $key } = "selected='selected'" ; }
2455 $checked { 'ESP_GROUPTYPE' }{ 'curve25519' } = '' ;
2456 $checked { 'ESP_GROUPTYPE' }{ '768' } = '' ;
2457 $checked { 'ESP_GROUPTYPE' }{ '1024' } = '' ;
2458 $checked { 'ESP_GROUPTYPE' }{ '1536' } = '' ;
2459 $checked { 'ESP_GROUPTYPE' }{ '2048' } = '' ;
2460 $checked { 'ESP_GROUPTYPE' }{ '3072' } = '' ;
2461 $checked { 'ESP_GROUPTYPE' }{ '4096' } = '' ;
2462 $checked { 'ESP_GROUPTYPE' }{ '6144' } = '' ;
2463 $checked { 'ESP_GROUPTYPE' }{ '8192' } = '' ;
2464 $checked { 'ESP_GROUPTYPE' }{ 'none' } = '' ;
2465 @temp = split ( '\|' , $cgiparams { 'ESP_GROUPTYPE' });
2466 foreach my $key ( @temp ) { $checked { 'ESP_GROUPTYPE' }{ $key } = "selected='selected'" ; }
2468 $checked { 'COMPRESSION' } = $cgiparams { 'COMPRESSION' } eq 'on' ?
"checked='checked'" : '' ;
2469 $checked { 'FORCE_MOBIKE' } = $cgiparams { 'FORCE_MOBIKE' } eq 'on' ?
"checked='checked'" : '' ;
2470 $checked { 'ONLY_PROPOSED' } = $cgiparams { 'ONLY_PROPOSED' } eq 'on' ?
"checked='checked'" : '' ;
2471 $checked { 'PFS' } = $cgiparams { 'PFS' } eq 'on' ?
"checked='checked'" : '' ;
2473 $selected { 'IKE_VERSION' }{ 'ikev1' } = '' ;
2474 $selected { 'IKE_VERSION' }{ 'ikev2' } = '' ;
2475 $selected { 'IKE_VERSION' }{ $cgiparams { 'IKE_VERSION' }} = "selected='selected'" ;
2477 $selected { 'DPD_ACTION' }{ 'clear' } = '' ;
2478 $selected { 'DPD_ACTION' }{ 'hold' } = '' ;
2479 $selected { 'DPD_ACTION' }{ 'restart' } = '' ;
2480 $selected { 'DPD_ACTION' }{ 'none' } = '' ;
2481 $selected { 'DPD_ACTION' }{ $cgiparams { 'DPD_ACTION' }} = "selected='selected'" ;
2483 $selected { 'START_ACTION' }{ 'add' } = '' ;
2484 $selected { 'START_ACTION' }{ 'route' } = '' ;
2485 $selected { 'START_ACTION' }{ 'start' } = '' ;
2486 $selected { 'START_ACTION' }{ $cgiparams { 'START_ACTION' }} = "selected='selected'" ;
2488 $selected { 'INACTIVITY_TIMEOUT' } = ();
2489 foreach my $timeout ( keys %INACTIVITY_TIMEOUTS ) {
2490 $selected { 'INACTIVITY_TIMEOUT' }{ $timeout } = "" ;
2492 $selected { 'INACTIVITY_TIMEOUT' }{ $cgiparams { 'INACTIVITY_TIMEOUT' }} = "selected" ;
2494 $selected { 'MODE' }{ 'tunnel' } = '' ;
2495 $selected { 'MODE' }{ 'transport' } = '' ;
2496 $selected { 'MODE' }{ $cgiparams { 'MODE' }} = "selected='selected'" ;
2498 $selected { 'INTERFACE_MODE' }{ '' } = '' ;
2499 $selected { 'INTERFACE_MODE' }{ 'gre' } = '' ;
2500 $selected { 'INTERFACE_MODE' }{ 'vti' } = '' ;
2501 $selected { 'INTERFACE_MODE' }{ $cgiparams { 'INTERFACE_MODE' }} = "selected='selected'" ;
2503 & Header
:: showhttpheaders
();
2504 & Header
:: openpage
( $Lang :: tr
{ 'ipsec' }, 1 , '' );
2505 & Header
:: openbigbox
( '100%' , 'left' , '' , $errormessage );
2507 if ( $errormessage ) {
2508 & Header
:: openbox
( '100%' , 'left' , $Lang :: tr
{ 'error messages' });
2509 print "<class name='base'> $errormessage " ;
2510 print " </class>" ;
2511 & Header
:: closebox
();
2515 & Header
:: openbox
( '100%' , 'left' , $Lang :: tr
{ 'warning messages' });
2516 print "<class name='base'> $warnmessage " ;
2517 print " </class>" ;
2518 & Header
:: closebox
();
2521 & Header
:: openbox
( '100%' , 'left' , " $Lang ::tr{'advanced'}:" );
2523 <form method='post' enctype='multipart/form-data' action=' $ENV {'SCRIPT_NAME'}'>
2524 <input type='hidden' name='ADVANCED' value='yes' />
2525 <input type='hidden' name='KEY' value=' $cgiparams {'KEY'}' />
2527 <table width="100%">
2530 <td width="15%"> $Lang ::tr{'mode'}:</td>
2532 <select name='MODE'>
2533 <option value='tunnel' $selected {'MODE'}{'tunnel'}> $Lang ::tr{'ipsec mode tunnel'}</option>
2534 <option value='transport' $selected {'MODE'}{'transport'}> $Lang ::tr{'ipsec mode transport'}</option>
2540 <td width="15%"> $Lang ::tr{'interface mode'}:</td>
2542 <select name='INTERFACE_MODE'>
2543 <option value='' $selected {'INTERFACE_MODE'}{''}> $Lang ::tr{'ipsec interface mode none'}</option>
2544 <option value='gre' $selected {'INTERFACE_MODE'}{'gre'}> $Lang ::tr{'ipsec interface mode gre'}</option>
2545 <option value='vti' $selected {'INTERFACE_MODE'}{'vti'}> $Lang ::tr{'ipsec interface mode vti'}</option>
2554 <h2> $Lang ::tr{'cryptographic settings'}</h2>
2556 <table width='100%'>
2559 <th width="15%"></th>
2566 <td> $Lang ::tr{'vpn keyexchange'}:</td>
2568 <select name='IKE_VERSION'>
2569 <option value='ikev2' $selected {'IKE_VERSION'}{'ikev2'}>IKEv2</option>
2570 <option value='ikev1' $selected {'IKE_VERSION'}{'ikev1'}>IKEv1</option>
2576 <td class='boldbase' width="15%"> $Lang ::tr{'encryption'}</td>
2577 <td class='boldbase'>
2578 <select name='IKE_ENCRYPTION' multiple='multiple' size='6' style='width: 100%'>
2579 <option value='chacha20poly1305' $checked {'IKE_ENCRYPTION'}{'chacha20poly1305'}>256 bit ChaCha20-Poly1305/128 bit ICV</option>
2580 <option value='aes256gcm128' $checked {'IKE_ENCRYPTION'}{'aes256gcm128'}>256 bit AES-GCM/128 bit ICV</option>
2581 <option value='aes256gcm96' $checked {'IKE_ENCRYPTION'}{'aes256gcm96'}>256 bit AES-GCM/96 bit ICV</option>
2582 <option value='aes256gcm64' $checked {'IKE_ENCRYPTION'}{'aes256gcm64'}>256 bit AES-GCM/64 bit ICV</option>
2583 <option value='aes256' $checked {'IKE_ENCRYPTION'}{'aes256'}>256 bit AES-CBC</option>
2584 <option value='camellia256' $checked {'IKE_ENCRYPTION'}{'camellia256'}>256 bit Camellia-CBC</option>
2585 <option value='aes192gcm128' $checked {'IKE_ENCRYPTION'}{'aes192gcm128'}>192 bit AES-GCM/128 bit ICV</option>
2586 <option value='aes192gcm96' $checked {'IKE_ENCRYPTION'}{'aes192gcm96'}>192 bit AES-GCM/96 bit ICV</option>
2587 <option value='aes192gcm64' $checked {'IKE_ENCRYPTION'}{'aes192gcm64'}>192 bit AES-GCM/64 bit ICV</option>
2588 <option value='aes192' $checked {'IKE_ENCRYPTION'}{'aes192'}>192 bit AES-CBC</option>
2589 <option value='camellia192' $checked {'IKE_ENCRYPTION'}{'camellia192'}>192 bit Camellia-CBC</option>
2590 <option value='aes128gcm128' $checked {'IKE_ENCRYPTION'}{'aes128gcm128'}>128 bit AES-GCM/128 bit ICV</option>
2591 <option value='aes128gcm96' $checked {'IKE_ENCRYPTION'}{'aes128gcm96'}>128 bit AES-GCM/96 bit ICV</option>
2592 <option value='aes128gcm64' $checked {'IKE_ENCRYPTION'}{'aes128gcm64'}>128 bit AES-GCM/64 bit ICV</option>
2593 <option value='aes128' $checked {'IKE_ENCRYPTION'}{'aes128'}>128 bit AES-CBC</option>
2594 <option value='camellia128' $checked {'IKE_ENCRYPTION'}{'camellia128'}>128 bit Camellia-CBC</option>
2595 <option value='3des' $checked {'IKE_ENCRYPTION'}{'3des'}>168 bit 3DES-EDE-CBC ( $Lang ::tr{'vpn weak'})</option>
2598 <td class='boldbase'>
2599 <select name='ESP_ENCRYPTION' multiple='multiple' size='6' style='width: 100%'>
2600 <option value='chacha20poly1305' $checked {'ESP_ENCRYPTION'}{'chacha20poly1305'}>256 bit ChaCha20-Poly1305/128 bit ICV</option>
2601 <option value='aes256gcm128' $checked {'ESP_ENCRYPTION'}{'aes256gcm128'}>256 bit AES-GCM/128 bit ICV</option>
2602 <option value='aes256gcm96' $checked {'ESP_ENCRYPTION'}{'aes256gcm96'}>256 bit AES-GCM/96 bit ICV</option>
2603 <option value='aes256gcm64' $checked {'ESP_ENCRYPTION'}{'aes256gcm64'}>256 bit AES-GCM/64 bit ICV</option>
2604 <option value='aes256' $checked {'ESP_ENCRYPTION'}{'aes256'}>256 bit AES-CBC</option>
2605 <option value='camellia256' $checked {'ESP_ENCRYPTION'}{'camellia256'}>256 bit Camellia-CBC</option>
2606 <option value='aes192gcm128' $checked {'ESP_ENCRYPTION'}{'aes192gcm128'}>192 bit AES-GCM/128 bit ICV</option>
2607 <option value='aes192gcm96' $checked {'ESP_ENCRYPTION'}{'aes192gcm96'}>192 bit AES-GCM/96 bit ICV</option>
2608 <option value='aes192gcm64' $checked {'ESP_ENCRYPTION'}{'aes192gcm64'}>192 bit AES-GCM/64 bit ICV</option>
2609 <option value='aes192' $checked {'ESP_ENCRYPTION'}{'aes192'}>192 bit AES-CBC</option>
2610 <option value='camellia192' $checked {'ESP_ENCRYPTION'}{'camellia192'}>192 bit Camellia-CBC</option>
2611 <option value='aes128gcm128' $checked {'ESP_ENCRYPTION'}{'aes128gcm128'}>128 bit AES-GCM/128 bit ICV</option>
2612 <option value='aes128gcm96' $checked {'ESP_ENCRYPTION'}{'aes128gcm96'}>128 bit AES-GCM/96 bit ICV</option>
2613 <option value='aes128gcm64' $checked {'ESP_ENCRYPTION'}{'aes128gcm64'}>128 bit AES-GCM/64 bit ICV</option>
2614 <option value='aes128' $checked {'ESP_ENCRYPTION'}{'aes128'}>128 bit AES-CBC</option>
2615 <option value='camellia128' $checked {'ESP_ENCRYPTION'}{'camellia128'}>128 bit Camellia-CBC</option>
2616 <option value='3des' $checked {'ESP_ENCRYPTION'}{'3des'}>168 bit 3DES-EDE-CBC ( $Lang ::tr{'vpn weak'})</option>
2622 <td class='boldbase' width="15%"> $Lang ::tr{'integrity'}</td>
2623 <td class='boldbase'>
2624 <select name='IKE_INTEGRITY' multiple='multiple' size='6' style='width: 100%'>
2625 <option value='sha2_512' $checked {'IKE_INTEGRITY'}{'sha2_512'}>SHA2 512 bit</option>
2626 <option value='sha2_384' $checked {'IKE_INTEGRITY'}{'sha2_384'}>SHA2 384 bit</option>
2627 <option value='sha2_256' $checked {'IKE_INTEGRITY'}{'sha2_256'}>SHA2 256 bit</option>
2628 <option value='aesxcbc' $checked {'IKE_INTEGRITY'}{'aesxcbc'}>AES XCBC</option>
2629 <option value='sha' $checked {'IKE_INTEGRITY'}{'sha'}>SHA1 ( $Lang ::tr{'vpn weak'})</option>
2630 <option value='md5' $checked {'IKE_INTEGRITY'}{'md5'}>MD5 ( $Lang ::tr{'vpn broken'})</option>
2633 <td class='boldbase'>
2634 <select name='ESP_INTEGRITY' multiple='multiple' size='6' style='width: 100%'>
2635 <option value='sha2_512' $checked {'ESP_INTEGRITY'}{'sha2_512'}>SHA2 512 bit</option>
2636 <option value='sha2_384' $checked {'ESP_INTEGRITY'}{'sha2_384'}>SHA2 384 bit</option>
2637 <option value='sha2_256' $checked {'ESP_INTEGRITY'}{'sha2_256'}>SHA2 256 bit</option>
2638 <option value='aesxcbc' $checked {'ESP_INTEGRITY'}{'aesxcbc'}>AES XCBC</option>
2639 <option value='sha1' $checked {'ESP_INTEGRITY'}{'sha1'}>SHA1 ( $Lang ::tr{'vpn weak'})</option>
2640 <option value='md5' $checked {'ESP_INTEGRITY'}{'md5'}>MD5 ( $Lang ::tr{'vpn broken'})</option>
2645 <td class='boldbase' width="15%"> $Lang ::tr{'lifetime'} <img src='/blob.gif' alt='*' /></td>
2646 <td class='boldbase'>
2647 <input type='text' name='IKE_LIFETIME' value=' $cgiparams {'IKE_LIFETIME'}' size='5' /> $Lang ::tr{'hours'}
2649 <td class='boldbase'>
2650 <input type='text' name='ESP_KEYLIFE' value=' $cgiparams {'ESP_KEYLIFE'}' size='5' /> $Lang ::tr{'hours'}
2654 <td class='boldbase' width="15%"> $Lang ::tr{'grouptype'}</td>
2655 <td class='boldbase'>
2656 <select name='IKE_GROUPTYPE' multiple='multiple' size='6' style='width: 100%'>
2657 <option value='curve25519' $checked {'IKE_GROUPTYPE'}{'curve25519'}>Curve 25519 (256 bit)</option>
2658 <option value='e521' $checked {'IKE_GROUPTYPE'}{'e521'}>ECP-521 (NIST)</option>
2659 <option value='e512bp' $checked {'IKE_GROUPTYPE'}{'e512bp'}>ECP-512 (Brainpool)</option>
2660 <option value='e384' $checked {'IKE_GROUPTYPE'}{'e384'}>ECP-384 (NIST)</option>
2661 <option value='e384bp' $checked {'IKE_GROUPTYPE'}{'e384bp'}>ECP-384 (Brainpool)</option>
2662 <option value='e256' $checked {'IKE_GROUPTYPE'}{'e256'}>ECP-256 (NIST)</option>
2663 <option value='e256bp' $checked {'IKE_GROUPTYPE'}{'e256bp'}>ECP-256 (Brainpool)</option>
2664 <option value='e224' $checked {'IKE_GROUPTYPE'}{'e224'}>ECP-224 (NIST)</option>
2665 <option value='e224bp' $checked {'IKE_GROUPTYPE'}{'e224bp'}>ECP-224 (Brainpool)</option>
2666 <option value='e192' $checked {'IKE_GROUPTYPE'}{'e192'}>ECP-192 (NIST)</option>
2667 <option value='8192' $checked {'IKE_GROUPTYPE'}{'8192'}>MODP-8192</option>
2668 <option value='6144' $checked {'IKE_GROUPTYPE'}{'6144'}>MODP-6144</option>
2669 <option value='4096' $checked {'IKE_GROUPTYPE'}{'4096'}>MODP-4096</option>
2670 <option value='3072' $checked {'IKE_GROUPTYPE'}{'3072'}>MODP-3072</option>
2671 <option value='2048' $checked {'IKE_GROUPTYPE'}{'2048'}>MODP-2048</option>
2672 <option value='1536' $checked {'IKE_GROUPTYPE'}{'1536'}>MODP-1536</option>
2673 <option value='1024' $checked {'IKE_GROUPTYPE'}{'1024'}>MODP-1024 ( $Lang ::tr{'vpn broken'})</option>
2674 <option value='768' $checked {'IKE_GROUPTYPE'}{'768'}>MODP-768 ( $Lang ::tr{'vpn broken'})</option>
2677 <td class='boldbase'>
2678 <select name='ESP_GROUPTYPE' multiple='multiple' size='6' style='width: 100%'>
2679 <option value='curve25519' $checked {'ESP_GROUPTYPE'}{'curve25519'}>Curve 25519 (256 bit)</option>
2680 <option value='e521' $checked {'ESP_GROUPTYPE'}{'e521'}>ECP-521 (NIST)</option>
2681 <option value='e512bp' $checked {'ESP_GROUPTYPE'}{'e512bp'}>ECP-512 (Brainpool)</option>
2682 <option value='e384' $checked {'ESP_GROUPTYPE'}{'e384'}>ECP-384 (NIST)</option>
2683 <option value='e384bp' $checked {'ESP_GROUPTYPE'}{'e384bp'}>ECP-384 (Brainpool)</option>
2684 <option value='e256' $checked {'ESP_GROUPTYPE'}{'e256'}>ECP-256 (NIST)</option>
2685 <option value='e256bp' $checked {'ESP_GROUPTYPE'}{'e256bp'}>ECP-256 (Brainpool)</option>
2686 <option value='e224' $checked {'ESP_GROUPTYPE'}{'e224'}>ECP-224 (NIST)</option>
2687 <option value='e224bp' $checked {'ESP_GROUPTYPE'}{'e224bp'}>ECP-224 (Brainpool)</option>
2688 <option value='e192' $checked {'ESP_GROUPTYPE'}{'e192'}>ECP-192 (NIST)</option>
2689 <option value='8192' $checked {'ESP_GROUPTYPE'}{'8192'}>MODP-8192</option>
2690 <option value='6144' $checked {'ESP_GROUPTYPE'}{'6144'}>MODP-6144</option>
2691 <option value='4096' $checked {'ESP_GROUPTYPE'}{'4096'}>MODP-4096</option>
2692 <option value='3072' $checked {'ESP_GROUPTYPE'}{'3072'}>MODP-3072</option>
2693 <option value='2048' $checked {'ESP_GROUPTYPE'}{'2048'}>MODP-2048</option>
2694 <option value='1536' $checked {'ESP_GROUPTYPE'}{'1536'}>MODP-1536</option>
2695 <option value='1024' $checked {'ESP_GROUPTYPE'}{'1024'}>MODP-1024 ( $Lang ::tr{'vpn broken'})</option>
2696 <option value='768' $checked {'ESP_GROUPTYPE'}{'768'}>MODP-768 ( $Lang ::tr{'vpn broken'})</option>
2697 <option value='none' $checked {'ESP_GROUPTYPE'}{'none'}>- $Lang ::tr{'none'} -</option>
2706 <h2> $Lang ::tr{'dead peer detection'}</h2>
2708 <table width="100%">
2710 <td width="15%"> $Lang ::tr{'dpd action'}:</td>
2712 <select name='DPD_ACTION'>
2713 <option value='none' $selected {'DPD_ACTION'}{'none'}>- $Lang ::tr{'disabled'} -</option>
2714 <option value='clear' $selected {'DPD_ACTION'}{'clear'}>clear</option>
2715 <option value='hold' $selected {'DPD_ACTION'}{'hold'}>hold</option>
2716 <option value='restart' $selected {'DPD_ACTION'}{'restart'}>restart</option>
2721 <td width="15%"> $Lang ::tr{'dpd timeout'}: <img src='/blob.gif' alt='*' /></td>
2723 <input type='text' name='DPD_TIMEOUT' size='5' value=' $cgiparams {'DPD_TIMEOUT'}' />
2727 <td width="15%"> $Lang ::tr{'dpd delay'}: <img src='/blob.gif' alt='*' /></td>
2729 <input type='text' name='DPD_DELAY' size='5' value=' $cgiparams {'DPD_DELAY'}' />
2736 <table width="100%">
2740 <input type='checkbox' name='ONLY_PROPOSED' $checked {'ONLY_PROPOSED'} />
2741 IKE+ESP: $Lang ::tr{'use only proposed settings'}
2745 <label> $Lang ::tr{'vpn start action'}</label>
2746 <select name="START_ACTION">
2747 <option value="route" $selected {'START_ACTION'}{'route'}> $Lang ::tr{'vpn start action route'}</option>
2748 <option value="start" $selected {'START_ACTION'}{'start'}> $Lang ::tr{'vpn start action start'}</option>
2749 <option value="add" $selected {'START_ACTION'}{'add'} > $Lang ::tr{'vpn start action add'}</option>
2756 <input type='checkbox' name='PFS' $checked {'PFS'} />
2757 $Lang ::tr{'pfs yes no'}
2761 <label> $Lang ::tr{'vpn inactivity timeout'}</label>
2762 <select name="INACTIVITY_TIMEOUT">
2764 foreach my $t ( sort { $a <=> $b } keys %INACTIVITY_TIMEOUTS ) {
2765 print "<option value= \" $t \" $selected {'INACTIVITY_TIMEOUT'}{ $t }> $INACTIVITY_TIMEOUTS { $t }</option> \n " ;
2776 <input type='checkbox' name='COMPRESSION' $checked {'COMPRESSION'} />
2777 $Lang ::tr{'vpn payload compression'}
2784 <input type='checkbox' name='FORCE_MOBIKE' $checked {'FORCE_MOBIKE'} />
2785 $Lang ::tr{'vpn force mobike'}
2790 <td align='left'><img src='/blob.gif' align='top' alt='*' /> $Lang ::tr{'required field'}</td>
2792 <input type='submit' name='ACTION' value=' $Lang ::tr{'save'}' />
2793 <input type='submit' name='ACTION' value=' $Lang ::tr{'cancel'}' />
2799 & Header
:: closebox
();
2800 & Header
:: closebigbox
();
2801 & Header
:: closepage
();
2808 ### Default status page
2813 & General
:: readhash
( "${General::swroot}/vpn/settings" , \
%cgiparams );
2814 & General
:: readhasharray
( "${General::swroot}/vpn/caconfig" , \
%cahash );
2815 & General
:: readhasharray
( "${General::swroot}/vpn/config" , \
%confighash );
2816 $cgiparams { 'CA_NAME' } = '' ;
2818 my @status = `/usr/local/bin/ipsecctrl I 2>/dev/null` ;
2820 # suggest a default name for this side
2821 if ( $cgiparams { 'VPN_IP' } eq '' && - e
"${General::swroot}/red/active" ) {
2822 if ( open ( IPADDR
, "${General::swroot}/red/local-ipaddress" )) {
2823 my $ipaddr = < IPADDR
>;
2826 $cgiparams { 'VPN_IP' } = ( gethostbyaddr ( pack ( "C4" , split ( /\./ , $ipaddr )), 2 ))[ 0 ];
2827 if ( $cgiparams { 'VPN_IP' } eq '' ) {
2828 $cgiparams { 'VPN_IP' } = $ipaddr ;
2832 # no IP found, use %defaultroute
2833 $cgiparams { 'VPN_IP' } = ' %defaultroute ' if ( $cgiparams { 'VPN_IP' } eq '' );
2835 $cgiparams { 'VPN_DELAYED_START' } = 0 if (! defined ( $cgiparams { 'VPN_DELAYED_START' }));
2836 $checked { 'ENABLED' } = $cgiparams { 'ENABLED' } eq 'on' ?
"checked='checked'" : '' ;
2838 & Header
:: showhttpheaders
();
2839 & Header
:: openpage
( $Lang :: tr
{ 'ipsec' }, 1 , '' );
2840 & Header
:: openbigbox
( '100%' , 'left' , '' , $errormessage );
2842 if ( $errormessage ) {
2843 & Header
:: openbox
( '100%' , 'left' , $Lang :: tr
{ 'error messages' });
2844 print "<class name='base'> $errormessage \n " ;
2845 print " </class> \n " ;
2846 & Header
:: closebox
();
2850 & Header
:: openbox
( '100%' , 'left' , $Lang :: tr
{ 'warning messages' });
2851 print " $warnmessage <br>" ;
2852 print " $Lang ::tr{'fwdfw warn1'}<br>" ;
2853 & Header
:: closebox
();
2854 print "<center><form method='post'><input type='submit' name='ACTION' value=' $Lang ::tr{'ok'}' style='width: 5em;'></form>" ;
2855 & Header
:: closepage
();
2859 & Header
:: openbox
( '100%' , 'left' , $Lang :: tr
{ 'global settings' });
2861 <form method='post' action=' $ENV {'SCRIPT_NAME'}'>
2862 <table width='100%'>
2864 <td width='20%' class='base' nowrap='nowrap'> $Lang ::tr{'vpn red name'}: <img src='/blob.gif' alt='*' /></td>
2865 <td width='20%'><input type='text' name='VPN_IP' value=' $cgiparams {'VPN_IP'}' /></td>
2866 <td width='20%' class='base'> $Lang ::tr{'enabled'}<input type='checkbox' name='ENABLED' $checked {'ENABLED'} /></td>
2872 <td class='base' nowrap='nowrap'> $Lang ::tr{'vpn delayed start'}: <img src='/blob.gif' alt='*' /><img src='/blob.gif' alt='*' /></td>
2873 <td ><input type='text' name='VPN_DELAYED_START' value=' $cgiparams {'VPN_DELAYED_START'}' /></td>
2876 <td class='base' nowrap='nowrap'> $Lang ::tr{'host to net vpn'}:</td>
2877 <td ><input type='text' name='RW_NET' value=' $cgiparams {'RW_NET'}' /></td>
2882 <table width='100%'>
2884 <td class='base' valign='top'><img src='/blob.gif' alt='*' /></td>
2885 <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>
2888 <td class='base' valign='top' nowrap='nowrap'><img src='/blob.gif' alt='*' /><img src='/blob.gif' alt='*' /> </td>
2889 <td class='base'> <font class='base'> $Lang ::tr{'vpn delayed start help'}</font></td>
2896 & Header
:: closebox
();
2898 & Header
:: openbox
( '100%' , 'left' , $Lang :: tr
{ 'connection status and controlc' });
2900 <table width='100%' cellspacing='1' cellpadding='0' class='tbl'>
2902 <th width='10%' class='boldbase' align='center'><b> $Lang ::tr{'name'}</b></th>
2903 <th width='22%' class='boldbase' align='center'><b> $Lang ::tr{'type'}</b></th>
2904 <th width='23%' class='boldbase' align='center'><b> $Lang ::tr{'common name'}</b></th>
2905 <th width='30%' class='boldbase' align='center'><b> $Lang ::tr{'remark'}</b></th>
2906 <th width='10%' class='boldbase' align='center'><b> $Lang ::tr{'status'}</b></th>
2907 <th class='boldbase' align='center' colspan='6'><b> $Lang ::tr{'action'}</b></th>
2913 foreach my $key ( sort { ncmp
( $confighash { $a }[ 1 ], $confighash { $b }[ 1 ]) } keys %confighash ) {
2914 if ( $confighash { $key }[ 0 ] eq 'on' ) { $gif = 'on.gif' ; } else { $gif = 'off.gif' ; }
2918 $col = "bgcolor=' $color {'color20'}'" ;
2921 $col = "bgcolor=' $color {'color22'}'" ;
2923 print "<td align='center' nowrap='nowrap' $col > $confighash { $key }[1]</td>" ;
2924 print "<td align='center' nowrap='nowrap' $col >" . $Lang :: tr
{ " $confighash { $key }[3]" } . " (" . $Lang :: tr
{ " $confighash { $key }[4]" } . ") $confighash { $key }[29]</td>" ;
2925 if ( $confighash { $key }[ 2 ] eq ' %auth -dn' ) {
2926 print "<td align='left' nowrap='nowrap' $col > $confighash { $key }[9]</td>" ;
2927 } elsif ( $confighash { $key }[ 4 ] eq 'cert' ) {
2928 print "<td align='left' nowrap='nowrap' $col > $confighash { $key }[2]</td>" ;
2930 print "<td align='left' $col > </td>" ;
2932 print "<td align='center' $col > $confighash { $key }[25]</td>" ;
2933 my $col1 = "bgcolor='${Header::colourred}'" ;
2934 my $active = "<b><font color='#FFFFFF'> $Lang ::tr{'capsclosed'}</font></b>" ;
2935 if ( $confighash { $key }[ 33 ] eq "add" ) {
2936 $col1 = "bgcolor='${Header::colourorange}'" ;
2937 $active = "<b><font color='#FFFFFF'> $Lang ::tr{'vpn wait'}</font></b>" ;
2939 foreach my $line ( @status ) {
2940 if (( $line =~ /\"$confighash{$key}[1]\".*IPsec SA established/ ) ||
2941 ( $line =~ /$confighash{$key}[1]\{.*INSTALLED/ )) {
2942 $col1 = "bgcolor='${Header::colourgreen}'" ;
2943 $active = "<b><font color='#FFFFFF'> $Lang ::tr{'capsopen'}</font></b>" ;
2944 } elsif ( $line =~ /$confighash{$key}[1]\[.*CONNECTING/ ) {
2945 $col1 = "bgcolor='${Header::colourorange}'" ;
2946 $active = "<b><font color='#FFFFFF'> $Lang ::tr{'vpn connecting'}</font></b>" ;
2947 } elsif ( $line =~ /$confighash{$key}[1]\{.*ROUTED/ ) {
2948 $col1 = "bgcolor='${Header::colourorange}'" ;
2949 $active = "<b><font color='#FFFFFF'> $Lang ::tr{'vpn on-demand'}</font></b>" ;
2952 # move to blue if really down
2953 if ( $confighash { $key }[ 0 ] eq 'off' && $col1 =~ /${Header::colourred}/ ) {
2954 $col1 = "bgcolor='${Header::colourblue}'" ;
2955 $active = "<b><font color='#FFFFFF'> $Lang ::tr{'capsclosed'}</font></b>" ;
2958 <td align='center' $col1 > $active </td>
2959 <td align='center' $col >
2960 <form method='post' action=' $ENV {'SCRIPT_NAME'}'>
2961 <input type='image' name=' $Lang ::tr{'restart'}' src='/images/reload.gif' alt=' $Lang ::tr{'restart'}' title=' $Lang ::tr{'restart'}' />
2962 <input type='hidden' name='ACTION' value=' $Lang ::tr{'restart'}' />
2963 <input type='hidden' name='KEY' value=' $key ' />
2968 if (( $confighash { $key }[ 4 ] eq 'cert' ) && ( $confighash { $key }[ 2 ] ne ' %auth -dn' )) {
2970 <td align='center' $col >
2971 <form method='post' action=' $ENV {'SCRIPT_NAME'}'>
2972 <input type='image' name=' $Lang ::tr{'show certificate'}' src='/images/info.gif' alt=' $Lang ::tr{'show certificate'}' title=' $Lang ::tr{'show certificate'}' />
2973 <input type='hidden' name='ACTION' value=' $Lang ::tr{'show certificate'}' />
2974 <input type='hidden' name='KEY' value=' $key ' />
2980 print "<td width='2%' $col > </td>" ;
2982 if ( $confighash { $key }[ 4 ] eq 'cert' && - f
"${General::swroot}/certs/ $confighash { $key }[1].p12" ) {
2984 <td align='center' $col >
2985 <form method='post' action=' $ENV {'SCRIPT_NAME'}'>
2986 <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'}' />
2987 <input type='hidden' name='ACTION' value=' $Lang ::tr{'download pkcs12 file'}' />
2988 <input type='hidden' name='KEY' value=' $key ' />
2993 } elsif (( $confighash { $key }[ 4 ] eq 'cert' ) && ( $confighash { $key }[ 2 ] ne ' %auth -dn' )) {
2995 <td align='center' $col >
2996 <form method='post' action=' $ENV {'SCRIPT_NAME'}'>
2997 <input type='image' name=' $Lang ::tr{'download certificate'}' src='/images/floppy.gif' alt=' $Lang ::tr{'download certificate'}' title=' $Lang ::tr{'download certificate'}' />
2998 <input type='hidden' name='ACTION' value=' $Lang ::tr{'download certificate'}' />
2999 <input type='hidden' name='KEY' value=' $key ' />
3005 print "<td width='2%' $col > </td>" ;
3008 <td align='center' $col >
3009 <form method='post' action=' $ENV {'SCRIPT_NAME'}'>
3010 <input type='image' name=' $Lang ::tr{'toggle enable disable'}' src='/images/ $gif ' alt=' $Lang ::tr{'toggle enable disable'}' title=' $Lang ::tr{'toggle enable disable'}' />
3011 <input type='hidden' name='ACTION' value=' $Lang ::tr{'toggle enable disable'}' />
3012 <input type='hidden' name='KEY' value=' $key ' />
3016 <td align='center' $col >
3017 <form method='post' action=' $ENV {'SCRIPT_NAME'}'>
3018 <input type='hidden' name='ACTION' value=' $Lang ::tr{'edit'}' />
3019 <input type='image' name=' $Lang ::tr{'edit'}' src='/images/edit.gif' alt=' $Lang ::tr{'edit'}' title=' $Lang ::tr{'edit'}' />
3020 <input type='hidden' name='KEY' value=' $key ' />
3023 <td align='center' $col >
3024 <form method='post' action=' $ENV {'SCRIPT_NAME'}'>
3025 <input type='hidden' name='ACTION' value=' $Lang ::tr{'remove'}' />
3026 <input type='image' name=' $Lang ::tr{'remove'}' src='/images/delete.gif' alt=' $Lang ::tr{'remove'}' title=' $Lang ::tr{'remove'}' />
3027 <input type='hidden' name='KEY' value=' $key ' />
3037 # If the config file contains entries, print Key to action icons
3042 <td class='boldbase'> <b> $Lang ::tr{'legend'}:</b></td>
3043 <td> <img src='/images/on.gif' alt=' $Lang ::tr{'click to disable'}' /></td>
3044 <td class='base'> $Lang ::tr{'click to disable'}</td>
3045 <td> <img src='/images/info.gif' alt=' $Lang ::tr{'show certificate'}' /></td>
3046 <td class='base'> $Lang ::tr{'show certificate'}</td>
3047 <td> <img src='/images/edit.gif' alt=' $Lang ::tr{'edit'}' /></td>
3048 <td class='base'> $Lang ::tr{'edit'}</td>
3049 <td> <img src='/images/delete.gif' alt=' $Lang ::tr{'remove'}' /></td>
3050 <td class='base'> $Lang ::tr{'remove'}</td>
3054 <td> <img src='/images/off.gif' alt='?OFF' /></td>
3055 <td class='base'> $Lang ::tr{'click to enable'}</td>
3056 <td> <img src='/images/floppy.gif' alt='?FLOPPY' /></td>
3057 <td class='base'> $Lang ::tr{'download certificate'}</td>
3058 <td> <img src='/images/reload.gif' alt='?RELOAD'/></td>
3059 <td class='base'> $Lang ::tr{'restart'}</td>
3067 <table width='100%'>
3068 <tr><td align='right' colspan='9'>
3069 <form method='post' action=' $ENV {'SCRIPT_NAME'}'>
3070 <input type='submit' name='ACTION' value=' $Lang ::tr{'add'}' />
3076 & Header
:: closebox
();
3078 & Header
:: openbox
( '100%' , 'left' , " $Lang ::tr{'certificate authorities'}" );
3080 <table width='100%' cellspacing='1' cellpadding='0' class='tbl'>
3082 <th width='25%' class='boldbase' align='center'><b> $Lang ::tr{'name'}</b></th>
3083 <th width='65%' class='boldbase' align='center'><b> $Lang ::tr{'subject'}</b></th>
3084 <th width='10%' class='boldbase' colspan='3' align='center'><b> $Lang ::tr{'action'}</b></th>
3088 my $col1 = "bgcolor=' $color {'color22'}'" ;
3089 my $col2 = "bgcolor=' $color {'color20'}'" ;
3090 if (- f
"${General::swroot}/ca/cacert.pem" ) {
3091 my $casubject = & Header
:: cleanhtml
( getsubjectfromcert
( "${General::swroot}/ca/cacert.pem" ));
3094 <td class='base' $col1 > $Lang ::tr{'root certificate'}</td>
3095 <td class='base' $col1 > $casubject </td>
3096 <td width='3%' align='center' $col1 >
3097 <form method='post' action=' $ENV {'SCRIPT_NAME'}'>
3098 <input type='hidden' name='ACTION' value=' $Lang ::tr{'show root certificate'}' />
3099 <input type='image' name=' $Lang ::tr{'edit'}' src='/images/info.gif' alt=' $Lang ::tr{'show root certificate'}' title=' $Lang ::tr{'show root certificate'}' />
3102 <td width='3%' align='center' $col1 >
3103 <form method='post' action=' $ENV {'SCRIPT_NAME'}'>
3104 <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'}' />
3105 <input type='hidden' name='ACTION' value=' $Lang ::tr{'download root certificate'}' />
3108 <td width='4%' $col1 > </td></tr>
3112 # display rootcert generation buttons
3115 <td class='base' $col1 > $Lang ::tr{'root certificate'}:</td>
3116 <td class='base' $col1 > $Lang ::tr{'not present'}</td>
3117 <td colspan='3' $col1 > </td></tr>
3122 if (- f
"${General::swroot}/certs/hostcert.pem" ) {
3123 my $hostsubject = & Header
:: cleanhtml
( getsubjectfromcert
( "${General::swroot}/certs/hostcert.pem" ));
3127 <td class='base' $col2 > $Lang ::tr{'host certificate'}</td>
3128 <td class='base' $col2 > $hostsubject </td>
3129 <td width='3%' align='center' $col2 >
3130 <form method='post' action=' $ENV {'SCRIPT_NAME'}'>
3131 <input type='hidden' name='ACTION' value=' $Lang ::tr{'show host certificate'}' />
3132 <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'}' />
3135 <td width='3%' align='center' $col2 >
3136 <form method='post' action=' $ENV {'SCRIPT_NAME'}'>
3137 <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'}" />
3138 <input type='hidden' name='ACTION' value=" $Lang ::tr{'download host certificate'}" />
3141 <td width='4%' $col2 > </td></tr>
3148 <td width='25%' class='base' $col2 > $Lang ::tr{'host certificate'}:</td>
3149 <td class='base' $col2 > $Lang ::tr{'not present'}</td>
3150 <td colspan='3' $col2 > </td></tr>
3156 if ( keys %cahash > 0 ) {
3157 foreach my $key ( keys %cahash ) {
3158 if ( $rowcolor ++ % 2 ) {
3160 $col = "bgcolor=' $color {'color20'}'" ;
3163 $col = "bgcolor=' $color {'color22'}'" ;
3165 print "<td class='base' $col > $cahash { $key }[0]</td> \n " ;
3166 print "<td class='base' $col > $cahash { $key }[1]</td> \n " ;
3168 <td align='center' $col >
3169 <form method='post' name='cafrm${key}a' action=' $ENV {'SCRIPT_NAME'}'>
3170 <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'}' />
3171 <input type='hidden' name='ACTION' value=' $Lang ::tr{'show ca certificate'}' />
3172 <input type='hidden' name='KEY' value=' $key ' />
3175 <td align='center' $col >
3176 <form method='post' name='cafrm${key}b' action=' $ENV {'SCRIPT_NAME'}'>
3177 <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'}' />
3178 <input type='hidden' name='ACTION' value=' $Lang ::tr{'download ca certificate'}' />
3179 <input type='hidden' name='KEY' value=' $key ' />
3182 <td align='center' $col >
3183 <form method='post' name='cafrm${key}c' action=' $ENV {'SCRIPT_NAME'}'>
3184 <input type='hidden' name='ACTION' value=' $Lang ::tr{'remove ca certificate'}' />
3185 <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'}' />
3186 <input type='hidden' name='KEY' value=' $key ' />
3196 # If the file contains entries, print Key to action icons
3197 if ( - f
"${General::swroot}/ca/cacert.pem" ) {
3200 <td class='boldbase'> <b> $Lang ::tr{'legend'}:</b></td>
3201 <td> <img src='/images/info.gif' alt=' $Lang ::tr{'show certificate'}' /></td>
3202 <td class='base'> $Lang ::tr{'show certificate'}</td>
3203 <td> <img src='/images/floppy.gif' alt=' $Lang ::tr{'download certificate'}' /></td>
3204 <td class='base'> $Lang ::tr{'download certificate'}</td>
3209 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>" ;
3213 <form method='post' enctype='multipart/form-data' action=' $ENV {'SCRIPT_NAME'}'>
3214 <table width='100%' border='0' cellspacing='1' cellpadding='0'>
3217 <td class='base' nowrap='nowrap'> $Lang ::tr{'ca name'}: <img src='/blob.gif' alt='*' /></td>
3218 <td nowrap='nowrap'><input type='text' name='CA_NAME' value=' $cgiparams {'CA_NAME'}' size='15' /> </td>
3219 <td nowrap='nowrap'><input type='file' name='FH' size='30' /></td>
3220 <td nowrap='nowrap'><input type='submit' name='ACTION' value=' $Lang ::tr{'upload ca certificate'}' /></td>
3223 <td colspan='3'> $Lang ::tr{'resetting the vpn configuration will remove the root ca, the host certificate and all certificate based connections'}:</td>
3224 <td align='right'><input type='submit' name='ACTION' value=' $Lang ::tr{'remove x509'}' /></td>
3230 & Header
:: closebox
();
3231 & Header
:: closebigbox
();
3232 & Header
:: closepage
();
3234 sub array_unique
($) {
3239 foreach my $e ( @
$array ) {
3240 next if $seen { $e }++;
3247 sub make_algos
($$$$$) {
3248 my ( $mode , $encs , $ints , $grps , $pfs ) = @_ ;
3251 foreach my $enc ( @
$encs ) {
3252 foreach my $int ( @
$ints ) {
3253 foreach my $grp ( @
$grps ) {
3256 if ( $mode eq "ike" ) {
3259 if ( $grp =~ m/^e(.*)$/ ) {
3260 push ( @algo , "ecp $1 " );
3261 } elsif ( $grp =~ m/curve25519/ ) {
3262 push ( @algo , " $grp " );
3264 push ( @algo , "modp $grp " );
3267 } elsif ( $mode eq "esp" && $pfs ) {
3268 my $is_aead = ( $enc =~ m/[cg]cm/ );
3274 if ( $grp eq "none" ) {
3276 } elsif ( $grp =~ m/^e(.*)$/ ) {
3277 push ( @algo , "ecp $1 " );
3278 } elsif ( $grp =~ m/curve25519/ ) {
3279 push ( @algo , " $grp " );
3281 push ( @algo , "modp $grp " );
3285 push ( @algos , join ( "-" , @algo ));
3290 return & array_unique
( \
@algos );
3293 sub make_subnets
($) {
3294 my $subnets = shift ;
3296 my @nets = split ( /\|/ , $subnets );
3298 foreach my $net ( @nets ) {
3299 my $cidr_net = & General
:: ipcidr
( $net );
3300 push ( @cidr_nets , $cidr_net );
3303 return join ( "," , @cidr_nets );