perl包安装的CPAN大坑
先看一个用cpan安装的例子。
$cpan -i App::cpanminus
Loading internal logger. Log::Log4perl recommended for better logging
Reading '/home/wubin/.cpan/Metadata'
Database was generated on Tue, 24 Dec 2024 15:29:01 GMT
Running install for module 'App::cpanminus'
Trying with
/usr/bin/wget -O "/home/wubin/.cpan/sources/authors/id/M/MI/MIYAGAWA/App-cpanminus-1.7048.tar.gz.tmp102266"
to get
https://cpan.org/authors/id/M/MI/MIYAGAWA/App-cpanminus-1.7048.tar.gz
--2024-12-25 16:27:09-- https://cpan.org/authors/id/M/MI/MIYAGAWA/App-cpanminus-1.7048.tar.gz
正在解析主机 cpan,org...151.101.193.55,151.101.1.55,151.101.65.55
正在连接 cpan,orgl151.101.193.551:443...已连接。
错误:无法验证 cpan.org 的由 "/c=Us/o=Let's Encrypt/CN=R11" 颁发的证书:
无法本地校验颁发者的权限。
要以不安全的方式连接至 cpan.org,使用:--no-check-certificate
Function system("/usr/bin/wget -O "/home/wubin/.cpan/sources/authors/id/M/MI/MIYAGAWA/App-cpanminus-1.7048.tar.gz.tmp102266" "https://cpan.org/authors/id/M/MI/MIYAGAWA/App-cpanminus-1.7048.tar.gz" ")
returned status 5 (wstat 1280), left
/home/wubin/.cpan/sources/authors/id/M/MI/MIYAGAWA/App-cpanminus-1.7048.tar.gz.tmp102266 with size 0
Giving up on '/home/wubin/.cpan/sources/authors/id/M/MI/MIYAGAWA/App-cpanminus-1.7048.tar.gz'
Note: Current database in memory was generated on Tue, 24 Dec 2024 15:29:01 GMT
如果是直接用wget 下载,那当然可以直接添加 “--no-check-certificate”,
但我用的不是wget命令,而是cpan命令?
cpan调用了wget来下载,
怎么将 “--no-check-certificate”这个参数传给wget?
github上这个帖子有几个解决方式:
https://github.com/miyagawa/cpanminus/issues/634
分别是:
- 第一种
$ cat ~.wgetrc
check_certificate = off
- 第二种
setting PERL_LWP_SSL_VERIFY_HOSTNAME to 0 will disable the SSL hostname verification.
https://metacpan.org/pod/LWP#PERL_LWP_SSL_VERIFY_HOSTNAME
CPAN is still available over HTTP. The index pages redirect to HTTPS, but individual files for modules and indexes are available over HTTP.
Try: curl -svo /dev/null http://www.cpan.org/modules/02packages.details.txt.gz and you will see 200 OK, not 301 redirect.
最终是第二种方式管用:
PERL_LWP_SSL_VERIFY_HOSTNAME=0 cpan install Net::SSLeay