Perl 500罐';t连接到example.com:443(LWP::Protocol::https::Socket:SSL连接尝试失败,出现未知错误SSL希望先读取)

Perl 500罐';t连接到example.com:443(LWP::Protocol::https::Socket:SSL连接尝试失败,出现未知错误SSL希望先读取),perl,ssl,Perl,Ssl,我想用这个从GitLab CE导出问题 我在macOS 10.10.5上运行了以下命令: sudo /usr/bin/perl -MCPAN -e'install Text::CSV_XS' sudo cpan Mozilla::CA sudo cpan install LWP sudo cpan LWP::Protocol::https 但是,我仍然会遇到以下错误: 500无法连接到gitlab.lrz.de:443(LWP::Protocol::https::Socket:SSL连接尝试失

我想用这个从GitLab CE导出问题

我在macOS 10.10.5上运行了以下命令:

sudo /usr/bin/perl -MCPAN -e'install Text::CSV_XS'
sudo cpan Mozilla::CA
sudo cpan install LWP
sudo cpan LWP::Protocol::https
但是,我仍然会遇到以下错误:

500无法连接到gitlab.lrz.de:443(LWP::Protocol::https::Socket:SSL连接尝试失败,出现未知错误SSL希望先读取)/Users/kiaora/Downloads/get-all-project-issues.pl第41行`

这是我第一次使用perl。非常感谢您的帮助

我只更改了这些行:

my $PROJECT_ID="myProjectID"; # numeric project id, can be found in project -> general settings
my $GITLAB_API_PRIVATE_TOKEN='myToken(scope read_repository)'; # obtained from https://gitlab.lrz.de/profile/personal_access_tokens
my $baseurl = "https://gitlab.lrz.de/"; # change if using a private install
编辑:

#!/usr/bin/perl -w

use strict;

use LWP::UserAgent;
use Text::CSV_XS qw( csv );
use JSON::PP qw(decode_json);
# Uncomment these for debugging
# use LWP::ConsoleLogger::Easy qw( debug_ua );
# use Data::Dumper;

my $PROJECT_ID="--my-project-id--"; # numeric project id, can be found in project -> general settings
my $GITLAB_API_PRIVATE_TOKEN='--my-api-private-token--'; # obtained from https://gitlab.com/profile/personal_access_tokens
my $baseurl = "https://gitlab.lrz.de/"; # change if using a private install

$baseurl .= "api/v4/";
my $issuesurl = $baseurl."projects/".$PROJECT_ID."/issues";

my @issues = ();
my $page = 1;
my $totalpages;

do
{

    my %query_hash = (
        'per_page' => 100,
        'page' => $page
    );

    print "Fetching page $page".(defined($totalpages)?" (of $totalpages)":"")."\n";

    my $ua = LWP::UserAgent->new();
    # debug_ua($ua);
    $ua->default_header('PRIVATE-TOKEN' => $GITLAB_API_PRIVATE_TOKEN);

    my $uri = URI->new($issuesurl);
    $uri->query_form(%query_hash);
    my $resp = $ua->get($uri);
    if (!$resp->is_success) {
        die $resp->status_line;
    }
    $totalpages = int($resp->header("X-Total-Pages"));

    my $resptext;
    $resptext = $resp->decoded_content;

    my $issuedata = decode_json($resptext);

    push(@issues, @{$issuedata});
}
while ($page++ < $totalpages);

my $outputfname = "issues.csv";
my $csv = Text::CSV_XS->new ({ binary => 1, eol => $/ });
open my $fh, ">", $outputfname or die "$outputfname: $!";

my @headings = [
    "URL",
    "Milestone",
    "Author",
    "Title",
    "Description",
    "State",
    "Assignees",
    "Labels",
    "Created At",
    "Updated At",
    "Closed At",
    "Due date",
    "Confidental",
    "Weight",
    "Locked",
    "Time estimate",
    "Time spent",
    "Human Time estimate",
    "Human Time spent",
];
$csv->print ($fh, @headings) or $csv->error_diag;

foreach my $i (@issues)
{
#    print Dumper([$i])."\n";
    my @values = [
        $i->{'web_url'},
        $i->{'milestone'}->{'title'},
        $i->{'author'}->{'username'},
        $i->{'title'},
        $i->{'description'},
        $i->{'state'},
        join(',', map {$_->{'username'}} @{$i->{'assignees'}}),
        join(',', @{$i->{'labels'}}),
        $i->{'created_at'},
        $i->{'updated_at'},
        $i->{'closed_at'},
        $i->{'due_date'},
        $i->{'confidential'},
        $i->{'weight'},
        $i->{'discussion_locked'},
        $i->{'time_stats'}->{'time_estimate'},
        $i->{'time_stats'}->{'total_time_spent'},
        $i->{'time_stats'}->{'human_time_estimate'},
        $i->{'time_stats'}->{'human_total_time_spent'},
        $i->{'closed_by'}->{'username'},

    ];
    $csv->print ($fh, @values) or $csv->error_diag;    
}

close $fh or die "$outputfname: $!";

print "Issues saved to $outputfname\n";
#/usr/bin/perl-w
严格使用;
使用LWP::UserAgent;
使用Text::CSV_XS qw(CSV);
使用JSON::PP qw(解码_JSON);
#取消注释以进行调试
#使用LWP::ConsoleLogger::Easy qw(调试);
#使用数据::转储程序;
my$PROJECT_ID=“--my PROJECT ID--”;#数字项目id,可在项目->常规设置中找到
我的$GITLAB_API_PRIVATE_TOKEN='--我的API PRIVATE TOKEN--'.#从https://gitlab.com/profile/personal_access_tokens
我的$baseurl=”https://gitlab.lrz.de/"; # 如果使用私有安装,则进行更改
$baseurl.=“api/v4/”;
my$issuesurl=$baseurl.projects/“$PROJECT\u ID./issues”;
我的@issues=();
我的$page=1;
我的$totalpages;
做
{
我的%query\u哈希=(
“每页”=>100,
“页面”=>$page
);
打印“获取页面$page”。(已定义($totalpages)?“(共$totalpages)”:“”。)。\n;
my$ua=LWP::UserAgent->new();
#调试单位($ua);
$ua->default\u头('PRIVATE-TOKEN'=>$GITLAB\u API\u PRIVATE\u-TOKEN);
my$uri=uri->new($issuesurl);
$uri->query\u form(%query\u hash);
my$resp=$ua->get($uri);
如果(!$resp->is_success){
模具$resp->status\u行;
}
$totalpages=int($resp->header(“X-Total-Pages”);
我的文字;
$resptext=$resp->解码内容;
my$issuedata=decode_json($resptext);
推送(@issues,@{$issuedata});
}
而($page++<$totalpages);
我的$outputfname=“issues.csv”;
my$csv=Text::csv_XS->new({binary=>1,eol=>$/});
打开我的$fh,“>”,$outputfname,或者死“$outputfname:$!”;
我的@headers=[
“网址”,
“里程碑”,
“作者”,
“头衔”,
“说明”,
“国家”,
“受让人”,
“标签”,
“创建于”,
“更新于”,
“截止日期”,
“到期日”,
“机密”,
“重量”,
“锁定”,
“时间估计”,
“花费的时间”,
“人类时间估算”,
“人类花费的时间”,
];
$csv->打印($fh,@标题)或$csv->错误诊断;
foreach我的$i(@issues)
{
#打印转储程序([$i])。“\n”;
我的@values=[
$i->{'web\u url'},
$i->{'milestone'}->{'title'},
$i->{'author'}->{'username'},
$i->{'title'},
$i->{'description'},
$i->{'state'},
join(“,”,map{$\->{'username'}}@{$i->{'assignees'}}),
连接(“,”,@{$i->{'labels'}),
$i->{'created_at'},
$i->{'U'at'},
$i->{'closed_at'},
$i->{'due_date'},
$i->{'机密'},
$i->{'weight'},
$i->{'discussion\u locked'},
$i->{'time\u stats'}->{'time\u estimate'},
$i->{'时间统计'}->{'花费的总时间'},
$i->{'time_stats'}->{'human_time_estimate'},
$i->{'time_stats'}->{'human_total_time_lower'},
$i->{'closed_by'}->{'username'},
];
$csv->打印($fh,@values)或$csv->错误诊断;
}
关闭$fh或死“$outputfname:$!”;
打印“保存到$outputfname的问题\n”;

您可以将这些安装命令缩短为
sudo cpan Text::CSV_XS Mozilla::CA LWP LWP::Protocol::https
。而
cpan安装
是不必要的,因为它安装了
install.pm
,这是一个虚拟模块,从未使用过。另外,
sudocpan
通常是个坏主意。如果您需要调试Perl代码的帮助,您应该发布该代码。另一方面,如果您只是试图使用一个碰巧是用Perl编写的工具,那么您的站点就错了:StackOverflow是用来回答有关编程的问题的。试试吧?或者这个工具有官方的支持论坛吗?@melpomene谢谢你的建议。我会记住的。你知道如何处理这个错误吗?正如我在问题中提到的,我根本不知道perl是如何工作的。我在谷歌上做了相当多的工作,这就是我如何理解问题中列出的命令。不过,我会添加脚本的代码。您运行的是旧版本的macOS,这表明您还使用了旧版本macOS附带的早已过时的OpenSSL版本0.9.8。此版本不支持TLS 1.1或TLS 1.2,但服务器至少需要支持TLS 1.1。请使用
perl-MNet::SSLeay-E'say Net::SSLeay::SSLeay\u version'
检查您的OpenSSL版本。谢谢Steffen!2015年7月14日,我确实运行了
OpenSSL 0.9.8zg