Skip to content

Commit

Permalink
improve the regex used to parse the SSL-Cert
Browse files Browse the repository at this point in the history
 - Drop the port from the hostname
 - Use a wildcare only if there is a domain
  • Loading branch information
Gonéri Le Bouder committed Nov 28, 2011
1 parent a291e4d commit 5001036
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/FusionInventory/Agent/Network.pm
Expand Up @@ -362,9 +362,10 @@ sub setSslRemoteHost {
# Check server name against provided SSL certificate
if ( $self->{URI} =~ /^https:\/\/([^\/]+).*$/i ) {
my $re = $1;
$re =~ s/:\d+//;
# Accept SSL cert will hostname with wild-card
# http://forge.fusioninventory.org/issues/542
$re =~ s/^([^\.]+)/($1|\\*)/;
$re =~ s/^([^\.]+)\.(.+)/($1|\\*)/;
# protect some characters, $re will be evaluated as a regex
$re =~ s/([\-\.])/\\$1/g;
$ua->default_header('If-SSL-Cert-Subject' => '/CN='.$re.'($|\/)');
Expand Down

0 comments on commit 5001036

Please sign in to comment.