Mojo :: useragent SSL失败

问题描述 投票:0回答:1

我正在使用Mojo :: Useragent获取使用HTTP_PROXY和HTTPS_PROXY定义的代理后面的一些站点

下面是一个代码示例:

my $rs = $ua->insecure(1)->get($mysite) 
if($rs->res->is_success) {
    .....
} else {
    print "Problem with fetching $mysite \n";
    print $rs->res->error->{message};
}

我收到此错误:

SSL连接尝试失败错误:14077419:SSL例程:SSL23_GET_SERVER_HELLO:tlsv1警报访问被拒绝

当我在同一台机器上使用curl时,我得到了预期的结果。

不知道如何解决这个问题?

perl ssl mojolicious mojo-useragent
1个回答
1
投票

形成SSL错误,看起来您的网络正在积极拒绝让您通过。

定义环境变量HTTP_PROXY和HTTPS_PROXY很好,但是你需要告诉Mojo :: UserAgent使用它们(与cURL不同,它默认会自动查找它们)。

在运行查询之前,将此行添加到代码中:

$ua->proxy->detect;

the Mojo::UserAgent::Proxy documentation

如果您在不使用环境变量的情况下寻找纯Perl解决方案,则可以直接在代码中手动配置代理,例如:

$ua->proxy
      ->http('http://127.0.0.1:8080')
      ->https('http://127.0.0.1:8080');
© www.soinside.com 2019 - 2024. All rights reserved.