Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

First pass at adding HTTPS support to CPAN. #119

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Makefile.PL
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ my $prereq_pm = {
# Scalar::Util;
# PathTools-3.16.tar.gz
'File::Temp' => 0, # TJENNESS; requires Test::More;
'Mozilla::CA' => 0, # enables LWP::UserAgent https cert checks
'Net::Ping' => 0, # SMPETERS;
'Scalar::Util' => 0, # GBARR;
# Scalar-List-Utils-1.18.tar.gz;
Expand Down Expand Up @@ -125,6 +126,7 @@ for my $interesting_module (qw(
MIME::Base64
Module::Build
Module::Signature
Mozilla::CA
Net::FTP
Parse::CPAN::Meta
Scalar::Util
Expand Down
4 changes: 2 additions & 2 deletions lib/App/Cpan.pm
Original file line number Diff line number Diff line change
Expand Up @@ -976,12 +976,12 @@ sub _find_good_mirrors {
);

foreach my $mirror ( @mirrors ) {
next unless eval { $mirror->can( 'http' ) };
next unless eval { $mirror->can( 'http' ) || $mirror->can( 'https' ) };
_print_ping_report( $mirror->http );
}

$CPAN::Config->{urllist} = [
map { $_->http } @mirrors
map { $->can( 'https' ) ? $_->https : $_->http } @mirrors
];
}

Expand Down
2 changes: 1 addition & 1 deletion lib/CPAN.pm
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ unless (@CPAN::Defaultsites) {
@CPAN::Defaultsites = map {
CPAN::URL->new(TEXT => $_, FROM => "DEF")
}
"http://www.perl.org/CPAN/",
"https://www.cpan.org/",
"ftp://ftp.perl.org/pub/CPAN/";
}
# $CPAN::iCwd (i for initial)
Expand Down
4 changes: 2 additions & 2 deletions lib/CPAN/Distribution.pm
Original file line number Diff line number Diff line change
Expand Up @@ -4265,7 +4265,7 @@ sub _getsave_url {
");
my $Ua;
CPAN::LWP::UserAgent->config;
eval { $Ua = CPAN::LWP::UserAgent->new; };
eval { $Ua = CPAN::LWP::UserAgent->new(ssl_opts => { verify_hostname => 1 }); };
if ($@) {
$CPAN::Frontend->mywarn("ERROR: CPAN::LWP::UserAgent->new dies with $@\n");
return;
Expand Down Expand Up @@ -4414,7 +4414,7 @@ sub reports {

CPAN::LWP::UserAgent->config;
my $Ua;
eval { $Ua = CPAN::LWP::UserAgent->new; };
eval { $Ua = CPAN::LWP::UserAgent->new(ssl_opts => { verify_hostname => 1 }); };
if ($@) {
$CPAN::Frontend->mydie("CPAN::LWP::UserAgent->new dies with $@\n");
}
Expand Down
6 changes: 5 additions & 1 deletion lib/CPAN/Mirrors.pm
Original file line number Diff line number Diff line change
Expand Up @@ -491,6 +491,9 @@ sub _parse {
elsif ( $prop eq 'dst_http' ) {
$mirror->{http} = $value;
}
elsif ( $prop eq 'dst_https' ) {
$mirror->{https} = $value;
}
elsif ( $prop eq 'dst_ftp' ) {
$mirror->{ftp} = $value;
}
Expand Down Expand Up @@ -535,14 +538,15 @@ sub hostname { shift->{hostname} }
sub continent { shift->{continent} }
sub country { shift->{country} }
sub http { shift->{http} || '' }
sub https { shift->{https} || '' }
sub ftp { shift->{ftp} || '' }
sub rsync { shift->{rsync} || '' }
sub rtt { shift->{rtt} }
sub ping_time { shift->{ping_time} }

sub url {
my $self = shift;
return $self->{http} || $self->{ftp};
return $self->{https} || $self->{http} || $self->{ftp};
}

sub ping {
Expand Down
2 changes: 1 addition & 1 deletion lib/CPAN/Shell.pm
Original file line number Diff line number Diff line change
Expand Up @@ -1944,7 +1944,7 @@ sub recent {
}
CPAN::LWP::UserAgent->config;
my $Ua;
eval { $Ua = CPAN::LWP::UserAgent->new; };
eval { $Ua = CPAN::LWP::UserAgent->new(ssl_opts => { verify_hostname => 1 }); };
if ($@) {
$CPAN::Frontend->mydie("CPAN::LWP::UserAgent->new dies with $@\n");
}
Expand Down
3 changes: 2 additions & 1 deletion t/11mirroredby.t
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ my $cmb = CPAN::Mirrored::By->new(
continent => "continent",
country => "country",
http => "http",
https => "https",
ftp => "ftp",
}
);
Expand All @@ -26,7 +27,7 @@ isa_ok( $cmb, 'CPAN::Mirrored::By' );
is( $cmb->continent(), 'continent',
'continent() should return continent entry' );
is( $cmb->country(), 'country', 'country() should return country entry' );
is( $cmb->url(), 'http', 'url() should return best url entry' );
is( $cmb->url(), 'https', 'url() should return best url entry' );

__END__
# Local Variables:
Expand Down
13 changes: 13 additions & 0 deletions t/CPAN/TestMirroredBy
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
# frequency = "daily/bidaily/.../weekly"
# dst_ftp = "ftp://the.same.host.name:/CPAN/mirror/directory/"
# dst_http = "http://the.same.host.name:/CPAN/mirror/directory/"
# dst_https = "https://the.same.host.name:/CPAN/mirror/directory/"
# dst_rsync = "the.same.host.name::CPAN"
# dst_location = "city, (area?, )country, continent (lat long)"
# dst_organisation = "full organisation name"
Expand Down Expand Up @@ -4237,5 +4238,17 @@ telmexchile.cl:
# dst_contact = "mailto:rdc.cl$ftpadm
# dst_src = "ftp.oleane.net"

weekly.org:
frequency = "daily"
dst_http = "http://cpan.weekly.org/"
dst_https = "https://cpan.weekly.org/"
dst_location = "Palo Alto, California, United States, North America (+37.424891 -122.100833)"
dst_organisation = "Primatech Paper Co."
dst_timezone = "-8"
dst_bandwidth = "100 Mb/s"
dst_contact = "weekly.org(david"
dst_src = "rsync://cpan-rsync.perl.org/CPAN/"

# dst_dst = "http://cpan.weekly.org/"

# here endeth MIRRORED.BY