gpt4 book ai didi

perl - Mojo::useragent SSL 失败

转载 作者:太空宇宙 更新时间:2023-11-03 14:00:13 25 4
gpt4 key购买 nike

我正在使用 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 connect attempt failed error:14077419:SSL routines:SSL23_GET_SERVER_HELLO:tlsv1 alert access denied

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

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

最佳答案

形成 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');

关于perl - Mojo::useragent SSL 失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53728872/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com